这里映射Swift SDK计算路径始终错误

时间:2017-01-12 11:00:31

标签: here-api here-ios

我在Xcode 8.2,Swift 3上使用Here Maps的iOS版Premium SDK。目前,我可以显示地图,找到我当前的位置,并将地图置于我当前的位置。

但是,当我尝试使用NMACoreRouter计算路由时,它总是返回错误。以下是我的代码的一部分:

private var nma_core_router: NMACoreRouter!

...

nam_core_router = NMACoreRouter.init()

...

let geo1 = NMAGeoCoordinates(latitude: lat1, longitude: lng1)
let geo2 = NMAGeoCoordinates(latitude: lat2, longitude: lng2)

let pt1 = NMAWaypoint(geoCoordinates: geo1!)
let pt2 = NMAWaypoint(geoCoordinates: geo2!, waypointType: NMAWaypointType.stopWaypoint)

let stops = [pt1!, pt2!]

let mode = NMARoutingMode(routingType: NMARoutingType.shortest, transportMode: NMATransportMode.bike, routingOptions: 0)

nma_core_router.calculateRoute(withStops: stops, routingMode: mode!) {
            (routeResult: NMARouteResult?, error: NMARoutingError?) in

   if error == nil {
       // handle routing results
   } else {
       //====> always here, no matter how accurate the coordinates were
   }
}

错误总是出现并且有NMARoutingError

有人可以告诉我,我做错了什么吗?

1 个答案:

答案 0 :(得分:1)

由于: https://developer.here.com/mobile-sdks/documentation/ios-hybrid-plus/topics_api_nlp_hybrid_plus/group--nma--route.html#topic-apiref__nmaroutingtype路由类型“最短”仅支持汽车。由于您尝试计算自行车路线,请使用“最快”路由类型。