I'm coding an iOS app with a Mapbox MGLMapView
displayed on my view controller, on this mapView I draw a route using a MGLShapeSource
, MGLLineStyleLayer
and MGLPolylineFeature
objects.
Here is the code :
let newSource = MGLShapeSource(identifier: "polylineBlue", shape: self.polylines, options: nil)
mapView.style?.addSource(newSource)
let newStyle = MGLLineStyleLayer(identifier: "polylineBlueLayer", source: source)
...styling my layer...
mapView.style?.addLayer(newStyle)
source.shape = self.polylines // a MGLPolylineFeature object
Works great for the route but there is one issue : is appears on top of my annotations.
I add the annotation with regular mapView function :
mapView.addAnnotations([..my MGLPointAnnotation objects...])
I've tried searching here and other websites, I only found one topic and there is nothing helpful except someone saying that we can't set a z layer position on annotations so no fix for that.
Does someone know a workaround ? Do I have to use that : https://docs.mapbox.com/ios/maps/examples/add-marker-symbol/ ?
if so, do I need to create one MGLSymbolStyleLayer
per annotation ?
Sounds like a painful solution for a so basic need...
Thanks !