View Full Version : Draw SKPolyline below all SKAnnotation

25.02.2016, 13:15
I first draw one SKPolyline and then several SKAnnotation, but i can't the hierarchy for them, some SKAnnotation getting drawn under the polyline, while some drawn above.

I tried to enumerate all my annotations and force the to front using bringToFrontAnnotation: method of my SKMapView, but no luck.

How can i change the drawing order of these elements? Its just looks random to me.

Thank you

25.02.2016, 13:42
Right now the ID is the only way of ordering the annotations (smaller id, higher the priority) -e.g. you want to change the z-index order of 2 annotations remove and add one of the annotations with a new id. i.e on iOS: SKMapView.drawingOrderType = SKAnnotationsOverDrawableObjects (you can specify if all overlays should be on top of all annotations or the other way around, you cannot have mixed behaviour).
A more robust z-index ordering feature is in development as we speak and should make it to the next (or the one after the next) SDK update.

25.02.2016, 14:33
I set mapView.settings.drawingOrderType = SKAnnotationsOverDrawableObjects and i also set my SKPolyline's identifier to 0 (while all my SKAnnotation's identifier is bigger than 0) but still no luck.

For the first draw, its okay, polyline is under everything, then i switch to another tab and back, then anything is above my polyline (while i not set neither of it). Then i switch away and back again and my polyline is below everything again and go on.

29.03.2016, 09:36
Please note that you need to update each time you re-enter the SKMapView

04.04.2016, 08:36
What exactly do we need to update when switching away and back to the Map? I'm expecting the component to have some retain abilities of its settings.

But the ordering via the drawingOrderType sometimes fails, though.

18.04.2016, 13:13
The fact that the value of drawingOrderType is not remembered when moving from map to map is a bug which will be addressed.

The current workaround is to re-issue SKMapView.drawingOrderType = SKAnnotationsOverDrawableObjects in viewWillAppear.