我需要一条指点线来告诉别人一条线的顺序。
我使用mapbox-ios中的MGLLineStyleLayer添加了虚线样式(示例:-),但我不知道它是否支持(>>>>)样式或箭头(->-),请告诉我该怎么办。
发布于 2019-08-24 02:40:07
可以使用MGLineStyleLayer.linePattern属性创建带箭头的直线。
首先,使用您想要使用的模式创建一个UIImage (在本例中,是一条带箭头的线)。然后使用[[MGLStyle setImage:forName]](https://docs.mapbox.com/ios/api/maps/5.2.0/Classes/MGLStyle.html#/c:objc(cs%29MGLStyle(im%29setImage:forName:) )将该图像添加到样式中。然后可以将该图像用于线条图案。
func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) {
if let image = UIImage(named: "arrow.png") {
style.setImage(image, forName: "arrow")
let source = MGLShapeSource(identifier: "polyline", shape: shapeFromGeoJSON, options: nil)
style.addSource(source)
let layer = MGLLineStyleLayer(identifier: "polyline", source: source)
layer.linePattern = NSExpression(forConstantValue: "arrow")
layer.lineWidth = NSExpression(forConstantValue: 10)
style.addLayer(layer)
}
}https://stackoverflow.com/questions/57588491
复制相似问题