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 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
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
NMAMapContainerinstance holding this object, if any
uniqueId- uniquely identifies the object for the duration of application launch
NMAMapObjectserves 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.
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
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
NMAMapCircle class is used to draw a circle on the map at a fixed geographical location; custom border and fill colors may be defined.
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.
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.
NMAMapMarker class is used to display a custom icon at a fixed geographical position on the map.
Custom icons can be provided as a
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
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 callback returns an array that contains instances of
NMAViewObject, which is a superclass of
Object selection can also be programmatically invoked by using
visibleObjectsAtPoint: method. Each of these methods takes a
CGPoint screen coordinate and returns an
NMAMapObject at that location.
visibleObjectsAtPoint method does not return any object that has
visible property set as
For more information see the
NMAMapView API documentation.