HERE Android SDK Developer's Guide

MapView

The class MapView is a member of com.here.android.mpa.mapping .

Class Summary

public class MapView

extends java.lang.Object

Represents a map view.

[For complete information, see the section Class Details]

See also:

MapActivity

android.view.ViewGroup

Nested Class Summary

Table 1. Nested Classes in MapView
Nested Classes

public static final enumeration MapView.TileSize

Tile resolution selection.

Constructor Summary

Table 2. Constructors in MapView
Constructors

MapView (Context context)

Constructor that initializes the context.

MapView (Context context, AttributeSet attrs)

Constructor that initializes the context and a set of attributes.

Field Summary

Table 3. Fields in MapView
Fields

public static final int FIXED_HIGHDPI_SIZE

public static final int FIXED_LOWDPI_SIZE

protected boolean m_copyrightLogoVisible

protected ImageView m_logoView

Method Summary

Table 4. Methods in MapView
Methods

public void addOnMapRenderListener (OnMapRenderListener listener)

Adds a OnMapRenderListener to listen for map render events.

protected void dispatchRestoreInstanceState (SparseArray container)

Override to prevent thawing of any child views.

protected void dispatchSaveInstanceState (SparseArray container)

Override to prevent freezing of any child views.

public Rect getCopyrightBoundaryRect ()

Gets the current rectangle relative to the view group as a container for the HERE copyright logo.

public int getCopyrightLogoHeight ()

Gets the height of the copyright logo.

public CopyrightLogoPosition getCopyrightLogoPosition ()

Gets the current position for the HERE copyright logo.

public int getCopyrightLogoVisibility ()

Gets the visibility of the HERE copyright logo.

public int getCopyrightLogoWidth ()

Gets the width of the copyright logo.

public int getCopyrightMargin ()

Gets the current margin, in pixels, for the HERE copyright logo, an offset from the edge of the visible map area to the edge of the logo.

public Map getMap ()

Returns the instance of Map associated with this MapView

public MapGesture getMapGesture ()

Gets the MapGesture representing the current gesture handler for the MapView .

protected void onLayout (boolean changed, int left, int top, int right, int bottom)

For documentation, see android.view.ViewGroup

public void onPause ()

Propagates an activity's onPause() event to the view.

public void onRestoreInstanceState (Parcelable state)

Callback indicating that a stored view state was restored (e.g.

public void onResume ()

Propagates an activity's onResume() event to the view.

public Parcelable onSaveInstanceState ()

Callback indicating that the internal state of a view was saved for later use (e.g.

public void removeOnMapRenderListener (OnMapRenderListener listener)

Removes an existing OnMapRenderListener.

public void setCopyrightBoundaryRect (Rect rect)

Sets a rectangle relative to the view group as a container for the HERE copyright logo.

public void setCopyrightLogoPosition (CopyrightLogoPosition position)

Sets a position for the HERE copyright logo.

public void setCopyrightMargin (int margin)

Sets a margin, in pixels, for the HERE copyright logo, an offset from the edge of the visible map area to the edge of the logo (depending on the placement).

public void setMap (Map aMap)

Associates the graphical view element with a Map .

public void setMapMarkerDragListener (OnDragListener listener)

Sets a MapMarker.OnDragListener to be invoked whenever any MapMarker added onto a Map that is attached to this MapView is dragged.

public static void setTileResolution (TileSize size)

Changes the tiles source to use.

Class Details

Represents a map view. This is the "View" UI class designed to handle all UI-related use cases, including rendering and screen touch events.

Each MapView must be bound to a Map, and map-related objects should be persisted during application runtime. MapView objects live and expire according to the associated activity's lifecycle.

A MapView is defined in an Android layout XML file. For example:


   <com.here.android.mpa.mapping.MapView
     android:id="@+id/mapview"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:visibility="visible"/>
  

Each MapView should follow the regular android lifecycle. When an activity's onResume() and onPause() are called, the view should also be notified via calls from within those methods. Please take care in how much processing is done in the onResume() method of an activity. Performing significant amounts of processing may delay the view rendering in cases such as device orientation change. It is recommended to use a specifically designated handler for organizing the amount of processing to be done in such cases.

Note that MapView does not notify the MapEngine when it is paused or resumed. User of MapView is responsible for handling the pausing and resuming of the MapEngine if needed. Another option is to utilize the MapActivity class when creating an activity with a MapView.

Although this class inherits from ViewGroup , it is not advisable for users to add children to MapView as no layout actions will be performed on any added children views.

See also:

MapActivity

android.view.ViewGroup

Constructor Details

MapView (Context context)

Constructor that initializes the context.

Parameters:

  • context

    Context of the MapView

See also:

MapView(Context, AttributeSet)

android.content.Context

MapView (Context context, AttributeSet attrs)

Constructor that initializes the context and a set of attributes.

Parameters:

  • context

    Context of the MapView

  • attrs

    An AttributeSet representing attributes of the MapView

See also:

MapView(Context)

android.content.Context

android.util.AttributeSet

Field Details

public static final int FIXED_HIGHDPI_SIZE

public static final int FIXED_LOWDPI_SIZE

protected boolean m_copyrightLogoVisible

protected ImageView m_logoView

Method Details

public void addOnMapRenderListener (OnMapRenderListener listener)

Adds a OnMapRenderListener to listen for map render events.

Parameters:

  • listener

    A OnMapRenderListener to add to the MapView

See also:

removeOnMapRenderListener(OnMapRenderListener)

protected void dispatchRestoreInstanceState (SparseArray container)

Override to prevent thawing of any child views. As child views created and added to the view group dynamically have the same id as the parent, causing conflict when the state is saved, all child views are blocked from being saved. Instead, this container will manually trigger the save and restore.

Parameters:

  • container

protected void dispatchSaveInstanceState (SparseArray container)

Override to prevent freezing of any child views. As child views created and added to the view group dynamically have the same id as the parent, causing conflict when the state is saved, all child views are blocked from being saved. Instead, this container will manually trigger the save and restore.

Parameters:

  • container

public Rect getCopyrightBoundaryRect ()

Gets the current rectangle relative to the view group as a container for the HERE copyright logo.

Returns:

The boundary rect (can be null).

public int getCopyrightLogoHeight ()

Gets the height of the copyright logo.

This method only returns a valid value once a Map has been set to this view.

Returns:

The height of the copyright logo in pixels. Returns -1 if unavailable.

public CopyrightLogoPosition getCopyrightLogoPosition ()

Gets the current position for the HERE copyright logo.

Returns:

The position of the logo.

public int getCopyrightLogoVisibility ()

Gets the visibility of the HERE copyright logo. Copyright logo is defaulted to be visible. Once changed, the visibility of logo stays effective even when the screen is rotated or re-created.

Returns:

One of the two values View.VISIBLE or View.INVISIBLE to represent the copyright logo's visibility.

public int getCopyrightLogoWidth ()

Gets the width of the copyright logo.

This method only returns a valid value once a Map has been set to this view.

Returns:

The width of the copyright logo in pixels. Returns -1 if unavailable.

public int getCopyrightMargin ()

Gets the current margin, in pixels, for the HERE copyright logo, an offset from the edge of the visible map area to the edge of the logo.

Returns:

The current offset from the edge of the MapView

public Map getMap ()

Returns the instance of Map associated with this MapView

Returns:

The Map object currently displayed in this view.

public MapGesture getMapGesture ()

Gets the MapGesture representing the current gesture handler for the MapView . Applications can intercept this object and override the default events.

Returns:

The MapGesture

protected void onLayout (boolean changed, int left, int top, int right, int bottom)

For documentation, see android.view.ViewGroup

Parameters:

  • changed
  • left
  • top
  • right
  • bottom

public void onPause ()

Propagates an activity's onPause() event to the view. Applications can call this method within the onPause() method of any activity which has a MapView as part of its view hierarchy. Note that unlike MapFragment, MapView does not automatically handle the pausing and/or resuming of MapEngine. Owner of MapView is responsible to address the handling of onPause() if needed.

See also:

onPause()

onPause()

public void onRestoreInstanceState (Parcelable state)

Callback indicating that a stored view state was restored (e.g. to create a new MapView with the same state).

Parameters:

See also:

android.view.View.onRestoreInstanceState(Parcelable)

public void onResume ()

Propagates an activity's onResume() event to the view. Applications can call this method within the onResume() method of any activity which has a MapView as part of its view hierarchy. Note that unlike MapFragment, MapView does not automatically handle the pausing and/or resuming of MapEngine. Owner of MapView is responsible to address the handling of onResume() if needed.

See also:

onResume()

onResume()

public Parcelable onSaveInstanceState ()

Callback indicating that the internal state of a view was saved for later use (e.g. to create a new MapView with the same state).

Returns:

The android.os.Parcelable for storing the view state

See also:

android.view.View.onSaveInstanceState()

public void removeOnMapRenderListener (OnMapRenderListener listener)

Removes an existing OnMapRenderListener.

Parameters:

  • listener

    A OnMapRenderListener to remove from the MapView

public void setCopyrightBoundaryRect (Rect rect)

Sets a rectangle relative to the view group as a container for the HERE copyright logo.

If the specified rectangle is not contained completely within the current visible map area, their area of intersection will be used instead of the specified rectangle's area. If the specified rectangle is outside the current visible map area, it will be ignored.

Note: the copyright boundary rectangle is reset upon screen rotation or upon recreating the screen.

Parameters:

  • rect

    The rectangle to move the copyright logo to.

public void setCopyrightLogoPosition (CopyrightLogoPosition position)

Sets a position for the HERE copyright logo. The current default is to place the logo at the center-bottom of the visible map view area.

Note: after the logo's position is set, it stays effective even when the screen is rotated or re-created.

Parameters:

  • position

    A MapCopyrightLogoPosition value representing the desired placement of the HERE copyright logo with respect to the visible map view area

public void setCopyrightMargin (int margin)

Sets a margin, in pixels, for the HERE copyright logo, an offset from the edge of the visible map area to the edge of the logo (depending on the placement).

Parameters:

  • margin

    Desired offset from the edge of the MapView

public void setMap (Map aMap)

Associates the graphical view element with a Map . Applications must call this method to bind the MapView and Map .

Note: the Map that gets passed as a parameter to this method could be null , in which case all listeners will be cleaned up.

Users are advised to call setMap(Map) with null to detach the map only after the onPause() is called to avoid memory leaks.

Parameters:

  • aMap

    A Map to associate with the MapView (could be null)

public void setMapMarkerDragListener (OnDragListener listener)

Sets a MapMarker.OnDragListener to be invoked whenever any MapMarker added onto a Map that is attached to this MapView is dragged.

Parameters:

public static void setTileResolution (TileSize size)

Changes the tiles source to use. This must be done before the map view is iniitialized.

Parameters:

  • size

    Tile size selection

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.