Reputation: 580
I'm using the Skobbler ios SDK.
I add two annotations to my map view. Then I route between these two points. The routing succeeds, but the annotation (pin) for the first point, the starting point disappears -- Actually the first annotations moves behind the second annotation. If I look carefully at the second annotation (pins) at the end of the route, I can see that there is another annotation behind it.
The app shows an annotation's callout when I tap the annotation. If I carefully tap the annotation behind the the end point annotation, the callout for the first annotation at the beginning of the route appears in its original starting point location. The annotation at the beginning of the route has improperly (so it seems to me) moved behind the annotation at the end of the route, but its callout remains at the correct position at the beginning of the route.
Why is the first annotation moving, and how can I keep it at its original position.
Thanks!
EDIT: iOS 9, Swift.
Its pretty generic code taken from snippets at http://developer.skobbler.com/getting-started/
func mapView(mapView: SKMapView, didLongTapAtCoordinate coordinate: CLLocationCoordinate2D) {
let annotation = ABPAnnotation()
annotations.append(annotation)
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(route)
}
func routingService(routingService: SKRoutingService!,
didFinishRouteCalculationWithInfo routeInformation: SKRouteInformation!) {
routingService.zoomToRouteWithInsets(UIEdgeInsetsZero, duration: 400)
}
Upvotes: 3
Views: 423
Reputation: 811
As mentioned in my comment above, I was also experiencing this issue when using the Android Skobbler SDK (versions 2.5 and 2.5.1) but was able to find a workaround from these two forum posts: #1 and #2.
Basically, it seems that users have issues adding annotations that have an id of 0
or 1
which I could replicate in my own code as well.
To solve it in my case, I simply made sure that any annotation I created didn't have an id less than 10
and that fixed the issue for me.
So changing
annotation.identifier = Int32(annotations.count)
to something like annotation.identifier = Int32(annotations.count + SKOBBLER_ANNOTATION_OFFSET)
where SKOBBLER_ANNOTATION_OFFSET
is a value of 10
or greater might work for you.
Hope that helps, thanks!
Edit: Actually, I remembered now that credit for discovering this goes to seeing @guido's comment in the original question, so thank you for the pointer in the right direction there!
Upvotes: 1