gpt4 book ai didi

ios - HERE map 到目的地的距离始终返回高值

转载 作者:行者123 更新时间:2023-11-29 01:20:22 26 4
gpt4 key购买 nike

我在此处的 map 中计算了一条路线,并使用该路线开始了 Turn-by-Turn Navigation。离线时一切正常,当我尝试使用

计算到达目的地的距离时
double distance = [NMANavigationManager sharedNavigationManager].distanceToDestination; 

上面的方法返回值很高,比如184467440737095520000。即使是不同的路由,返回值也总是184467440737095520000。当我引用导航管理器委托(delegate)时,我发现此方法将返回以米为单位的值。但即使这个返回值也比我的目的地距离高。请指导我如何正确计算到目的地的距离。提前致谢

-(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];
}

最佳答案

计算距离时出现错误。值 184467440737095520000 等于 NMANavigationManagerInvalidValue 常量。

当您的位置更新时尝试计算距离,所以在您提到的 positionDidUpdate 方法中执行此操作:

double distance = [NMANavigationManager sharedNavigationManager].distanceToDestination;

如果您想在调用 startTurnByTurnNavigationWithRoute 方法后第一次执行此操作,您应该从 route 获取此类信息:

double distance = _route.length;

顺便说一句,如果你尝试对 timeToArrival 做同样的事情,你也会得到一个很高的值。

关于ios - HERE map 到目的地的距离始终返回高值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34692147/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com