java.lang.Object | |
↳ | com.amazon.geo.mapsv2.AmazonMap |
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.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
AmazonMap.CancelableCallback | Interface for receiving notifications when a task is cancelled or completed. | ||||||||||
AmazonMap.InfoWindowAdapter | Interface for displaying Marker info windows. |
||||||||||
AmazonMap.OnCameraChangeListener | Interface for receiving callbacks when the map camera changes position. | ||||||||||
AmazonMap.OnIndoorStateChangeListener | Interface for receiving notifications when indoor maps change state. | ||||||||||
AmazonMap.OnInfoWindowClickListener | Interface for receiving callbacks when a user clicks the info window
for a Marker . |
||||||||||
AmazonMap.OnMapClickListener | Interface for receiving callbacks when the map is clicked. | ||||||||||
AmazonMap.OnMapLoadedCallback | Interface for receiving callbacks when the map finishes loading. | ||||||||||
AmazonMap.OnMapLongClickListener | Interface for receiving callbacks when the user performs a long click on the map. | ||||||||||
AmazonMap.OnMarkerClickListener | Interface for receiving callbacks when the user clicks a Marker . |
||||||||||
AmazonMap.OnMarkerDragListener | Interface for receiving callbacks when the user drags a marker. | ||||||||||
AmazonMap.OnMyLocationButtonClickListener | Interface for receiving callbacks when the user clicks the "Locate Me" button. | ||||||||||
AmazonMap.OnMyLocationChangeListener | This interface is deprecated. Use standard Android location APIs instead. See the Location Strategies API guide for details. | ||||||||||
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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds a
Circle to the map. | |||||||||||
This is not yet implemented and will throw an
UnsupportedOperationException when called.
| |||||||||||
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. | |||||||||||
Adds a
Polygon to the map. | |||||||||||
Adds a
Polyline to the map. | |||||||||||
Adds a
TileOverlay to the map.
Only | |||||||||||
Animates the map camera to the specified Camera animations are not supported in the Amazon Maps API v2.5 | |||||||||||
Animates the map camera to the specified Camera animations are not supported in the Amazon Maps API v2.5. | |||||||||||
Animates the map camera to the specified Camera animations are not supported in the Amazon Maps API v2.5. | |||||||||||
Removes all added objects from the map.
| |||||||||||
Gets a
CameraPosition representing a snapshot of the current position
of the map camera. | |||||||||||
Gets the focused building with indoor maps.
| |||||||||||
Gets the currently displayed map type.
| |||||||||||
Gets the maximum zoom level for the camera at the current position.
| |||||||||||
Gets the minimum zoom level for the camera at the current position.
| |||||||||||
This method is deprecated.
Use standard Android location APIs instead. See the Location Strategies API guide for details.
| |||||||||||
Gets a
Projection object that can be used to convert between
latitude/longitude and screen coordinates. | |||||||||||
Gets a
UiSettings object representing the user interface settings
currently in use. | |||||||||||
Retrieves a boolean value that specifies whether buildings are enabled.
| |||||||||||
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. | |||||||||||
Retrieves a boolean value that specifies whether the "My Location" layer
is currently enabled.
| |||||||||||
Retrieves a boolean value that specifies whether the traffic layer is
currently enabled.
| |||||||||||
Immediately moves the map camera to the specified
CameraUpdate destination. | |||||||||||
Sets whether 3D buildings are displayed on the map.
| |||||||||||
Sets whether indoor maps are displayed.
Note that indoor buildings are not currently supported in the Amazon Maps API, so this returns false. | |||||||||||
Sets a custom adapter for displaying
Marker info
windows. | |||||||||||
Sets a
LocationSource for the "My Location" layer. | |||||||||||
Sets the map type to display.
| |||||||||||
Enable or disable the "My Location" layer.
| |||||||||||
Sets a listener to receive callbacks when the map camera changes position.
| |||||||||||
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. | |||||||||||
Sets a listener to receive callbacks when the user clicks on a
Marker 's
info window. | |||||||||||
Sets a listener to receive callbacks when the user clicks on the map.
| |||||||||||
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. | |||||||||||
Sets a listener to receive callbacks when the user performs a long click
on the map.
| |||||||||||
Sets a listener to receive callbacks when the user clicks on a
Marker . | |||||||||||
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. | |||||||||||
Sets a listener to receive callbacks when the user clicks the "Locate Me"
button.
| |||||||||||
This method is deprecated.
Use standard Android location APIs instead. See the Location Strategies API guide for details.
| |||||||||||
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.
| |||||||||||
Enables or disables the traffic layer.
| |||||||||||
Takes a snapshot of the map.
| |||||||||||
Takes a snapshot of the map and returns it in a pre-allocated
Bitmap passed to the method. | |||||||||||
Stops any active map camera animation. Camera animations are not supported in the Amazon Maps API v2.5. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Display satellite tiles with labels and translucent road overlays.
Display no map tiles.
Display base map tiles.
Display satellite tiles with no roads or labels.
Display terrain tiles with labels and white road overlays. Not supported in Amazon Maps API v2.5.
Adds a Circle
to the map. See Circle
and
CircleOptions
for details on creating a valid circle and the
available properties.
options | A CircleOptions object that defines how to draw
the circle. Must not be null . |
---|
Circle
that was added to the map.IllegalArgumentException | if getRadius() or
getStrokeWidth() is negative.
|
---|
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.
options | The options specified to draw the ground overlay |
---|
GroundOverlay
that was added to the map
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.
options | A MarkerOptions object that defines how to draw
the marker. Must not be null . |
---|
Marker
that was added to the map.
Adds a Polygon
to the map. See Polygon
and
PolygonOptions
for details on creating a valid polygon and the
available properties.
options | A PolygonOptions object that defines how to draw
the polygon. Must not be null . |
---|
Polygon
that was added to the map.IllegalArgumentException | if
getStrokeWidth() is negative.
|
---|
Adds a Polyline
to the map. See Polyline
and
PolylineOptions
for details on creating a valid polyline and the
available properties.
options | A PolylineOptions object that defines how to draw
the Polyline. Must not be null . |
---|
Polyline
that was added to the map.IllegalArgumentException | if getWidth() is
negative.
|
---|
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.
options | A TileOverlayOptions object that defines how to
draw the tile overlay. Must not be null . |
---|
TileOverlay
that was added to the map.IllegalArgumentException | if the TileProvider has not been
set in the options.
|
---|
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.
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. |
IllegalStateException | if called off of the main thread. |
---|
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.
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. |
IllegalArgumentException | if durationMs is not positive. |
---|---|
IllegalStateException | if called off of the main thread. |
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.
update | A CameraUpdate object that defines the new
camera properties to apply. |
---|
IllegalStateException | if called off of the main thread. |
---|
Removes all added objects from the map.
Gets a CameraPosition
representing a snapshot of the current position
of the map camera.
CameraPosition
object representing the current position
of the map camera.
Gets the focused building with indoor maps.
This functionality is not currently supported.
Gets the currently displayed map type.
MAP_TYPE_NONE
, MAP_TYPE_NORMAL
,
MAP_TYPE_HYBRID
, MAP_TYPE_TERRAIN
, or MAP_TYPE_SATELLITE
).
Gets the maximum zoom level for the camera at the current position.
Gets the minimum zoom level for the camera at the current position.
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.
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.
Projection
object representing a snapshot of the projection.
Gets a UiSettings
object representing the user interface settings
currently in use. The returned UiSettings
object can be used change
map UI settings.
UiSettings
currently in use.
Retrieves a boolean value that specifies whether buildings are enabled.
true
if buildings are enabled, false
otherwise.
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
.
Retrieves a boolean value that specifies whether the "My Location" layer is currently enabled.
true
if the "My Location" layer is enabled, false
otherwise.
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.
true
if the traffic layer is enabled and false
otherwise.
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
.
update | A CameraUpdate object that defines the new
camera properties to apply. |
---|
IllegalStateException | if not called on the main thread. |
---|---|
NullPointerException | if update is null .
|
Sets whether 3D buildings are displayed on the map.
enabled | true to turn 3D buildings on, or false to
turn them off.
|
---|
Sets whether indoor maps are displayed.
Note that indoor buildings are not currently supported in the Amazon Maps API, so this returns false.
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.
adapter | The adapter to use for rendering marker info
windows. Pass null to clear the adapter and use the
default info window.
|
---|
Sets a LocationSource
for the "My Location" layer. This replaces
the map's built-in location provider with the specified LocationSource
.
source | The location source to set. Pass null to
use the default location source.
|
---|
type | The map type to display. |
---|
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
.
enabled | true to enable the "My Location" layer, or
false to disable it.
|
---|
Sets a listener to receive callbacks when the map camera changes position. Setting a new listener clears any previously-set listener.
listener | The listener to receive callbacks when the camera
changes position. Set to null to clear the 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.
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.
|
---|
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.
listener | The listener to receive callbacks for info window
clicks. Set to null to clear the 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.
listener | The listener to receive callbacks for map clicks. Set to
null to clear the listener.
|
---|
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:
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.
callback | The callback to invoke after the map is rendered.
Set to null to clear the callback.
|
---|
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.
listener | The listener to receive callbacks for long map clicks.
Set to null to clear the 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:
setTitle(String)
.
isMapToolbarEnabled()
is true
.
The listener can return true
to block the default behavior or
false
to allow the default behavior.
listener | The listener to receive callbacks for marker clicks. Set
to null to clear the listener and use the default
behavior instead.
|
---|
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.
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.
|
---|
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.
listener | The listener to receive callbacks when the "Locate Me"
button is clicked. Set to null to clear the 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.
listener | The listener to receive callbacks. Set to
null to clear the listener. |
---|
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.
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. |
Enables or disables the traffic layer.
enabled | true to enable the traffic layer, or false to disable it.
|
---|
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.
callback | The callback to receive notification when the snapshot is available. The bitmap provided to the callback may be null if the snapshot failed. |
---|
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.
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.
|
Stops any active map camera animation.
Camera animations are not supported in the Amazon Maps API v2.5.