The main component responsible for navigation in Navmii SDK is NMNavigationSevice. You can access an instance of this class via NMSdk' navigationService property:
Code Block | ||||
---|---|---|---|---|
| ||||
NMNavigationService *navigationService = [NMSdk sharedInstance].navigationService; |
Navmii SDK generates various navigation events. To be able to handle these events make one of your classes conform to NMNavigationServiceListener protocol and add an instance of this class to NMNavigationService listeners via addNavigationServiceListener: method:
Code Block | ||||
---|---|---|---|---|
| ||||
[NMSdk sharedInstance.navigationService addNavigationServiceListener:yourListener]; |
You also can add multiple listeners to NMNavigationService instance.
These navigation events are:
- change of GPS status
- change of iOS location services authorization status
- change of current position
- update of navigation information (see Navigation Info section)
- change of country of current location
- update of guidance info (see Guidance (v2))
- passing a waypoint
- reaching the destination
- demo route start
- demo route stop
POSITIONING OPTIONS
You can set up the location detection accuracy in meters via locationDetectionAccuracy property. To retrieve user defined CLAuthorizationStatus use locationServicesAuthorizationStatus readonly property. You The onLocationServicesAuthorizationChanged: method will be called when this status changes. You can allow or disallow location updates when your app is in background mode via allowsBackgroundLocationUpdates BOOL property.
Code Block | ||||
---|---|---|---|---|
| ||||
//sets location detection accuracy to 20 meters
[[NMSdk sharedInstance].navigationService setLocationDetectionAccuracy:20];
//allows user's location updates in the background mode
[[NMSdk sharedInstance].navigationService setAllowsBackgroundLocationUpdates:YES];
|
Code Block | ||||
---|---|---|---|---|
| ||||
//logs out location services authorization status on change - (void)onLocationServicesAuthorizationStatusChanged:(CLAuthorizationStatus)status { NSLog(@"authorization status - %d", status); } |
When the authorization status is not determined you can prompt the user to allow/disallow location updates throughout requestAlwaysAuthorization and requestWhenInUseAuthorization methods:
Code Block | ||||
---|---|---|---|---|
| ||||
[[NMSdk sharedInstance].navigationService.locationServicesAuthorizationStatus); |
requestAlwaysAuthorization];
//or, alternatively
[[NMSdk sharedInstance].navigationService requestWhenInUseAuthorization]; |
There is also the gpsStatus property indicating if the SDK accepts GPS signal. GPS status is represented as NMGpsStatus enum
takingof the following values:
- NMGpsStatusOK
- NMGpsStatusNoSignal
- NMGpsStatusOff
The onGPSStatusChange: event in NMNavigationServiceListener protocol will bee triggered when the status changes:
Code Block | ||||
---|---|---|---|---|
| ||||
//logs out a message if GPS signal is received by the SDK if (- (void)onGpsStatusChange:(NMGpsStatus)status { NSLog(@"GPS status has changed to %d", (int)status); } |
RETRIEVING CURRENT POSITION
The user's current position can be retrieved via NMNavigationService's currentPosition readonly property.
Code Block | ||||
---|---|---|---|---|
| ||||
//logs out the user's current position NMMapCoordinates *currentPosition = [NMSdk sharedInstance].navigationService.gpsStatus == NMGpsStatusOK) { currentPosition; NSLog(@"GPS signal is received"); }You are at coordinates: %f lat. %f lon.", currentPosition.latitude, currentPosition.longitude); |
DEMO ROUTE
Navmii SDK allows you to demonstrate the way the real-time traverse of the route will look like on the screen. When the route is calculated, use startDemoRoute and stopDemoRoute methods. Use isDemoRouteActive BOOL property to find out if the demo route is still in progress.
Code Block | ||||
---|---|---|---|---|
| ||||
//starts demo route [[NMSdk sharedInstance].navigationService startDemoRoute]; //stops demo route [[NMSdk sharedInstance].navigationService stopDemoRoute]; |