Nutiteq is now part of CARTO! Please use latest CARTO Mobile SDK 4.x for new projects, Nutiteq SDK 3.x support and updates will end in 2017

iOS Get Started

1. Create new project with Nutiteq SDK framework

Create new project in Xcode, add SDK framework (binary and headers) and assets to it, and make sure that builder will find new framework .h files. Also add dependencies: GLKit and libz.

  1. Create a new Xcode project. ‘File’ -> ‘New’ -> ‘Project’ -> ‘Single View application’.
  2. Suggested: Create Podfile with dependency ‘Nutiteq’ , install the Pods and open Workspace file.
  3. (Alternative: Copy Nuti.framework and nutibright.zip to the project root directory. You get these files from Downloads . Then add dependencies: GLkit.framework and libz frameworks (Build Phases > Link Binary with Libraries))

2. Modify Controller for Map View

Extend ViewController and add MapView manipulation code into it. Make sure it is Objective C++, not plain Objective C class

  1. Rename ‘ViewController.m’ (comes with template) to ‘ViewController.mm’ to avoid compilation issues
  2. Make ViewController.h to extend GLKViewController instead of UIViewController
  3. Replace YOUR_LICENSE_KEY with your license key in code below. You have to be registered here (free Lite plan is fine), and get the code from My apps page.
#import <UIKit/UIKit.h>

@interface ViewController : GLKViewController

@end

and implementation ViewController.mm :


#import "ViewController.h"
#import <Nuti/Nuti.h>
 
@implementation ViewController

- (void)loadView {
  // The initial step: register your license. 
  // This must be done before using MapView
  [NTMapView registerLicense:@"YOUR_LICENSE_KEY"];
  [super loadView];
}


- (void)viewDidLoad
{

 [super viewDidLoad];
  // minimal map definition code 

  // The storyboard has NTMapView connected as a view
  NTMapView* mapView = (NTMapView*) self.view;

  // Create online vector tile layer, use style asset embedded in the project
  NTVectorTileLayer* vectorTileLayer = [[NTNutiteqOnlineVectorTileLayer alloc] initWithSource: @"nutiteq.osm" styleAssetName:@"nutibright.zip"];
 
  // Add vector tile layer
  [[mapView getLayers] add:vectorTileLayer];
    

@end

2. Modify storyboard to enable Map View

Default storyboard template uses UIView class, we need NTMapView here instead.

  1. Repeat next step with both Main_iPhone.storyboard and Main_iPad.storyboard files, if you have both
  2. Open Main.Storyboard, find View Controller Scene -> View Controller and View. From Navigator window find Identity Inspector, and change the first parameter (Custom Class) to NTMapView (from the default UIView).

3. Run the app

Run the app – you should see the map with OpenStreetMap, as defined in your ViewController. It is zoomable, rotatable and tilt-able out of the box, with the default world view.

4. View manipulations

Manipulating the map view goes via MapView object methods:

  // Set the base projection, that will be used for most MapView, MapEventListener and Options methods
  NTEPSG3857* proj = [[NTEPSG3857 alloc] init];
  [[mapView getOptions] setBaseProjection:proj]; // EPSG3857 is actually the default base projection, so this is actually not needed
    
  // General options
  [[mapView getOptions] setRotatable:YES]; // make map rotatable (this is actually the default)
  [[mapView getOptions] setTileThreadPoolSize:2]; // use 2 threads to download tiles
    
  // Set initial location and other parameters, don't animate
  [mapView setFocusPos:[proj fromWgs84:[[NTMapPos alloc] initWithX:24.650415 y:59.428773]]  durationSeconds:0];
  [mapView setZoom:14 durationSeconds:0];
  [mapView setRotation:0 durationSeconds:0];

Next get our ready-made demo apps with many advanced examples.