HERE Maps Distance to Destination 总是返回高值
Posted
技术标签:
【中文标题】HERE Maps Distance to Destination 总是返回高值【英文标题】:HERE Maps Distance to Destination always returns high Value 【发布时间】:2016-01-09 10:09:41 【问题描述】:我在此处的地图中计算了一条路线,并使用该路线开始了逐向导航。离线时一切正常,当我尝试使用
计算到达目的地的距离时double distance = [NMANavigationManager sharedNavigationManager].distanceToDestination;
上述方法返回的值非常高,例如184467440737095520000。即使对于不同的路由,返回值总是184467440737095520000。当我提到导航管理器委托时,我发现此方法将返回以米为单位的值。但是即使这个返回值也太高了我的目的地距离..请指导我如何正确计算到我的目的地的距离..提前谢谢
-(void)CalculateRoute:(NMARoutingMode *)routingMode
routeManager = [NMARouteManager sharedRouteManager];
routeManager.delegate = self;
NSMutableArray* stopList = [NSMutableArray array];
[stopList addObject:_StartCoordinate];
[stopList addObject:_DestinationCoordinate];
NSLog(@"routing from [%.5f,%.5f] to [%.5f,%.5f]", ((NMAGeoCoordinates*)stopList[0]).latitude, ((NMAGeoCoordinates*)stopList[0]).longitude,
((NMAGeoCoordinates*)stopList[1]).latitude, ((NMAGeoCoordinates*)stopList[1]).longitude);
NSLog(@"routingMode===>%@",routingMode.description);
[routeManager calculateRouteWithStops:stopList routingMode:routingMode];
-(IBAction)StartNav:(UIButton*)sender
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(positionDidUpdate)
name:NMAPositioningManagerDidUpdatePositionNotification
object:[NMAPositioningManager sharedPositioningManager]];
[NMANavigationManager sharedNavigationManager].map = self.mapView;
[NMANavigationManager sharedNavigationManager].delegate = self;
[NMANavigationManager sharedNavigationManager].mapTrackingAutoZoomEnabled = YES;
[NMANavigationManager sharedNavigationManager].mapTrackingEnabled = YES;
[NMANavigationManager sharedNavigationManager].mapTrackingOrientation = NMAMapTrackingOrientationDynamic;
[NMANavigationManager sharedNavigationManager].speedWarningEnabled = YES;
[NMANavigationManager sharedNavigationManager].mapTrackingTilt = NMAMapTrackingTilt2D;
[[NMANavigationManager sharedNavigationManager]startTurnByTurnNavigationWithRoute:_route];
【问题讨论】:
【参考方案1】:计算距离时出错。值 184467440737095520000 等于 NMANavigationManagerInvalidValue 常量。
尝试在您的位置更新时计算距离,因此请在您提到的 positionDidUpdate 方法中执行此操作:
double distance = [NMANavigationManager sharedNavigationManager].distanceToDestination;
如果你想在调用startTurnByTurnNavigationWithRoute方法后第一次这样做,你应该从路由中得到这样的信息:
double distance = _route.length;
顺便说一句,如果你尝试对 timeToArrival 做同样的事情,你也会得到一个很高的价值。
【讨论】:
【参考方案2】:distanceToDestination
是不是 double
值。它是一个unsigned long long
值或NMAUint64
值。
执行以下操作:
unsigned long long distance = [NMANavigationManager sharedNavigationManager].distanceToDestination;
或
NMAUint64 distance = [NMANavigationManager sharedNavigationManager].distanceToDestination;
【讨论】:
以上是关于HERE Maps Distance to Destination 总是返回高值的主要内容,如果未能解决你的问题,请参考以下文章
使用pincode计算距离(Google map Distance Matrix API)
如何使用 HTTPS 调用 HERE Maps API v3
在 NodeJS 项目中放置 Google Maps API 密钥的位置