Working with the SDK
The key component of NavmiiSDK framework is NMSdk class. To initialize NMSdk and start map rendering, create an instance of NMSdk class and use startWithSettings:
method. This method takes NMConfigurationSettings as an argument. To deinitialize NMSdk use destroy
method. The pause
and resume
methods only start and stop map rendering respectively, without initializing/deinitializing the SDK.
To see code examples of initializing the SDK please refer to CREATING THE MAP VIEW section. NMConfigurationSettings are described in SDK CONFIGURATION SETTINGS.
Here's the most typical example of the last three methods usage:
//in AppDelegate.m - (void)applicationWillTerminate:(UIApplication *)application { [navmiiSdk destroy]; } - (void)applicationDidEnterBackground:(UIApplication *)application { [navmiiSdk pause]; } - (void)applicationDidBecomeActive:(UIApplication *)application { [navmiiSdk resume]; }
SDK CONFIGURATION SETTINGS
NMConfigurationSettings class represents the settings with which the SDK can be launched. If you have the resources designated to customize the map, you can specify the path to these resources using customResourcesPath
property. To enable map rendering in offline mode, specify the path to the folder with offline maps using offlineMapsPath
property. You can also specify the path to the folder where the SDK puts files created at runtime.
To create an NMConfigurationSettings instance use the instance or class method:
NMConfigurationSettings *settings = [[NMConfigurationSettings alloc] initWithCustomResourcesPath:customResourcesPath offlineMapsPath:offlineMapsPath innerFilesPath:innerFilesPath mapSchemeId:mapSchemeId]; //or alternatively NMConfigurationSettings *settings = [NMConfigurationSettings settingsWithCustomResourcesPath:customResourcesPath offlineMapsPath:offlineMapsPath innerFilesPath:innerFilesPath mapSchemeId:mapSchemeId];
SDK STATE
The NMSdk can have four possible states represented by NMSdkState enum:
- not initialized
- active
- paused
- destroyed
You can retrieve the SDK state through NMSdk's state
property.
The process of the SDK's initialization is asynchronious. To be informed on the initialization finish use NMSdkStateChangeListener protocol methods:
- (void)onSdkStarted { //handle initialization here } - (void)onSdkIsFailedToStart:(NSError *)error { //handle failure here }
Other useful NMSdkStateChangeListener protocol methods are:
- (void)onSdkPaused { //handle the SDK has been paused } - (void)onSdkResumed { //handle the SDK has been resumed } - (void)onSdkDestroyed { //handle the SDK has been destroyed }