在初始化地图之后,我向某个坐标添加了一个注释。
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)
}在我这样做之后,注释就放置在正确的坐标上。但是,在我计算完路由之后,同样的注释就会被重画到路由开始坐标。
这是我用来计算路线的代码(我在初始化地图和添加注释后立即调用它)
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)
}那么,为什么在计算路由之后,该注释被重画到另一个坐标(总是路由的开始)?
发布于 2016-02-26 12:53:01
将注释的ID设置为> 10。
出于某种原因,SDK使用内部0和1个ID作为起始和结束目标标志,我猜,如果没有为注释分配特定的ID,它就会自动接收其中一个受保护的ID。
注意:我知道这已经在Android版本中得到了解决-我们将在iOS版本中检查。
https://stackoverflow.com/questions/35630455
复制相似问题