HERE SDK for iOS (Starter Edition)

SDK for iOS Developer's Guide

Objects and Interaction

HERE SDK allows the addition of a variety of objects, each with a specific purpose, to a map view. The types of available object include map markers, routes, polylines, and overlays. These objects are described in more detail below.

NMAMapObject Class

NMAMapObject class provides a generic base class from which most types of specialized map object are inherited. Functionality common to all these object types is encapsulated in NMAMapObject. The following is a list of important properties and methods in NMAMapObject.

  • zIndex - determines the objects stacking order, which controls how the object is displayed on the map relative to other objects that may overlap it
  • visible - determines whether or not the object is drawn when the map is rendered
  • type - contains the type of map object such as marker, polyline, and route. For the full list see the NMAMapObject API reference
  • parent - the NMAMapContainer instance holding this object, if any
  • uniqueId - uniquely identifies the object for the duration of application launch
  • NMAMapObject serves as a base class to other map object types and should not be instantiated directly.
  • Any change in a map object visual appearance causes the entire map view to be redrawn since map objects are drawn as part of the map itself. For optimal performance map objects should not be frequently updated unless it is necessary.

NMAMapContainer class

Map containers are a special type of map object that can be used to group together other map objects of certain types. The types of objects allowed are NMAMapMarker, NMAMapCircle, NMAMapPolygon, and NMAMapPolyline. Containers provide a convenient way to control the stacking order and visibility of a large group of objects.

To use a map container, create one or more map objects and add them to the container using addMapObject method. To show the objects on a map, add the map container to the map with addMapObject method of NMAMapView.

Note: A container may also hold other instances of NMAMapContainer.

NMAMapCircle class

NMAMapCircle class is used to draw a circle on the map at a fixed geographical location; custom border and fill colors may be defined.

Figure 1. A MapCircle object

NMAMapPolyline class

NMAMapPolyline class is used to draw one or more connected line segments on the map. The segment vertices are specified by a series of NMAGeoCoordinates. The visual appearance of the polyline can be customized.

Figure 2. A MapPolyline object

NMAMapPolygon interface

NMAMapPolygon class is similar to NMAMapPolyline but the first and last points of the line are automatically joined to create a closed shape. Polygon objects can have different border and fill colors.

Figure 3. A MapPolygon object with transparent fill and a border
Note: Polygons that have a path that crosses over itself are not supported. For example, it is not possible to create a "bowtie" shape using four line segments where one line segment crosses another. However, you can create the shape using two triangles.

NMAMapMarker class

NMAMapMarker class is used to display a custom icon at a fixed geographical position on the map.

Custom icons can be provided as a UIImage.

Figure 4. An NMAMapMarker object

You can set NMAMapMarker to be draggable by setting draggable property to YES. To listen for drag events, such as marker position changes, use respondToEvents:withBlock: method in NMAMapView.

Map Object Selection

All user-defined objects with a visual representation can be selected. Selection occurs when a visible object on the map is tapped. By default the map does not take any action when objects are selected. To implement selection handling, a custom class must implement the NMAMapViewDelegate protocol and its onMapObjectsSelected method. onMapObjectsSelected callback returns an array that contains instances of NMAViewObject, which is a superclass of NMAMapObject.

Object selection can also be programmatically invoked by using objectsAtPoint: or visibleObjectsAtPoint: method. Each of these methods takes a CGPoint screen coordinate and returns an NSArray of NMAMapObject at that location. visibleObjectsAtPoint method does not return any object that has visible property set as NO.

For more information see the NMAMapView API documentation.