iOS

iOS

NaoMapSdkFramework provides easy-to-use and powerful NAO Map library iOS. The classes are described below.

 

Installation

use_frameworks! # Add this if you are targeting iOS 11+
platform :ios, '11.0'
install! 'cocoapods', :deterministic_uuids => false
use_modular_headers!
inhibit_all_warnings!

pod 'NaoMapSdkFramework'  

Importing

#import <NaoMapSdkFramework/NaoMapSDK.h>

Create the map view

  1. Add a mapviewManager property to the ViewController class:
    @interface ViewController: UIViewController<NaoMapViewListener>
    @property (nonatomic) NaoMapViewManager *mapViewManager;
    @end

    The NaoMapViewManager class is defined in the NaoMapSdkFramework iOS SDK. It represents an NaoMapSdkFramework map view and includes methods for interacting with the map view manager. It implements NaoMapViewListener protocols which are used to handle events related to the map view.

  2. Instantiate the NaoMapViewManager object in viewDidLoad
    (void)viewDidLoad {
        [super viewDidLoad];
        // 1. Create and initialize the map view manager instance
        self.mapViewManager = [[NaoMapViewManager alloc] initWithListener:(id)self];
    }
  3. Call [self.mapViewManager load:apiKey]  method which load the site associated with the given apiKey. The method [self.mapViewManager load:apiKey] takes one parameter: Your NAOSDK API key. It returns the progress bar view that shows the site loading progress.
        // 2. Load the site with the corresponding url and apikey
        UIViewController* vc =[self.mapViewManager load:apiKey];
    
        [vc setModalPresentationStyle: UIModalPresentationFullScreen];
        [self.navigationController pushViewController:vc animated:YES];
        [self presentViewController:vc animated:YES completion:nil];
  4. Copy the following code which implements methods of the NaoMapViewListener protocol.
#pragma mark - MapViewListener callbacks

- (void)didLoadSiteFail:(BOOL)state withMessage:(nonnull NSString *)message {
    if (state)
      NSLog(@"The required site has been successfully loaded");
    else
      NSLog(@"The client failed to load the site: (%@)", message);
}

- (void)didFinishLoadingWithSuccess {
    [self dismissViewControllerAnimated:NO completion:NULL];
    // 3. Get and show the map view
    UIViewController* vc = [self.mapViewManager getView];
    [vc setModalPresentationStyle: UIModalPresentationFullScreen];
    [self.navigationController pushViewController:vc animated:YES];
    [self presentViewController:vc animated:YES completion:nil];
}

didLoadSiteFail callback will indicate the site loading state. Success if the site has been successfully load and fail otherwise. onMapLayerChange will only called if the load has been successful. In this cas, the client-side, can UIViewController* vc = [self.mapViewManager getView] to get the map view.

Adding the POI

You can add one or more POI (point of interest) using one of the following methods: (void)setPOI:(nonnull NSData *)poi and (void)setPOIs:(nonnull NSData *)pois . Both methods take a NSData as argument. A single POI should has the following format:

{
  "type": "object",
  "properties": {
    "location": {
      "type": "object",
      "properties": {
        "longitude": {
          "type": "number"
        },
        "latitude": {
          "type": "number"
        },
        "altitude": {
          "type": "number"
        }
      },
      "required": [
        "longitude",
        "latitude",
        "altitude"
      ]
    },
    "icon": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "category": {
      "type": "string"
    },
    "metadata": {
      "type": "object",
      "properties": {},
      "required": []
    }
  },
  "required": [
    "location",
    "icon",
    "name",
    "category",
    "metadata"
  ]
}

This is an example of adding a POI

link for icon : https://fontawesome.com/search?q=thermo&o=r

Add unicode as a string icon.

    NSDictionary *dictionaryOrArray = @{
        @"location": @{
            @"longitude":@1.38735654451718,
            @"latitude":@43.5642422862191,
            @"altitude":@10.0
        },
        @"icon": @"f491",
        @"name": @"thermometer",
        @"category": @"TOOLS",
        @"metadata": @{}
        
};
    NSError *error;
    // Convert the json data into the NSData
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionaryOrArray
                                                       options:NSJSONWritingPrettyPrinted
                                                         error:&error];
    [self.mapViewManager setPOI:jsonData];

The metadata field is used to add the meta information which is displayed while you click on the POI icon. It is not mandatory and can be left empty dictionary.

if you want to add more POIs, you should provide the POIs in array format to (void)setPOIs:(nonnull NSData *)pois, like that:

[
    {
        "location":{
            "longitude":1.3872800433604597,
            "latitude":43.56435614021779,
            "altitude":10.0
        },
        "icon": "medical.thermometer",
        "name": "Thermometer",
        "category": "TOOLS",
        "metadata":{
            "Name":   "High Frequency X-ray Machine",
            "Classification": "Imaging Diagnostic Equipment",
            "Type":   "X Ray Equipment"
        }
        
    },
    {
        "location":{
            "longitude":1.387164,
            "latitude":43.564311,
            "altitude":5.0
        },
        "icon": "syringe.fill",
        "name": "Syringe",
        "category": "TOOLS",
        "metadata":{
            "Name": "Autoclave",
            "Type":   "Pressure Steam Sterilization Equipments",
            "Certification":  "CE, ISO13485",
            "Electric Tension":  "380V",
            "LCD Display":    "With LCD Display",
            "Ultra High Temperature Alarm":   "Ultra High Temperature Alarm"
        }
    }
]

Sample application

Your may find here the sample application.

    • Related Articles

    • iOS 15

      Intro iOS 15 has been released on September 15th (2021). It doesn’t need any additional permissions, the previous recommendations for the iOS 14 remain valid. However, two new features or enhancements about the location permissions and notifications ...
    • iOS 13

      NAOSDK remains compatible with iOS13. iOS 13 brings some changes to existing permissions. If your app only uses NAO SDK while the app is in the foreground, you don’t have to change anything (The Foreground operation is exactly the same as iOS12); ...
    • iOS 11

      iOS 11 brings some changes to existing APIs. If your app only uses NAO SDK while the app is in the foreground, you do not have to change anything; however, if your app uses NAO SDK when it is in background, you need to make some changes. In iOS 10 ...
    • iOS 14

      Summary NAOSDK remains compatible with iOS14. Permission Changes On iOS 13, the user had the option of deciding whether the app should have access to its location once, only when using the app, or always. On iOS 14, the user can décide whether the ...
    • Release 22.06 (NAO SDK 4.11.7.8 / Hot Fix iOS 4.11.7.9)

      Versions Component Version Hotfix NAO® Cloud 22.06 NAO® SDK iOS 4.11.7.8 4.11.7.9 NAO® SDK Android 4.11.7.8 NAO® Logger iOS 4.11.7.8 NAO® Logger Android 4.11.7.8 New Features NAO® Cloud Nao track web app is now available Nao track web app crash ...