public final class

AmazonMap

extends Object
java.lang.Object
   ↳ com.amazon.geo.mapsv2.AmazonMap

Class Overview

The main class for interacting with the map. This class cannot be instantiated directly but must be obtained from MapFragment.getMapAsync(), SupportMapFragment.getMapAsync(), or MapView.getMapAsync().

All interactions with AmazonMap must be on the main thread. Calling methods off of the main thread results in an IllegalStateException.

Indoor maps are not currently supported. Stubs are available to provide API parity.

Summary

Nested Classes
interface AmazonMap.CancelableCallback Interface for receiving notifications when a task is cancelled or completed. 
interface AmazonMap.InfoWindowAdapter Interface for displaying Marker info windows. 
interface AmazonMap.OnCameraChangeListener Interface for receiving callbacks when the map camera changes position. 
interface AmazonMap.OnIndoorStateChangeListener Interface for receiving notifications when indoor maps change state. 
interface AmazonMap.OnInfoWindowClickListener Interface for receiving callbacks when a user clicks the info window for a Marker
interface AmazonMap.OnMapClickListener Interface for receiving callbacks when the map is clicked. 
interface AmazonMap.OnMapLoadedCallback Interface for receiving callbacks when the map finishes loading. 
interface AmazonMap.OnMapLongClickListener Interface for receiving callbacks when the user performs a long click on the map. 
interface AmazonMap.OnMarkerClickListener Interface for receiving callbacks when the user clicks a Marker
interface AmazonMap.OnMarkerDragListener Interface for receiving callbacks when the user drags a marker. 
interface AmazonMap.OnMyLocationButtonClickListener Interface for receiving callbacks when the user clicks the "Locate Me" button. 
interface AmazonMap.OnMyLocationChangeListener This interface is deprecated. Use standard Android location APIs instead. See the Location Strategies API guide for details.  
interface AmazonMap.SnapshotReadyCallback Interface for receiving callbacks from the snapshot() methods. 
Constants
int MAP_TYPE_HYBRID Display satellite tiles with labels and translucent road overlays.
int MAP_TYPE_NONE Display no map tiles.
int MAP_TYPE_NORMAL Display base map tiles.
int MAP_TYPE_SATELLITE Display satellite tiles with no roads or labels.
int MAP_TYPE_TERRAIN Display terrain tiles with labels and white road overlays. Not supported in Amazon Maps API v2.5.
Public Methods
final Circle addCircle(CircleOptions options)
Adds a Circle to the map.
final GroundOverlay addGroundOverlay(GroundOverlayOptions options)
This is not yet implemented and will throw an UnsupportedOperationException when called.
final Marker addMarker(MarkerOptions options)
Adds a marker to the map.

Note that flat and draggable markers are not currently supported. All markers added to the map are non-flat, non-draggable markers, regardless of the flat and draggable settings.

final Polygon addPolygon(PolygonOptions options)
Adds a Polygon to the map.
final Polyline addPolyline(PolylineOptions options)
Adds a Polyline to the map.
final TileOverlay addTileOverlay(TileOverlayOptions options)
Adds a TileOverlay to the map.

Only UrlTileProvider based implementaions are supported in Amazon Maps API v2.5.

final void animateCamera(CameraUpdate update, AmazonMap.CancelableCallback callback)

Animates the map camera to the specified CameraUpdate destination over a default duration with an optional completion callback.

Camera animations are not supported in the Amazon Maps API v2.5

final void animateCamera(CameraUpdate update, int durationMs, AmazonMap.CancelableCallback callback)

Animates the map camera to the specified CameraUpdate destination over a specified duration, with an optional completion callback.

Camera animations are not supported in the Amazon Maps API v2.5.

final void animateCamera(CameraUpdate update)

Animates the map camera to the specified CameraUpdate destination over a default duration.

Camera animations are not supported in the Amazon Maps API v2.5.

final void clear()
Removes all added objects from the map.
final CameraPosition getCameraPosition()
Gets a CameraPosition representing a snapshot of the current position of the map camera.
final IndoorBuilding getFocusedBuilding()
Gets the focused building with indoor maps.
final int getMapType()
Gets the currently displayed map type.
final float getMaxZoomLevel()
Gets the maximum zoom level for the camera at the current position.
final float getMinZoomLevel()
Gets the minimum zoom level for the camera at the current position.
final Location getMyLocation()
This method is deprecated. Use standard Android location APIs instead. See the Location Strategies API guide for details.
final Projection getProjection()
Gets a Projection object that can be used to convert between latitude/longitude and screen coordinates.
final UiSettings getUiSettings()
Gets a UiSettings object representing the user interface settings currently in use.
final boolean isBuildingsEnabled()
Retrieves a boolean value that specifies whether buildings are enabled.
final boolean isIndoorEnabled()
Retrieves a boolean value that specifies whether indoor maps are currently enabled.

Note that indoor buildings are not currently supported in the Amazon Maps API, so this always returns false.

final boolean isMyLocationEnabled()
Retrieves a boolean value that specifies whether the "My Location" layer is currently enabled.
final boolean isTrafficEnabled()
Retrieves a boolean value that specifies whether the traffic layer is currently enabled.
final void moveCamera(CameraUpdate update)
Immediately moves the map camera to the specified CameraUpdate destination.
final void setBuildingsEnabled(boolean enabled)
Sets whether 3D buildings are displayed on the map.
final boolean setIndoorEnabled(boolean enabled)
Sets whether indoor maps are displayed.

Note that indoor buildings are not currently supported in the Amazon Maps API, so this returns false.

final void setInfoWindowAdapter(AmazonMap.InfoWindowAdapter adapter)
Sets a custom adapter for displaying Marker info windows.
final void setLocationSource(LocationSource source)
Sets a LocationSource for the "My Location" layer.
final void setMapType(int type)
Sets the map type to display.
final void setMyLocationEnabled(boolean enabled)
Enable or disable the "My Location" layer.
final void setOnCameraChangeListener(AmazonMap.OnCameraChangeListener listener)
Sets a listener to receive callbacks when the map camera changes position.
final void setOnIndoorStateChangeListener(AmazonMap.OnIndoorStateChangeListener listener)
Sets a listener to receive callbacks for indoor maps state changes.

Note that indoor buildings are not supported in the Amazon Maps API, so this listener is never called.

final void setOnInfoWindowClickListener(AmazonMap.OnInfoWindowClickListener listener)
Sets a listener to receive callbacks when the user clicks on a Marker's info window.
final void setOnMapClickListener(AmazonMap.OnMapClickListener listener)
Sets a listener to receive callbacks when the user clicks on the map.
void setOnMapLoadedCallback(AmazonMap.OnMapLoadedCallback callback)

Sets a callback to receive notifications after all map tiles are fetched and rendered.

Map loaded callbacks are not supported in the Amazon Maps API v2.5 and hence the callback will never be invoked.

final void setOnMapLongClickListener(AmazonMap.OnMapLongClickListener listener)
Sets a listener to receive callbacks when the user performs a long click on the map.
final void setOnMarkerClickListener(AmazonMap.OnMarkerClickListener listener)
Sets a listener to receive callbacks when the user clicks on a Marker.
final void setOnMarkerDragListener(AmazonMap.OnMarkerDragListener listener)
Sets a listener to receive callbacks when a marker is dragged.

Note that draggable markers are not currently supported in the Amazon Maps API, so this listener is never called.

final void setOnMyLocationButtonClickListener(AmazonMap.OnMyLocationButtonClickListener listener)
Sets a listener to receive callbacks when the user clicks the "Locate Me" button.
final void setOnMyLocationChangeListener(AmazonMap.OnMyLocationChangeListener listener)
This method is deprecated. Use standard Android location APIs instead. See the Location Strategies API guide for details.
final void setPadding(int left, int top, int right, int bottom)
Sets the number of pixels to offset all map controls, indicators, attribution text, and any other fixed views in from the edge of the map fragment or map view's bounding box.
final void setTrafficEnabled(boolean enabled)
Enables or disables the traffic layer.
final void snapshot(AmazonMap.SnapshotReadyCallback callback)
Takes a snapshot of the map.
final void snapshot(AmazonMap.SnapshotReadyCallback callback, Bitmap bitmap)
Takes a snapshot of the map and returns it in a pre-allocated Bitmap passed to the method.
final void stopAnimation()

Stops any active map camera animation.

Camera animations are not supported in the Amazon Maps API v2.5.

[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int MAP_TYPE_HYBRID

Display satellite tiles with labels and translucent road overlays.

Constant Value: 4 (0x00000004)

public static final int MAP_TYPE_NONE

Display no map tiles.

Constant Value: 0 (0x00000000)

public static final int MAP_TYPE_NORMAL

Display base map tiles.

Constant Value: 1 (0x00000001)

public static final int MAP_TYPE_SATELLITE

Display satellite tiles with no roads or labels.

Constant Value: 2 (0x00000002)

public static final int MAP_TYPE_TERRAIN

Display terrain tiles with labels and white road overlays. Not supported in Amazon Maps API v2.5.

Constant Value: 3 (0x00000003)

Public Methods

public final Circle addCircle (CircleOptions options)

Adds a Circle to the map. See Circle and CircleOptions for details on creating a valid circle and the available properties.

Parameters
options A CircleOptions object that defines how to draw the circle. Must not be null.
Returns
  • The Circle that was added to the map.

public final GroundOverlay addGroundOverlay (GroundOverlayOptions options)

This is not yet implemented and will throw an UnsupportedOperationException when called.

Adds a ground overlay with the specified options. If the options are not well-formed, this method will throw an IllegalStateException.

Parameters
options The options specified to draw the ground overlay
Returns

public final Marker addMarker (MarkerOptions options)

Adds a marker to the map. The marker icon is rendered at the coordinates defined in the LatLng provided in position(LatLng).

By default, clicking the marker moves the camera to the marker's position. If title(String) is defined, then an info window with the title is shown.

See Marker and MarkerOptions for details on creating a valid marker and the available properties.

Note that flat and draggable markers are not currently supported. All markers are added to the map as non-flat, non-draggable markers, regardless of the flat and draggable settings.

Parameters
options A MarkerOptions object that defines how to draw the marker. Must not be null.
Returns
  • The Marker that was added to the map.

public final Polygon addPolygon (PolygonOptions options)

Adds a Polygon to the map. See Polygon and PolygonOptions for details on creating a valid polygon and the available properties.

Parameters
options A PolygonOptions object that defines how to draw the polygon. Must not be null.
Returns
  • The Polygon that was added to the map.

public final Polyline addPolyline (PolylineOptions options)

Adds a Polyline to the map. See Polyline and PolylineOptions for details on creating a valid polyline and the available properties.

Parameters
options A PolylineOptions object that defines how to draw the Polyline. Must not be null.
Returns
Throws
IllegalArgumentException if getWidth() is negative.

public final TileOverlay addTileOverlay (TileOverlayOptions options)

Adds a TileOverlay to the map. See TileOverlay for details on creating a valid tile overlay and the available properties.

Unlike other overlays, tile overlays are not automatically restored when the map is recreated and must be re-added manually.

Only UrlTileProvider based implementaions are supported in Amazon Maps API v2.5.

Parameters
options A TileOverlayOptions object that defines how to draw the tile overlay. Must not be null.
Returns
Throws
IllegalArgumentException if the TileProvider has not been set in the options.

public final void animateCamera (CameraUpdate update, AmazonMap.CancelableCallback callback)

Animates the map camera to the specified CameraUpdate destination over a default duration with an optional completion callback. The CameraUpdate can set any or all of the camera properties (target, zoom level, bearing, and tilt).

Use the methods in CameraUpdateFactory to create the CameraUpdate.

Camera animations are not supported in the Amazon Maps API v2.5.

Parameters
update A CameraUpdate object that defines the new camera properties to apply.
callback Optional callback to receive notification of the animation's completion on the main thread. The callback will receive onFinish() if the animation completes successfully. If the animation is interrupted by further camera movements or user interaction, onCancel() will be called.
Throws
IllegalStateException if called off of the main thread.

public final void animateCamera (CameraUpdate update, int durationMs, AmazonMap.CancelableCallback callback)

Animates the map camera to the specified CameraUpdate destination over a specified duration, with an optional completion callback. The CameraUpdate can set any or all of the camera properties (target, zoom level, bearing, and tilt).

Use the methods in CameraUpdateFactory to create the CameraUpdate.

Camera animations are not supported in the Amazon Maps API v2.5.

Parameters
update A CameraUpdate object that defines the new camera properties to apply.
durationMs Duration of the animation in milliseconds. Must be positive.
callback Optional callback to receive notification of the animation's completion on the main thread. The callback will receive onFinish() if the animation completes successfully. If the animation is interrupted by further camera movements or user interaction, onCancel() will be called.
Throws
IllegalArgumentException if durationMs is not positive.
IllegalStateException if called off of the main thread.

public final void animateCamera (CameraUpdate update)

Animates the map camera to the specified CameraUpdate destination over a default duration. The CameraUpdate can set any or all of the camera properties (target, zoom level, bearing, and tilt).

Use the methods in CameraUpdateFactory to create the CameraUpdate.

Camera animations are not supported in the Amazon Maps API v2.5.

Parameters
update A CameraUpdate object that defines the new camera properties to apply.
Throws
IllegalStateException if called off of the main thread.

public final void clear ()

Removes all added objects from the map.

public final CameraPosition getCameraPosition ()

Gets a CameraPosition representing a snapshot of the current position of the map camera.

Returns
  • A CameraPosition object representing the current position of the map camera.

public final IndoorBuilding getFocusedBuilding ()

Gets the focused building with indoor maps.

This functionality is not currently supported.

public final int getMapType ()

Gets the currently displayed map type.

Returns
  • The map type (MAP_TYPE_NONE, MAP_TYPE_NORMAL, MAP_TYPE_HYBRID, MAP_TYPE_TERRAIN, or MAP_TYPE_SATELLITE).

public final float getMaxZoomLevel ()

Gets the maximum zoom level for the camera at the current position.

Returns
  • The maximum zoom level.

public final float getMinZoomLevel ()

Gets the minimum zoom level for the camera at the current position.

Returns
  • The minimum zoom level.

public final Location getMyLocation ()

This method is deprecated.
Use standard Android location APIs instead. See the Location Strategies API guide for details.

Gets the current position of the "My Location" indicator.

Returns
  • The "My Location" indicator's current location.

public final Projection getProjection ()

Gets a Projection object that can be used to convert between latitude/longitude and screen coordinates.

The returned Projection is a snapshot of the projection, representing where the camera was when this method was called. Note that Amazon Maps uses a Mercator (EPSG:3857) projection.

Returns
  • A Projection object representing a snapshot of the projection.

public final UiSettings getUiSettings ()

Gets a UiSettings object representing the user interface settings currently in use. The returned UiSettings object can be used change map UI settings.

Returns

public final boolean isBuildingsEnabled ()

Retrieves a boolean value that specifies whether buildings are enabled.

Returns
  • true if buildings are enabled, false otherwise.

public final boolean isIndoorEnabled ()

Retrieves a boolean value that specifies whether indoor maps are currently enabled.

Note that indoor buildings are not currently supported in the Amazon Maps API, so this always returns false.

public final boolean isMyLocationEnabled ()

Retrieves a boolean value that specifies whether the "My Location" layer is currently enabled.

Returns
  • true if the "My Location" layer is enabled, false otherwise.

public final boolean isTrafficEnabled ()

Retrieves a boolean value that specifies whether the traffic layer is currently enabled. This depends on the availability of traffic data at the current location.

Returns
  • true if the traffic layer is enabled and false otherwise.

public final void moveCamera (CameraUpdate update)

Immediately moves the map camera to the specified CameraUpdate destination. The CameraUpdate can set any or all of the camera properties (target, zoom level, bearing, and tilt).

Any active camera animation will be canceled.

Use the methods in CameraUpdateFactory to create the CameraUpdate.

Parameters
update A CameraUpdate object that defines the new camera properties to apply.
Throws
IllegalStateException if not called on the main thread.
NullPointerException if update is null.

public final void setBuildingsEnabled (boolean enabled)

Sets whether 3D buildings are displayed on the map.

Parameters
enabled true to turn 3D buildings on, or false to turn them off.

public final boolean setIndoorEnabled (boolean enabled)

Sets whether indoor maps are displayed.

Note that indoor buildings are not currently supported in the Amazon Maps API, so this returns false.

public final void setInfoWindowAdapter (AmazonMap.InfoWindowAdapter adapter)

Sets a custom adapter for displaying Marker info windows. An info window is displayed above a marker when the marker is clicked. If no adapter is set, the map uses the default info window, which displays the marker's title and optional snippet.

Implement the AmazonMap.InfoWindowAdapter interface to customize the marker info windows. You can customize the entire window or just the contents of the window.

Parameters
adapter The adapter to use for rendering marker info windows. Pass null to clear the adapter and use the default info window.

public final void setLocationSource (LocationSource source)

Sets a LocationSource for the "My Location" layer. This replaces the map's built-in location provider with the specified LocationSource.

Parameters
source The location source to set. Pass null to use the default location source.

public final void setMapType (int type)

Sets the map type to display. Supported values are:

The default type is MAP_TYPE_NORMAL.

Parameters
type The map type to display.

public final void setMyLocationEnabled (boolean enabled)

Enable or disable the "My Location" layer. When enabled, the user's location is displayed on the screen and the "Locate Me" button is shown if enabled. The "Locate Me" button can be enabled or disabled by calling setMyLocationButtonEnabled(boolean).

When setMyLocationEnabled is disabled, these UI elements are not shown.

Note: Your app must request location permissions to use the "My Location" layer:

  • android.permission.ACCESS_COARSE_LOCATION
  • android.permission.ACCESS_FINE_LOCATION

These permissions are only needed if you call setMyLocationEnabled() and pass true.

Parameters
enabled true to enable the "My Location" layer, or false to disable it.

public final void setOnCameraChangeListener (AmazonMap.OnCameraChangeListener listener)

Sets a listener to receive callbacks when the map camera changes position. Setting a new listener clears any previously-set listener.

Parameters
listener The listener to receive callbacks when the camera changes position. Set to null to clear the listener.

public final void setOnIndoorStateChangeListener (AmazonMap.OnIndoorStateChangeListener listener)

Sets a listener to receive callbacks for indoor maps state changes.

Note that indoor buildings are not supported in the Amazon Maps API, so this listener is never called.

Parameters
listener The listener to receive callbacks for indoor map state changes. Set to null to clear the listener. Since indoor maps are not currently supported, this listener is never called.

public final void setOnInfoWindowClickListener (AmazonMap.OnInfoWindowClickListener listener)

Sets a listener to receive callbacks when the user clicks on a Marker's info window. Setting a new listener clears any previously-set listener. If no listener is set, clicking a marker's info window briefly highlights the window.

Parameters
listener The listener to receive callbacks for info window clicks. Set to null to clear the listener.

public final void setOnMapClickListener (AmazonMap.OnMapClickListener listener)

Sets a listener to receive callbacks when the user clicks on the map. Setting a listener clears any previously-set listener. If no listener is set, clicking on the map does nothing.

Parameters
listener The listener to receive callbacks for map clicks. Set to null to clear the listener.

public void setOnMapLoadedCallback (AmazonMap.OnMapLoadedCallback callback)

Sets a callback to receive notifications after all map tiles are fetched and rendered.

If the map is already rendered when setOnMapLoadedCallback() is called, the callback is invoked immediately.

Note that the callback does not fire if:

  • The map cannot load due to connectivity
  • The map keeps changing due to animations or user interactions.

Setting a callback clears any previously-set callback.

Map loaded callbacks are not supported in the Amazon Maps API v2.5 and hence the callback will never be invoked.

Parameters
callback The callback to invoke after the map is rendered. Set to null to clear the callback.

public final void setOnMapLongClickListener (AmazonMap.OnMapLongClickListener listener)

Sets a listener to receive callbacks when the user performs a long click on the map. Setting a new listener clears any previously-set listener. If no listener is set, performing a long-click on the map does nothing.

Parameters
listener The listener to receive callbacks for long map clicks. Set to null to clear the listener.

public final void setOnMarkerClickListener (AmazonMap.OnMarkerClickListener listener)

Sets a listener to receive callbacks when the user clicks on a Marker. Setting a new listener clears any previously-set listener. If no listener is set, clicking a marker does the following default behavior:

  • Centers the map camera on the marker.
  • Displays an info window for the marker if the marker has a title defined. See setTitle(String).
  • Displays the Map Toolbar with buttons to open the Amazon Maps app if isMapToolbarEnabled() is true.

The listener can return true to block the default behavior or false to allow the default behavior.

Parameters
listener The listener to receive callbacks for marker clicks. Set to null to clear the listener and use the default behavior instead.

public final void setOnMarkerDragListener (AmazonMap.OnMarkerDragListener listener)

Sets a listener to receive callbacks when a marker is dragged. Setting a new listener clears any previously-set listener.

Note that draggable markers are not currently supported in the Amazon Maps API, so this listener is never called.

Parameters
listener The listener to receive callbacks when markers are dragged. Set to null to clear the listener. Since draggable markers are not currently supported, this listener is never called.

public final void setOnMyLocationButtonClickListener (AmazonMap.OnMyLocationButtonClickListener listener)

Sets a listener to receive callbacks when the user clicks the "Locate Me" button. Setting a new listener clears any previously-set listener. If no listener is set, clicking the button triggers the default behavior of animating the map camera to the user's current location and zooming in.

The listener can return true to block the default behavior or false to allow the default behavior.

Parameters
listener The listener to receive callbacks when the "Locate Me" button is clicked. Set to null to clear the listener.

public final void setOnMyLocationChangeListener (AmazonMap.OnMyLocationChangeListener listener)

This method is deprecated.
Use standard Android location APIs instead. See the Location Strategies API guide for details.

Sets a listener to receive callbacks when the user's location changes. Setting a new listener clears any previously-set listener.

Parameters
listener The listener to receive callbacks. Set to null to clear the listener.

public final void setPadding (int left, int top, int right, int bottom)

Sets the number of pixels to offset all map controls, indicators, attribution text, and any other fixed views in from the edge of the map fragment or map view's bounding box. All camera movements are also relative to the center of the padded area. By default these views are positioned in by a predetermined amount so supplying a padding value is not required.

Parameters
left Padding in pixels from the left of the map.
top Padding in pixels from the top of the map.
right Padding in pixels from the right of the map.
bottom Padding in pixels from the bottom of the map.

public final void setTrafficEnabled (boolean enabled)

Enables or disables the traffic layer.

Parameters
enabled true to enable the traffic layer, or false to disable it.

public final void snapshot (AmazonMap.SnapshotReadyCallback callback)

Takes a snapshot of the map. You can retrieve the snapshot taken from the onSnapshotReady(Bitmap) method, which is called when the snapshot is available.

Parameters
callback The callback to receive notification when the snapshot is available. The bitmap provided to the callback may be null if the snapshot failed.

public final void snapshot (AmazonMap.SnapshotReadyCallback callback, Bitmap bitmap)

Takes a snapshot of the map and returns it in a pre-allocated Bitmap passed to the method. You can also retrieve the snapshot from the onSnapshotReady(Bitmap) method, which is called when the snapshot is available.

If the snapshot is successful and the Bitmap you pass to this method has the same dimensions as the map, then the Bitmap passed to this method and the Bitmap available from onSnapshotReady(Bitmap) will be identical.

If the snapshot fails, or if the Bitmap you pass to this method does not have the same dimensions as the map, then the Bitmap passed to this method and the Bitmap available from onSnapshotReady(Bitmap) will be different.

Parameters
callback The callback to receive notification when the snapshot is available.
bitmap An optional preallocated Bitmap to populate with the snapshot. This Bitmap is not used if the dimensions do not match the map. The Bitmap provided to the callback may be a different object and can be null if the snapshot failed.

public final void stopAnimation ()

Stops any active map camera animation.

Camera animations are not supported in the Amazon Maps API v2.5.