Map Overlays (Android)

This article describes how to add interactive map overlays.

Map Overlays Overview

Map overlays are colored shapes you can draw on your maps using area placemarks. You can make these overlays interactive.

A map overlay example is included in the Android Sample app.

Map Overlay Code

Use this code to implement a map overlay.

Placemark myPlacemark;  // known placemark
Context c = getActivity();

if(placemark.getArea() != null && c != null) {

    // Create the OverlayMarker
    OverlayMarker om = new OverlayMarker.Builder(c,
            OverlayMarkerOptions.fromPlacemark(myPlacemark)).build();
    om.getOverlayMarkerOptions().setOverlayColor(0x2222AA55);
    om.getOverlayMarkerOptions().setOverlayFillColor(0x2222AA33);

    // Selection notification via onMarkerSelect() is enabled by default

    // Add the OverlayMarker to the map
    List<Marker> markerList = Arrays.asList((Marker)om);
    getMapView().commitTransaction(
        new Transaction.Builder().setAnimationDuration(500)
                                 .addMarkers(markerList).build());
}