NavigationMap

public interface NavigationMap

Provides methods for modifying the contents of the navigation map, e.g. adding and removing markers.

All methods should be accessed on the Android UI thread only.

Nested Class Summary

interface NavigationMap.OnMapClickListener Callback interface for when the user taps on the map. 
interface NavigationMap.OnMarkerClickListener Defines signatures for methods that are called when a marker is clicked or tapped. 

Public Method Summary

abstract Marker
addMarker(MarkerOptions markerOptions)
Adds a single marker to the map.
abstract Projection
getProjection()
Returns a Projection object that you can use to convert between screen coordinates and latitude/longitude coordinates.
abstract void
removeAllMarkers()
Removes all the markers currently on the map.
abstract void
removeMarker(Marker marker)
Removes the specified marker from the map.
abstract void
setOnMapClickListener(NavigationMap.OnMapClickListener listener)
Sets a callback that's invoked when the map is tapped.
abstract void
setOnMarkerClickListener(NavigationMap.OnMarkerClickListener listener)
Sets a callback that's invoked when a marker is clicked.
abstract void
setPadding(int left, int top, int right, int bottom)
Sets the padding for the UI elements within the map area in px.
abstract void
setTrafficEnabled(boolean enabled)
Sets whether traffic information will be displayed.

Public Methods

public abstract Marker addMarker (MarkerOptions markerOptions)

Adds a single marker to the map.

Parameters
markerOptions the MarkerOptions which defines marker properties such as position. The options will be copied into the Marker and are safe to re-use.
Returns
  • an object representing the marker

public abstract Projection getProjection ()

Returns a Projection object that you can use to convert between screen coordinates and latitude/longitude coordinates.

The Projection returned is a snapshot of the current projection, and will not automatically update when the camera moves. As this operation is expensive, you should get the projection only once per screen. Google Maps uses the Mercator projection to create its maps from geographic data and convert points on the map into geographic coordinates.

Returns
  • The Projection of the map in its current state or null if the map has not been fully initialized.

public abstract void removeAllMarkers ()

Removes all the markers currently on the map.

public abstract void removeMarker (Marker marker)

Removes the specified marker from the map.

Parameters
marker the marker to remove

public abstract void setOnMapClickListener (NavigationMap.OnMapClickListener listener)

Sets a callback that's invoked when the map is tapped.

Parameters
listener The callback that's invoked when the map is tapped. To unset the callback, use null.

public abstract void setOnMarkerClickListener (NavigationMap.OnMarkerClickListener listener)

Sets a callback that's invoked when a marker is clicked.

Parameters
listener The callback that's invoked when a marker is clicked. To unset the callback, use null.

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

Sets the padding for the UI elements within the map area in px. This also affects the recentering behavior, causing the map to be recentered within the padded area.

Note: The top padding value only applies when the header is disabled (see setHeaderEnabled(boolean)), and the bottom padding only applies when the ETA card is disabled (see setEtaCardEnabled(boolean)). The left and right padding values apply at all times.

Parameters
left
top
right
bottom

public abstract void setTrafficEnabled (boolean enabled)

Sets whether traffic information will be displayed.

Parameters
enabled If true, traffic information will be displayed.