首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在计算路由后,绘制的注释移动到用户的位置- Skobbler

在计算路由后,绘制的注释移动到用户的位置- Skobbler
EN

Stack Overflow用户
提问于 2016-02-25 14:44:35
回答 1查看 119关注 0票数 1

在初始化地图之后,我向某个坐标添加了一个注释。

代码语言:javascript
复制
func initMap(){

    SKRoutingService.sharedInstance().navigationDelegate = self
    SKRoutingService.sharedInstance().routingDelegate = self
    SKRoutingService.sharedInstance().mapView = self.mapView
    SKRoutingService.sharedInstance().mapView?.delegate = self
    SKRoutingService.sharedInstance().mapView?.centerOnCurrentPosition()
    SKRoutingService.sharedInstance().mapView?.animateToZoomLevel(16)
    SKRoutingService.sharedInstance().mapView?.settings.showAccuracyCircle = false
    SKRoutingService.sharedInstance().mapView?.settings.showStreetNamePopUps = true
    SKRoutingService.sharedInstance().mapView?.mapScaleView.hidden = true

    setCheckpointAnnotation()


}


    func setCheckpointAnnotation(){

    let annotationViewHolder = UIView(frame: CGRectMake(0,0,40,80))
    let annotationImageView = UIImageView(frame: CGRectMake(0,0,40,80))

    annotationImageView.image = UIImage(named: "HorseHead.png")
    annotationViewHolder.addSubview(annotationImageView)

    let annotation = SKAnnotation()
    annotation.location = self.checkpointLocation
    let annotationView = SKAnnotationView(view: annotationViewHolder, reuseIdentifier: "Annotation")
    annotation.annotationView = annotationView

    SKRoutingService.sharedInstance().mapView?.addAnnotation(annotation, withAnimationSettings: .None)
}

在我这样做之后,注释就放置在正确的坐标上。但是,在我计算完路由之后,同样的注释就会被重画到路由开始坐标。

这是我用来计算路线的代码(我在初始化地图和添加注释后立即调用它)

代码语言:javascript
复制
 func calculateRoute(){
    let route = SKRouteSettings()
    //var viaPointsArray = [SKViaPoint]()



    self.checkpoints.removeFirst()

    route.startCoordinate = self.userLocation
    route.destinationCoordinate = self.checkpointLocation

    //route.viaPoints = viaPointsArray

    route.shouldBeRendered = true // If false, the route will not be rendered.
    route.routeMode = SKRouteMode.Pedestrian

    route.maximumReturnedRoutes = 1
    route.routeRestrictions.avoidHighways = true

    SKRoutingService.sharedInstance().calculateRoute(route)
}

那么,为什么在计算路由之后,该注释被重画到另一个坐标(总是路由的开始)?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-26 12:53:01

将注释的ID设置为> 10。

出于某种原因,SDK使用内部0和1个ID作为起始和结束目标标志,我猜,如果没有为注释分配特定的ID,它就会自动接收其中一个受保护的ID。

注意:我知道这已经在Android版本中得到了解决-我们将在iOS版本中检查。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35630455

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档