HERE Android SDK Developer's Guide

Objects and Interaction

You can select ViewObject objects by using a single tap gesture. To enable this in your code, create an OnGestureListener object and pass it to MapFragment.getMapGesture().addOnGestureListener(OnGestureListener). When a single tap occurs, the listener receives the onTapEvent(PointF) callback, and if that event is not handled, then the listener receives the onMapObjectsSelected(List<ViewObject>) callback. The application can then define what to do with the selected ViewObject.

Types of ViewObject objects that are selectable are defined within the ViewObject.Type enumeration, which includes:

  • USER_OBJECT - an object that the application adds to a map with a MapObject base class (MapPolygon for example).
  • UNKNOWN_OBJECT - a selectable map object that is not a USER_OBJECT

The ViewObject Abstract Class

The ViewObject abstract class represents the base implementation for all objects that are selectable on a MapView or MapFragment. The MapFragment features user-selectable objects.

Sub-classes of the ViewObject class include MapObject .

MapObject and Geo Objects

MapObject represents an abstract class for all map-related objects that can be added on a Map. The subclasses of this abstract class include:

  • MapContainer
  • MapCircle
  • MapPolyline
  • MapPolygon
  • MapRoute
  • MapMarker

These objects can be created by calling the appropriate constructor methods. In some cases, a geo object is required in the constructor. Geo objects (for example, GeoPolyline and GeoPolygon) are geographical data representations that act as models to MapObjects, which act as views. Unlike map objects, geo objects cannot be added directly to a Map. For more information on geo objects and creating map objects, see the API Reference.

The following code snippet demonstrates how to create a MapPolyline and a GeoPolyline object:

List<GeoCoordinate> testPoints = new ArrayList<GeoCoordinate>();
testPoints.add(new GeoCoordinate(49.163, -123.137766, 10));
testPoints.add(new GeoCoordinate(59.163, -123.137766, 10));
testPoints.add(new GeoCoordinate(60.163, -123.137766, 10));
GeoPolyline polyline = new GeoPolyline(testPoints);
MapPolyline mapPolyline = new MapPolyline(polyline);

To add a MapObject to the map, use Map.addMapObject(MapObject) or Map.addMapObjects(List<MapObject>).


You can use MapContainer as a container for other MapObject instances. Map containers determine the stacking order of objects displayed on a map. To add a map object, call the MapContainer.addMapObject(MapObject) method.

Note: MapRoute and MapContainer cannot be added to a MapContainer.


A MapCircle represents a type of MapObject in the shape of a circle, with an assigned radius distance and a GeoCoordinate center. It can be created by calling the constructor MapCircle(double radius, GeoCoordinate center).

Figure 1. A MapCircle object


A MapPolyline is a MapObject in the shape of a polyline with anchor points at any number of GeoCoordinate points. It can be created via a GeoPolyline object, which can be created by calling the GeoPolyline(List<GeoCoordinate> points) constructor.

Note: A MapPolyline or MapPolygon can only contain up to 65536 vertices.
Figure 2. A MapPolyline object


A MapPolygon is a MapObject in the shape of a polygon. In contrast with a MapPolyline, it is assumed that the last coordinate in the line's path is connected to the first coordinate, thereby constructing an enclosed geometry. A MapPolygon may define separate border and fill colors. To create a MapPolygon, use the constructor MapPolygon(GeoPolygon polygon). A GeoPolygon can be created by calling GeoPolygon(List<GeoCoordinate> points).

Figure 3. A MapPolygon object


A MapRoute is a MapObject that displays a calculated route on a map. For more information on MapRoute, see Routing.


A MapMarker is a MapObject that displays an icon at a geographical position on a map. You can create a MapMarker with your own custom icon by calling MapMarker(GeoCoordinate, Image).

Figure 4. A MapMarker object

MapMarker instances are always placed on top of other map objects. Refer to the diagram below for more information about z-index ordering for multiple map markers.

Figure 5. MapMarker order

You can set MapMarker to be draggable by using the MapMarker.setDraggable(true) method. To listen for drag events, such as marker position changes, use MapMarker.OnDragListener.

User Interactions with MapObject

This section provides an example on handling MapObject tap events. In the following code:

  • addMapObject() adds the object on the Map.
  • List<ViewObject> holds the objects that have been selected in this tap event. By looping through this list of objects, your code can find the MapObject that should respond to this tap event.
Note: The onMapObjectsSelected(List) callback is triggered after the onTapEvent(PointF) callback. For more information on this, refer to Map Gestures

// Create a custom marker image myImage =

try {
} catch (IOException e) {

// Create the MapMarker
MapMarker myMapMarker =
  new MapMarker(new GeoCoordinate(LAT, LNG), myImage);



// Create a gesture listener and add it to the MapFragment
MapGesture.OnGestureListener listener =
  new MapGesture.OnGestureListener.OnGestureListenerAdapter() {
    public boolean onMapObjectsSelected(List<ViewObject> objects) {
      for (ViewObject viewObj : objects) {
        if (viewObj.getBaseType() == ViewObject.Type.USER_OBJECT) {
          if (((MapObject)viewObj).getType() == MapObject.Type.MARKER) {
            // At this point we have the originally added
            // map marker, so we can do something with it
            // (like change the visibility, or more
            // marker-specific actions)
      // return false to allow the map to handle this callback also
      return false;

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