You can create a line with an arrow by using the MGLineStyleLayer.linePattern
property.
First, create a UIImage
with the pattern that you would like to use (in this case, a line with an arrow). Then add that image to your style using [MGLStyle setImage:forName]
. That image can then be used for the line pattern.
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)
}
}