View Full Version : Routing between 2 annotations moves 1st annotation to location of 2nd Annotation

26.10.2015, 16:32
I'm using the Skobbler iOS SDK with Swift, iOS 9, xCode 7.0.1

I add two annotations to my map view. Then I route between these two points. The routing succeeds, but the annotation (a pin) for the starting point disappears -- Actually the first annotations moves behind the second annotation (the ending point of the route). If I look carefully at the second annotation (also a pin) at the end of the route, I can see that there is another annotation behind it.

Why is the first annotation moving, and how can I keep it at its original position.



Here is the code used to create the annotations and routing.

func mapView(mapView: SKMapView, didLongTapAtCoordinate coordinate: CLLocationCoordinate2D) {

let annotation = ABPAnnotation()
annotation.identifier = Int32(annotations.count)
annotation.annotationType = SKAnnotationType.Red
annotation.location = coordinate
let animationSettings = SKAnimationSettings()
mapView.addAnnotation(annotation, withAnimationSettings: animationSettings)
self.mapView(mapView, didSelectAnnotation: annotation)

func mapView(mapView:SKMapView!, didSelectAnnotation annotation:SKAnnotation!) {
mapView.calloutView.location = annotation.location
mapView.calloutView.titleLabel.text = "Annotation"
mapView.calloutView.subtitleLabel.text = "subtitle"
mapView.showCalloutForAnnotation(annotation, withOffset: CGPointMake(0, 42), animated: false);

@IBAction func routeAction(sender: AnyObject) {
let route = SKRouteSettings()
route.startCoordinate = annotations[0].location
route.destinationCoordinate = annotations[1].location
route.shouldBeRendered = true
route.routeMode = SKRouteMode.CarEfficient
route.maximumReturnedRoutes = 1
route.routeRestrictions.avoidHighways = false
route.requestAdvices = true
SKRoutingService.sharedInstance().calculateRoute(r oute)

func routingService(routingService: SKRoutingService!, didFinishRouteCalculationWithInfo routeInformation: SKRouteInformation!) {
routingService.zoomToRouteWithInsets(UIEdgeInsetsZ ero, duration: 400)

30.10.2015, 23:49
This is a similar problem to my problem (http://forum.skobbler.com/showthread.php/7079-iOS-Annotation-moves-when-zooming-in) . Looking forward to a solution.

31.10.2015, 06:06
Skobbler? Does anyone monitor this forum?

02.11.2015, 14:40
Hi Jimt2000,

We confirm that this issue is on our developers' list. We'll update this thread as soon as we have an answer.

02.11.2015, 16:56
Thank you.

05.11.2015, 05:20
Does one of your annotations have the identifier 0 by any chance?
By dumb luck I found out that, in my case, this mysterious behaviour occurs for the annotation with identifier 0 (zero). If I change the identifier to 1 for example the mysterious behaviour is gone (in my case).
My guess is, but perhaps you (Adela) can confirm, is that somehow the 0 identifier is reserved for the current location (indicator).

05.11.2015, 17:32
In my code, I find just the opposite.
If I have two annotations with identifiers of 0, and 1. I do NOT get the problem.
If I have two annotations with identifiers of 1 and 2, I DO get the problem.

05.11.2015, 17:45
Hmmm...very strange. Well, at least we know now it has something to do with the identifiers. I'm working on updating my full code on this today. Let you know if I find anything else. Perhaps also the Skobbler guys can shed some light on this, now that they have this new info?

06.11.2015, 19:33
Our developers are investigating the problem but to be on the safe side of things, switch to using annotation ids > 10.

At some point in time the ID 0 was used for the destination flag annotation - we're looking now at the code base to see what is the current implementation.

06.11.2015, 19:47
Thanks. I'm not seeing the problem when using IDs > 10.