HERE iOS SDK Developer's Guide

Maps

The core feature of the HERE iOS SDK is Mapping. The key concepts covered in this section include adding a map to an iOS application, changing the location displayed by the map, and modifying its properties. The primary component of the mapping API is the NMAMapView, which is integrated with the Cocoa Touch framework as a UIView subclass. NMAMapView represents the view to display map and various properties. The NMAMapView is derived from UIView and part of iOS Cocoa Touch framework.

Note: To create a simple map application, refer to the Quick Start section.

The first step to integrate a map into an application is to insert a NMAMapView to your view controller's .xib file or the storyboard of the application using the Interface Builder. Alternatively, you can also add NMAMapView to your view controller programmatically as follows:

- (void)viewDidLoad
{
  mapView = [[NMAMapView alloc] initWithFrame:self.view.frame];
  [self.view addSubview:mapView];
}

The NMAMapView class handles all user interactions in the form of touch gestures. More details about the supported gesture types can be found in the Map Gestures section.

Working with NMAMapView

Once the NMAMapView is initialized, it can be manipulated and interacted in a variety of ways. Some key attributes of the NMAMapView are its geographical center (geoCenter) and zoom level (zoomLevel). These properties may be used to customize the NMAMapView display. For example, the following code demonstrates how to show a view of Vancouver, Canada.

NMAGeoCoordinates *geoCoordCenter = [[NMAGeoCoordinates alloc]
  initWithLatitude:49.260327 longitude:-123.115025];
[self.mapView setGeoCenter:geoCoordCenter withAnimation:NMAMapAnimationNone];
In the preceding code:
  • The geographical location [NMAGeoCoordinates] for the new map center is created by a call to the -(id)initWithLatitude:(double)aLatitude longitude:(double)aLongitude method.
  • When setting the center of a map, the transition can be animated by passing the NMAMapAnimationLinear enum value to the animation parameter. Animation can also be suppressed by using the NMAMapAnimationNone value.

The beginning and ending of these events may be observed by assigning an object to the NMAMapView's delegate property. The object should implement the methods of the NMAMapViewDelegate protocol corresponding to the events you wish it to receive. This delegate can also be used to detect map object selection.

Note: For optimum performance, avoid resizing a map after it has been created. If resizing is necessary, create the map at the largest size to be used and reduce it later.

Resolution and Text Size

By default, the HERE SDK uses high-resolution (512 x 512 pixels) map tiles. You can set the useHighResolutionMap property in NMAMapView to NO to use lower-resolution (256 x 256 pixels) map tiles instead.

You can also use the mapPPI property to change the map's pixel-per-inch setting. The default setting is NMAMapPPILow. Setting the property to NMAMapPPIHigh makes street labels and other text to be bigger.

Properties of NMAMapView

The following examples show how to work with some of the properties in NMAMapView:

Map Center

The center of the map determines the geographical area to be displayed. It can be read using the NMAMapView geoCenter property, and set using one of the setGeoCenter: methods. Its type is NMAGeoCoordinates.

// Move the map to London.
NMAGeoCoordinates *geoCoordCenter = [[NMAGeoCoordinates alloc]
initWithLatitude:51.51 longitude:-0.11];
[self.mapView setGeoCenter:geoCoordCenter withAnimation:NMAMapAnimationNone];

Zoom Level

The size of the geographical area displayed by the map can be controlled by changing the zoom level. The zoom level ranges from NMAMapViewMinimumZoomLevel to NMAMapViewMaximumZoomLevel, with a higher zoom value being closer to the ground. The following code sets the zoom level to the median zoom level:

// Set the zoom level to the median.
mapView.zoomLevel =
(NMAMapViewMinimumZoomLevel + NMAMapViewMaximumZoomLevel)/2.0f;

Animations

The NMAMapView supports the following animation settings to be used while changing properties, defined by the NMAMapAnimation enum:

  • NMAMapAnimationNone
  • NMAMapAnimationLinear
// Move to London using bow animation
NMAGeoCoordinates *geoCoordCenter = [[NMAGeoCoordinates alloc]
    initWithLatitude:51.51 longitude:-0.11];
[mapView setGeoCenter:geoCoordCenter withAnimation:NMAMapAnimationLinear];

Setting Multiple Attributes

An extended API is provided to change one or more attributes at the same time.

-(void) setGeoCenter:(NMAGeoCoordinates*) coordinates
           zoomLevel:(float) level
         withAnimation:(NMAMapAnimation) animation

To leave a map attribute unchanged, pass the NMAMapViewPreserveValue constant to the relevant method parameter.

// Move to Vancouver, preserving zoom level
NMAGeoCoordinates* coord = [[NMAGeoCoordinates alloc]
  initWithLatitude:49.0
  longitude:123.0];
[mapView setGeoCenter:coord
  zoomLevel:NMAMapViewPreserveValue
  withAnimation:NMAMapAnimationNone];

For more information about the APIs introduced and demonstrated in this section, refer to the API Reference documentation.

You cannot use this account to purchase a commercial plan on Developer Portal, as it is already associated to plans with different payment methods.

To purchase a commercial plan on Developer Portal, please register for or sign in with a different HERE Account.

Something took longer than expected.

The project should be available soon under your projects page.

Sorry, our services are not available in this region.

Something seems to have gone wrong. Please try again later.

We've detected that your account is set to Australian Dollars (AUD).
Unfortunately, we do not offer checkouts in AUD anymore.
You can continue using your current plan as normal, but to subscribe to one of our new plans,
please register for a new HERE account or contact us for billing questions on selfservesupport@here.com.