PDA

View Full Version : Z order of annotations



jimt2000
04.05.2016, 17:06
I have a map with several annotations. You can add two additional annotations to our map by long pressing a point on the map. These two additional annotations define the start and end point for routing while offline. Its possible that the two new additional annotations overlap other annotations already on the map, so we call bringToFrontAnnotation to bring the annotations to the front.

The problem is that we can only get one annotation to be in front. When we call bringToFrontAnnotation on the second annotation, the first annotation goes back behind all the other annotations.

2520

When we bring the green pin (top right corner of the image), the red image goes behind the the other pins. Now if we call bringToFrontAnnotation for the red pin, the green pin will appear under the pins it overlaps. We cannot seem to get both pins to be on top.

Do you have an suggestions on how we can get both pins on top?

Thanks,
Jim

Adela_Silvia
11.05.2016, 11:03
Try to solve this by assigning annotation id for the annotations. Avoid to use 0 and 1 as these two ids caused some issues as they are predefined at our core level (start from a higher level)

jimt2000
11.05.2016, 16:59
Thanks for the reply.

We start our annotation identifiers at 1001.



class ABPSkobblerMapAnnotation: SKAnnotation {

static let PIN_VIEW_START_ID: Int = 1000
static var pendingPinId: Int = 1

// Guarantee unique pin identifiers starting from PIN_VIEW_START_ID
var nextPinId: Int32 {
let value = ABPSkobblerMapAnnotation.pendingPinId + 1
ABPSkobblerMapAnnotation.pendingPinId = value
return Int32( ( ABPSkobblerMapAnnotation.PIN_VIEW_START_ID + value ) )
}

override init() {
super.init()
self.identifier = nextPinId
}
}

Adela_Silvia
19.05.2016, 13:30
You should add for the starting point and for the end point an id lower than 1001 (e.g: 100 for the starting point and 101 for the end point)- the lowest ID would be on top

jimt2000
19.05.2016, 17:03
That did it for me. Thanks so much!