HERE Android SDK Developer's Guide

MapMarker

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

Class Summary

public final class MapMarker

extends com.here.android.mpa.mapping.MapObject, com.here.android.mpa.common.ViewObject, java.lang.Object

Represents a marker used to display an icon at a geographical position on a map.

[For complete information, see the section Class Details]

Nested Class Summary

Table 1. Nested Classes in MapMarker
Nested Classes

public static abstract interface MapMarker.OnDragListener

Callback interface for drag events on MapMarker objects.

Constructor Summary

Table 2. Constructors in MapMarker
Constructors

MapMarker ()

Creates a default MapMarker.

MapMarker (float hue)

Creates a default MapMarker.

MapMarker (GeoCoordinate coordinate, Image image)

Creates a MapMarker with a specified GeoCoordinate and Image.

Method Summary

Table 3. Methods in MapMarker
Methods

public PointF getAnchorPoint ()

Returns the anchor point for this MapMarker .

public GeoCoordinate getCoordinate ()

Returns the current map GeoCoordinate for this MapMarker .

public String getDescription ()

Gets the current description text.

public Image getIcon ()

Returns the icon image for this MapMarker .

public int getInfoBubbleHashCode ()

Returns non-zero hash code of the info bubble if it is showing.

public String getTitle ()

Gets the current title to be used by the default info bubble.

public float getTransparency ()

Gets the current transparency for the icon

public Type getType ()

public void hideInfoBubble ()

Hides the info bubble if it's currently showing.

public boolean isDraggable ()

Returns a boolean indicating whether the marker is draggable.

public boolean isInfoBubbleVisible ()

Returns a boolean indicating if the info bubble is currently displayed on this marker.

public MapMarker setAnchorPoint (PointF anchor)

Sets an anchor point for this MapMarker .

public MapMarker setCoordinate (GeoCoordinate coordinate)

Sets a map GeoCoordinate for this MapMarker .

public MapMarker setDescription (String description)

Sets the description text.

public MapMarker setDraggable (boolean isDraggable)

Sets whether this marker is draggable or not.

public MapMarker setIcon (Image icon)

Sets an icon image for this MapMarker .

public MapMarker setTitle (String title)

Sets a title to be used by the default info bubble.

public boolean setTransparency (float alpha)

Sets a transparency level, within the range of [0..1], for the icon.

public void showInfoBubble ()

Displays the default info bubble if setTitle(String) has been set to something non-null.

Class Details

Represents a marker used to display an icon at a geographical position on a map. The map handles proper placement of icons on the screen as well as panning and rotation.

MapMarker objects can be selected by application users.

Constructor Details

MapMarker ()

Creates a default MapMarker. The marker will contain the default marker image.

See also:

MapMarker(float)

MapMarker(GeoCoordinate, Image)

MapMarker (float hue)

Creates a default MapMarker. The marker will contain a colorization of the default marker image.

Parameters:

  • hue

    The hue of the marker. Value must be greater or equal to 0 and less than 360.

Throws:

  • IllegalArgumentException

    For hue values outside the acceptable range.

See also:

MapMarker()

MapMarker(GeoCoordinate, Image)

MapMarker (GeoCoordinate coordinate, Image image)

Creates a MapMarker with a specified GeoCoordinate and Image.

Parameters:

  • coordinate

    A GeoCoordinate representing the map coordinates of the marker

  • image

    An Image used to display the marker

See also:

MapMarker()

MapMarker(float)

Method Details

public PointF getAnchorPoint ()

Returns the anchor point for this MapMarker .

The marker is drawn with the specified pixel offset from its getCoordinate() position. To clear an anchor set previously, pass a PointF to this method with an X-coordinate equal to half the width of the marker and a Y-coordinate equal to half the height of the marker.

By default, there is no offset and the MapMarker is centered in the center of the icon image.

public GeoCoordinate getCoordinate ()

Returns the current map GeoCoordinate for this MapMarker .

Returns:

The current GeoCoordinate location

public String getDescription ()

Gets the current description text.

Returns:

The current description. Can be null if it has not been set.

public Image getIcon ()

Returns the icon image for this MapMarker .

Returns:

An Image representing this marker's icon

public int getInfoBubbleHashCode ()

Returns non-zero hash code of the info bubble if it is showing.

Use this hash code to compare against the hash code of the objects returned by onMapObjectsSelected(List) to determine if object selected is an info bubble. If so, call hideInfoBubble() to close the info bubble.

Returns:

The hash code of the info bubble that is visible. 0 if the info bubble is not showing.

See also:

onMapObjectsSelected(List<ViewObject>)

public String getTitle ()

Gets the current title to be used by the default info bubble.

Returns:

The current title. Can be null if it has not been set.

public float getTransparency ()

Gets the current transparency for the icon

The transparency level is only precise to two decimal places due to numerical operations performed internally when rendering the map.

Returns:

The current transparency of the icon

public Type getType ()

public void hideInfoBubble ()

Hides the info bubble if it's currently showing.

public boolean isDraggable ()

Returns a boolean indicating whether the marker is draggable.

Returns:

True if the marker is draggable, false otherwise.

public boolean isInfoBubbleVisible ()

Returns a boolean indicating if the info bubble is currently displayed on this marker.

Returns:

True if the info bubble is displayed, false otherwise.

public MapMarker setAnchorPoint (PointF anchor)

Sets an anchor point for this MapMarker .

The marker is drawn with the specified pixel offset from its getCoordinate() position. To clear an anchor set previously, pass a PointF to this method with an X-coordinate equal to half the width of the marker and a Y-coordinate equal to half the height of the marker.

By default, there is no offset and the MapMarker is centered in the center of the icon image.

Parameters:

  • anchor

    A PointF relative to the top-left corner of the MapMarker.

Returns:

The updated MapMarker itself.

public MapMarker setCoordinate (GeoCoordinate coordinate)

Sets a map GeoCoordinate for this MapMarker .

Parameters:

  • coordinate

    Desired GeoCoordinate location for this marker

Returns:

The updated MapMarker itself.

public MapMarker setDescription (String description)

Sets the description text. This will be shown below the title in normal typeface.

Parameters:

  • description

    The description to be set.

Returns:

The updated MapMarker itself.

public MapMarker setDraggable (boolean isDraggable)

Sets whether this marker is draggable or not. By default, the marker is not draggable.

If any user overridden methods of onLongPressEvent(PointF) or onDoubleTapEvent(PointF) that is registered with MapGesture returns true , the MapMarker will ignore any drag events even if the marker is set to enable dragging.

Parameters:

  • isDraggable

    true if the marker is draggable, false otherwise.

Returns:

The updated MapMarker itself.

See also:

MapGesture

public MapMarker setIcon (Image icon)

Sets an icon image for this MapMarker .

Parameters:

  • icon

    An Image representing this marker's icon

Returns:

The updated MapMarker itself.

public MapMarker setTitle (String title)

Sets a title to be used by the default info bubble.

Parameters:

  • title

    The title to set.

Returns:

The updated MapMarker itself.

public boolean setTransparency (float alpha)

Sets a transparency level, within the range of [0..1], for the icon.

Parameters:

  • alpha

    Desired alpha value for the icon, 0 for fully transparent, 1 for fully opaque (the default value is 1)

Returns:

True if successful, false otherwise.

public void showInfoBubble ()

Displays the default info bubble if setTitle(String) has been set to something non-null. This method should be called only after the MapMarker is added onto a Map, otherwise making this call would make no effects. As only one info bubble can be displayed on the map at a time, thus when calling showInfoBubble() on a different MapMarker , the current info bubble on display will automatically be closed before the newly selected one is shown.

See also:

addMapObject(MapObject)

addMapObjects(List<MapObject>)

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.