NaoMapSdkFramework provides easy-to-use and powerful NAO Map library iOS. The classes are described below.
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'
#import <NaoMapSdkFramework/NaoMapSDK.h>
@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.
(void)viewDidLoad {
[super viewDidLoad];
// 1. Create and initialize the map view manager instance
self.mapViewManager = [[NaoMapViewManager alloc] initWithListener:(id)self];
}
// 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];
#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.
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"
}
}
]
Your may find here the sample application.