Navigation SDK is currently available only to select customers. Contact sales to learn more.

GoogleMapOptions

public final class GoogleMapOptions extends AbstractSafeParcelable
implements ReflectedParcelable

Defines configuration GoogleMapOptions for a GoogleMap. These options can be used when adding a map to your application programmatically (as opposed to via XML). If you are using a MapFragment, you can pass these options in using the static factory method MapFragment.newInstance(GoogleMapOptions). If you are using a MapView, you can pass these options in using the constructor MapView.MapView(Context, GoogleMapOptions).

If you add a map using XML, then you can apply these options using custom XML tags.

Inherited Constant Summary

Public Constructor Summary

GoogleMapOptions()
Creates a new GoogleMapOptions object.

Public Method Summary

GoogleMapOptions
camera(CameraPosition camera)
Specifies a the initial camera position for the map.
GoogleMapOptions
compassEnabled(boolean enabled)
Specifies whether the compass should be enabled.
static GoogleMapOptions
createFromAttributes(Context context, AttributeSet attrs)
Creates a GoogleMapsOptions from the AttributeSet.
CameraPosition
Boolean
LatLngBounds
Boolean
int
Float
Float
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
GoogleMapOptions
latLngBoundsForCameraTarget(LatLngBounds llbounds)
Specifies a LatLngBounds to constrain the camera target, so that when users scroll and pan the map, the camera target does not move outside these bounds.
GoogleMapOptions
mapId(String mapId)
Specifies the map's ID.
GoogleMapOptions
mapToolbarEnabled(boolean enabled)
Specifies whether the mapToolbar should be enabled.
GoogleMapOptions
mapType(int mapType)
Specifies a change to the initial map type.
GoogleMapOptions
maxZoomPreference(float maxZoomPreference)
Specifies a preferred upper bound for camera zoom.
GoogleMapOptions
minZoomPreference(float minZoomPreference)
Specifies a preferred lower bound for camera zoom.
GoogleMapOptions
rotateGesturesEnabled(boolean enabled)
Specifies whether rotate gestures should be enabled.
GoogleMapOptions
scrollGesturesEnabled(boolean enabled)
Specifies whether scroll gestures should be enabled.
GoogleMapOptions
scrollGesturesEnabledDuringRotateOrZoom(boolean enabled)
Specifies whether scroll gestures should be enabled during rotate and zoom gestures.
GoogleMapOptions
tiltGesturesEnabled(boolean enabled)
Specifies whether tilt gestures should be enabled.
String
GoogleMapOptions
useViewLifecycleInFragment(boolean useViewLifecycleInFragment)
When using a MapFragment, this flag specifies whether the lifecycle of the map should be tied to the fragment's view or the fragment itself.
GoogleMapOptions
zoomControlsEnabled(boolean enabled)
Specifies whether the zoom controls should be enabled.
GoogleMapOptions
zoomGesturesEnabled(boolean enabled)
Specifies whether zoom gestures should be enabled.

Inherited Method Summary

Public Constructors

public GoogleMapOptions ()

Creates a new GoogleMapOptions object.

Public Methods

public GoogleMapOptions camera (CameraPosition camera)

Specifies a the initial camera position for the map.

Parameters
camera

public GoogleMapOptions compassEnabled (boolean enabled)

Specifies whether the compass should be enabled. See UiSettings.setCompassEnabled(boolean) for more details. The default value is true.

Parameters
enabled

public static GoogleMapOptions createFromAttributes (Context context, AttributeSet attrs)

Creates a GoogleMapsOptions from the AttributeSet.

Parameters
context
attrs

public CameraPosition getCamera ()

Returns
  • the camera option, or null if unspecified.

public Boolean getCompassEnabled ()

Returns
  • the compassEnabled option, or null if unspecified.

public LatLngBounds getLatLngBoundsForCameraTarget ()

Returns
  • the LatLngBounds used to constrain the camera target, or null if unspecified.

public Boolean getMapToolbarEnabled ()

Returns
  • the mapToolbarEnabled option, or null if unspecified.

public int getMapType ()

Returns
  • the mapType option, or -1 if unspecified.

public Float getMaxZoomPreference ()

Returns
  • the maximum zoom level preference, or null if unspecified.

public Float getMinZoomPreference ()

Returns
  • the minimum zoom level preference, or null if unspecified.

public Boolean getRotateGesturesEnabled ()

Returns
  • the rotateGesturesEnabled option, or null if unspecified.

public Boolean getScrollGesturesEnabled ()

Returns
  • the scrollGesturesEnabled option, or null if unspecified.

public Boolean getScrollGesturesEnabledDuringRotateOrZoom ()

Returns
  • the scrollGesturesEnabledDuringRotateOrZoom option, or null if unspecified.

public Boolean getTiltGesturesEnabled ()

Returns
  • the tiltGesturesEnabled option, or null if unspecified.

public Boolean getUseViewLifecycleInFragment ()

Returns
  • the useViewLifecycleInFragment option, or null if unspecified.

public Boolean getZoomControlsEnabled ()

Returns
  • the zoomControlsEnabled option, or null if unspecified.

public Boolean getZoomGesturesEnabled ()

Returns
  • the zoomGesturesEnabled option, or null if unspecified.

public GoogleMapOptions latLngBoundsForCameraTarget (LatLngBounds llbounds)

Specifies a LatLngBounds to constrain the camera target, so that when users scroll and pan the map, the camera target does not move outside these bounds.

See GoogleMap.setLatLngBoundsForCameraTarget(LatLngBounds) for details.

Parameters
llbounds

public GoogleMapOptions mapId (String mapId)

Specifies the map's ID.

Parameters
mapId

public GoogleMapOptions mapToolbarEnabled (boolean enabled)

Specifies whether the mapToolbar should be enabled. See UiSettings.setMapToolbarEnabled(boolean) for more details. The default value is true.

Parameters
enabled

public GoogleMapOptions mapType (int mapType)

Specifies a change to the initial map type.

Parameters
mapType

public GoogleMapOptions maxZoomPreference (float maxZoomPreference)

Specifies a preferred upper bound for camera zoom.

See GoogleMap.setMaxZoomPreference(float) for details.

Parameters
maxZoomPreference

public GoogleMapOptions minZoomPreference (float minZoomPreference)

Specifies a preferred lower bound for camera zoom.

See GoogleMap.setMinZoomPreference(float) for details.

Parameters
minZoomPreference

public GoogleMapOptions rotateGesturesEnabled (boolean enabled)

Specifies whether rotate gestures should be enabled. See UiSettings.setRotateGesturesEnabled(boolean) for more details. The default value is true.

Parameters
enabled

public GoogleMapOptions scrollGesturesEnabled (boolean enabled)

Specifies whether scroll gestures should be enabled. See UiSettings.setScrollGesturesEnabled(boolean) for more details. The default value is true.

Parameters
enabled

public GoogleMapOptions scrollGesturesEnabledDuringRotateOrZoom (boolean enabled)

Specifies whether scroll gestures should be enabled during rotate and zoom gestures. See UiSettings.setScrollGesturesEnabledDuringRotateOrZoom(boolean) for more details. The default value is true.

Parameters
enabled

public GoogleMapOptions tiltGesturesEnabled (boolean enabled)

Specifies whether tilt gestures should be enabled. See UiSettings.setTiltGesturesEnabled(boolean) for more details. The default value is true.

Parameters
enabled

public String toString ()

public GoogleMapOptions useViewLifecycleInFragment (boolean useViewLifecycleInFragment)

When using a MapFragment, this flag specifies whether the lifecycle of the map should be tied to the fragment's view or the fragment itself. The default value is false, tying the lifecycle of the map to the fragment.

Using the lifecycle of the fragment allows faster rendering of the map when the fragment is detached and reattached, because the underlying GL context is preserved. This has the cost that detaching the fragment, but not destroying it, will not release memory used by the map.

Using the lifecycle of a fragment's view means that a map is not reused when the fragment is detached and reattached. This will cause the map to re-render from scratch, which can take a few seconds. It also means that while a fragment is detached, and therefore has no view, all GoogleMap methods will throw NullPointerException.

Parameters
useViewLifecycleInFragment

public GoogleMapOptions zoomControlsEnabled (boolean enabled)

Specifies whether the zoom controls should be enabled. See UiSettings.setZoomControlsEnabled(boolean) for more details. The default value is true.

Parameters
enabled

public GoogleMapOptions zoomGesturesEnabled (boolean enabled)

Specifies whether zoom gestures should be enabled. See UiSettings.setZoomGesturesEnabled(boolean) for more details. The default value is true.

Parameters
enabled