Reputation: 597
I had calculated a route in here maps and started Turn-by-Turn Navigation using that route. Everything is working fine in offline and when i tried to calculate the distance to reach the destination using
double distance = [NMANavigationManager sharedNavigationManager].distanceToDestination;
The above method returned value which is very high such as 184467440737095520000. The returned value is always 184467440737095520000 even for different routes. when i referred the navigation manager delegate i found that this method will return values in metres. But even this returned value is too high of my destination's distance..Please guide me how to calculate the distance to my destination correctly.. thanks in advance
-(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];
}
Upvotes: 0
Views: 713
Reputation: 1019
You're getting an error when computing the distance. The value 184467440737095520000 is equal to the NMANavigationManagerInvalidValue constant.
Try to compute the distance when your position is updated, so do it in your positionDidUpdate method as you mentioned:
double distance = [NMANavigationManager sharedNavigationManager].distanceToDestination;
If you would like to do it the first time after calling the startTurnByTurnNavigationWithRoute method, you should get such information from the route:
double distance = _route.length;
Btw, if you try to do the same with the timeToArrival, you will get a high value too.
Upvotes: 2
Reputation: 5343
distanceToDestination
is not a double
value. It is an unsigned long long
value or NMAUint64
value.
Do following:
unsigned long long distance = [NMANavigationManager sharedNavigationManager].distanceToDestination;
or
NMAUint64 distance = [NMANavigationManager sharedNavigationManager].distanceToDestination;
Upvotes: -1