【问题标题】:Skobbler Annotation disappears (moves) when it is the starting point of a route当 Skobbler 注释是路线的起点时,它会消失(移动)
【发布时间】:2015-11-14 09:54:48
【问题描述】:

我正在使用 Skobbler ios SDK。

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

当我点击注释时,应用会显示注释的标注。如果我仔细点击终点注释后面的注释,路线开头的第一个注释的标注会出现在其原始起点位置。路线开头的注释不正确(在我看来)移动到路线末尾的注释后面,但它的标注仍然在路线开头的正确位置。

为什么第一个注释会移动,我怎样才能让它保持在原来的位置。

谢谢!

编辑: iOS 9,斯威夫特。

其非常通用的代码取自http://developer.skobbler.com/getting-started/的 sn-ps

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)
}

【问题讨论】:

  • 请添加您用于将注释添加到此问题的代码(包括您用于注释的 ID)。你会调用 updateAnnotation 吗?
  • 这是安卓问题还是iOS问题?
  • 已编辑:添加代码。使用 xcode 7.1,iOS 9
  • 遇到了类似的问题,发到了skobbler论坛。我确实有一个解决方法,在论坛中提到。到目前为止,Skobbler 似乎没有真正的解决方案。 forum.skobbler.com/showthread.php/…
  • 我在寻找解决方案时在 Skobbler 论坛上看到了您的帖子。我们正在评估使用 Skobbler 进行大型部署。它似乎非常符合我们的需要,但我有点失望在这里没有听到任何消息,或者在我在 Skobbler 论坛上的帖子。 (forum.skobbler.com/showthread.php/…)。

标签: ios ios9 skmaps


【解决方案1】:

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

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

为了解决我的问题,我只是确保我创建的任何注释的 id 都不小于10,这就为我解决了这个问题。

如此变化 annotation.identifier = Int32(annotations.count)annotation.identifier = Int32(annotations.count + SKOBBLER_ANNOTATION_OFFSET) 之类的东西,其中 SKOBBLER_ANNOTATION_OFFSET10 或更大的值可能对您有用。

希望对你有帮助,谢谢!

编辑:实际上,我现在记得发现这一点的功劳归功于在原始问题中看到@guido 的评论,所以感谢您在正确方向上的指示!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-16
    • 2020-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多