当它是路线的起点时,Skobbler Annotation消失(移动)

时间:2015-10-22 19:46:00

标签: ios ios9 skmaps

我正在使用Skobbler ios SDK。

我在地图视图中添加了两个注释。然后我在这两点之间路由。路由成功,但第一个点的注释(引脚),起点消失 - 实际上第一个注释在第二个注释后面移动。如果我仔细查看路径末尾的第二个注释(引脚),我可以看到它背后有另一个注释。

当我点按注释时,应用会显示注释的标注。如果我仔细点击结束点注释后面的注释,则路径开头的第一个注释的标注将出现在其原始起点位置。路线开头的注释不正确(因此在我看来)在路线末端的注释后移动,但其标注仍保留在路线开头的正确位置。

为什么第一个注释会移动,如何将其保持在原始位置。

谢谢!

编辑: iOS 9,Swift。

它非常通用的代码来自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)
}

Pin starting pin moved behind ending pin

1 个答案:

答案 0 :(得分:1)

正如我在上面的评论中所提到的,在使用Android Skobbler SDK(版本2.5和2.5.1)时我也遇到了这个问题,但是能够从这两个论坛帖子中找到解决方法:#1和{ {3}}

基本上,用户似乎在添加ID为01的注释时遇到问题,我也可以在自己的代码中复制这些注释。

为了解决这个问题,我只是确保我创建的任何注释都没有小于10的ID,并为我解决了这个问题。

如此改变 annotation.identifier = Int32(annotations.count) annotation.identifier = Int32(annotations.count + SKOBBLER_ANNOTATION_OFFSET)之类SKOBBLER_ANNOTATION_OFFSET 10的值{{1}}或更高可能适合您。

希望有所帮助,谢谢!

编辑:实际上,我记得现在发现这个问题的归功于在原始问题中看到@ guido的评论,所以谢谢你指向正确的指针!

相关问题