HERE iOS SDK Developer's Guide

NMAMapOverlay

Class Summary

class NMAMapOverlay

Derived from: UIView, NMAMapViewDelegate

A UIView subclass used to display graphics content at a fixed geographical location on the map.

Include: NMAKit.framework/headers/NMAMapOverlay.h

Inheritance Diagrams

Figure 1. Public inheritance diagram for NMAMapOverlay

[For complete information, see the section Class Details]

Public Property Summary

Table 1. Public Properties
Public Properties

[readable, writable, assign] CGPoint  anchorOffset

The CGPoint offset of the NMAMapOverlay from its anchored location.

[readable, writable, strong] NMAGeoCoordinates coordinates

The NMAGeoCoordinates for the NMAMapOverlay center

[readable, writable, assign] BOOL  displayedAsMarker

Display the NMAMapOverlay on the map as an equivalent NMAMapMarker

[readable, writable, assign] NSUInteger  zMarkerIndex

The NSUInteger z-index for the NMAMapOverlay in NMAMapOverlayTypeMapMarker mode

Instance Method Summary

Table 2. Instance Methods
Instance Method Summary

-(nonnull instancetype) initWithSubview:(nonnull UIView *) subview

Initializes a NMAMapOverlay instance with the specified UIView subview

-(nonnull instancetype) initWithSubview:(nonnull UIView *) subview geoCoordinates:(nonnull NMAGeoCoordinates *) coordinates

Initializes a NMAMapOverlay instance with the specified UIView subview and NMAGeoCoordinates location

-(void) refresh

Updates the size and position of the NMAMapOverlay

-(CGPoint) setAnchorOffsetUsingLayoutPosition:( NMALayoutPosition ) position

Class Method Summary

Table 3. Class Methods
Class Methods

+(nonnull instancetype) mapOverlayWithSubview:(nonnull UIView *) subview

A convenience method to construct a NMAMapOverlay with a subview

+(nonnull instancetype) mapOverlayWithSubview:(nonnull UIView *) subview geoCoordinates:(nonnull NMAGeoCoordinates *) coordinates

A convenience method to construct a NMAMapOverlay with a subview and location

Class Details

A UIView subclass used to display graphics content at a fixed geographical location on the map.

The NMAMapOverlay class can be used to display custom UIView-based content at a fixed location on the map. To use, create a NMAMapOverlay and add one or more custom UIViews as subviews of the overlay. Then, give the overlay a NMAGeoCoordinates location and add it to a map. The overlay will automatically be repositioned on the screen as the map moves.

The NMAMapOverlay will automatically be resized and repositioned when subviews are added or removed; however, changes to the size or content of existing subviews will not be detected. Any such changes should be followed by an invocation of the -refresh method.

To ensure overlays are not drawn outside the bounds of the NMAMapView to which they are added set the NMAMapView clipsToBounds property to YES.

There is slightly more overhead involved in positioning an overlay as compared to a NMAMapMarker, so for use cases which only require static images, markers should be used. NMAMapOverlay should be used if features provide by UIView are required, such as Core Animation or dynamic content.

In some cases, the NMAMapOverlay may be static for most of its life with the occasional need to be animated or otherwise dynamic. For these cases, the property "displayedAsMarker" can be used to replace the NMAMapOverlay with a NMAMapMarker displaying a "snapshot" of the overlay.

Note:

NMAMapOverlay automatically adjusts the values of its UIView center, bounds, and frame properties to ensure that the overlay is always in the correct position and always large enough to encompass all of its subviews. Thus, it is not recommended to modify these properties directly.

Note:

It is not recommended to subclass NMAMapOverlay.

Public Property Details

[readable, writable, assign] CGPoint anchorOffset

The CGPoint offset of the NMAMapOverlay from its anchored location.

Use this property to reposition a NMAMapOverlay as needed. The x and y offset values are measured in points. Positive offset values move the NMAMapOverlay down and to the right, while negative values move it up and to the left.

If no offset is provided, the NMAMapOverlay is centered on its anchor; that is, the center of the marker image is located at the map-space representation of the marker's world-space location (its anchor, an NMAGeoCoordinates).

[readable, writable, strong] NMAGeoCoordinatescoordinates

The NMAGeoCoordinates for the NMAMapOverlay center.

[readable, writable, assign] BOOL displayedAsMarker

Display the NMAMapOverlay on the map as an equivalent NMAMapMarker.

Set this property to YES to replace the NMAMapOverlay with an identical- looking NMAMapMarker. The property can be set back to NO at any time to go back to displaying the overlay.

Defaults to NO.

Note:

The displayed marker is static snapshot of the overlay at the time when this property is changed from NO to YES. It will not reflect changes made to the overlay after setting this property to YES. To update the marker, call the refresh method.

[readable, writable, assign] NSUInteger zMarkerIndex

The NSUInteger z-index for the NMAMapOverlay in NMAMapOverlayTypeMapMarker mode.

Instance Method Details

-(nonnull instancetype) initWithSubview:(nonnull UIView *) subview

Initializes a NMAMapOverlay instance with the specified UIView subview.

Parameters:

  • subview

    The subview to be displayed on the map

Returns:

The NMAMapOverlay

-(nonnull instancetype) initWithSubview:(nonnull UIView *) subview geoCoordinates:(nonnull NMAGeoCoordinates *) coordinates

Initializes a NMAMapOverlay instance with the specified UIView subview and NMAGeoCoordinates location.

Parameters:

  • subview

    The subview to be displayed on the map

  • coordinates

    The location at which to display the overlay

Returns:

The NMAMapOverlay

-(void) refresh

Updates the size and position of the NMAMapOverlay. Should be invoked when the content of the overlay has changed.

-(CGPoint) setAnchorOffsetUsingLayoutPosition:( NMALayoutPosition ) position

A convenience function to set where the NMAMapOverlay is attached to its anchor

Parameters:

  • position

    A NMAnchorLocation for anchoring the marker icon.

Returns:

The CGPoint offset value that was applied to the anchorOffset property

Class Method Details

+(nonnull instancetype) mapOverlayWithSubview:(nonnull UIView *) subview

A convenience method to construct a NMAMapOverlay with a subview.

+(nonnull instancetype) mapOverlayWithSubview:(nonnull UIView *) subview geoCoordinates:(nonnull NMAGeoCoordinates *) coordinates

A convenience method to construct a NMAMapOverlay with a subview and location.