Mapbox Map
The general class to interact with in the Mapbox Maps SDK for Android. It exposes the entry point for all methods related to the Map object. You cannot instantiate MapboxMap object directly, rather, you must obtain one from the getMapboxMap() method MapView that you have added to your application.
Note: Similar to a View object, a MapboxMap should only be read and modified from the main thread.
Types
Functions
Add a listener that's going to be invoked whenever map camera changes.
Add a listener that's going to be invoked whenever map has entered the idle state.
Add a listener that's going to be invoked whenever the Map's style has been fully loaded, and the Map has rendered all visible tiles.
Add a listener that's going to be invoked whenever there's a map load error.
Add a listener that's going to be invoked whenever the Map finished rendering a frame.
Add a listener that's going to be invoked whenever the Map started rendering a frame.
Add a listener that's going to be invoked whenever a source has been added with StyleManager#addStyleSource runtime API.
Add a listener that's going to be invoked whenever the source data has been loaded.
Add a listener that's going to be invoked whenever a source has been removed with StyleManager#removeStyleSource runtime API.
Add a listener that's going to be invoked whenever the requested style data been loaded. The 'type' property defines what kind of style data has been loaded.
Add a listener that's going to be invoked whenever a style has a missing image.
Add a listener that's going to be invoked whenever an image added to the Style is no longer needed and can be removed using StyleManager#removeStyleImage method.
Add a listener that's going to be invoked whenever the requested style has been fully loaded, including the style specified sprite and sources.
Call extension function on CameraAnimationsPlugin. In most cases should not be called directly.
Convert the given bounds, boundsPadding, bearing and pitch values to CameraOptions. Note that this method takes into account the current map padding in addition to the boundsPadding provided in parameters.
Convenience method that adjusts the provided CameraOptions object for given parameters.
Convenience method that returns the CameraOptions object for given parameters. This method takes into account the current map padding in addition to the padding provided in parameters.
Convenience method that returns the CameraOptions object for given parameters.
Calculates a target point where the camera should move after dragging from a screen coordinate startCoordinate
to another coordinate endCoordinate
.
Convert the given geometry, geometryPadding, bearing and pitch values to CameraOptions. Note that this method takes into account the current map padding in addition to the geometryPadding provided in parameters.
Returns the CoordinateBounds for a given camera.
Returns the CoordinateBounds for a given camera.
Returns the CoordinateBounds for given RectF defined in screen points.
Returns the coordinate bounds and zoom for a given camera.
Returns the unwrapped coordinate bounds and zoom for a given camera.
Calculate a geographical coordinate(i.e., longitude-latitude pair) that corresponds to a screen coordinate.
Calculate a longitude-latitude pair for a Spherical Mercator projected meters.
Calculates the geographical coordinate information that corresponds to a given screen coordinate.
Calculate geographical coordinates(i.e., longitude-latitude pair) that corresponds to screen coordinates.
Calculates the geographical coordinates information that corresponds to the given screen coordinates.
In some cases querying source / render features is expected to be a blocking operation e.g. performing this action on map click. In this case in order to avoid deadlock on main thread querying could be performed on render thread and in that case querying result will be also delivered on render thread not leading to the main thread deadlock. Example:
Call extension function on GesturesPlugin. In most cases should not be called directly.
Returns attributions for the data used by the Map's style.
Get the map bounds options.
Returns the map's MapCenterAltitudeMode.
Get debug options
Get elevation for given coordinate. Value is available only for the visible region on the screen, if terrain (DEM) tile is available.
Get the state map of a feature within a style source.
Get the map's current free camera options. After mutation, it should be set back to the map.
Returns the children (original points or clusters) of a cluster (on the next zoom level) given its id (cluster_id value from feature properties) from a GeoJsonSource.
Returns the zoom on which the cluster expands into several children (useful for "click to zoom" feature) given the cluster's cluster_id (cluster_id value from feature properties) from a GeoJsonSource.
Returns all the leaves (original points) of a cluster (given its cluster_id) from a GeoJsonSource, with pagination support: limit is the number of leaves to return (set to Infinity for all points), and offset is the amount of points to skip (for pagination).
Get map options.
Calculate distance spanned by one pixel at the specified latitude at current zoom level.
Calculate distance spanned by one pixel at the specified latitude and zoom level.
Get the prefetch zoom delta
Returns whether multiple copies of the world are being rendered side by side beyond -180 and 180 degrees longitude.
Returns if a gesture is in progress.
Returns if user animation is currently in progress.
Loads the new map style built from the specified style DSL block. For example:
Loads the new map style either from a specified URI or from a JSON both represented as String.
Legacy method to load style, please refer to deprecation message for more details.
Legacy method to load style, please refer to deprecation message for more details.
Legacy method to load style, please refer to deprecation message for more details.
Calculate a screen coordinate that corresponds to a geographical coordinate (i.e., longitude-latitude pair).
Calculate screen coordinates that corresponds to geographical coordinates (i.e., longitude-latitude pair).
Calculate a point on the map in Mercator Projection for a given coordinate at the specified zoom scale.
Calculate Spherical Mercator ProjectedMeters coordinates.
Queries the map for rendered features.
Queries the map for source features.
Reduce memory use. Useful to call when the application gets paused or sent to background.
Removes entries from a feature state object.
Remove the camera change listener.
Remove the map idle listener.
Remove the map loaded listener.
Remove the map error listener.
Remove the render frame finished listener.
Remove the render frame started listener.
Remove the source added listener.
Remove the source data loaded listener.
Remove the source removed listener.
Remove the style data loaded listener
Remove the style image missing listener.
Remove the style image unused listener.
Remove the style loaded listener.
Reset all the feature states within a style source.
Changes the map view by any combination of center, zoom, bearing, and pitch, without an animated transition. The map will retain its current values for any details not passed via the camera options argument. It is not guaranteed that the provided CameraOptions will be set, the map may apply constraints resulting in a different CameraState.
Sets the map view with the free camera options.
Sets the map MapCenterAltitudeMode that defines behavior of the center point altitude for all subsequent camera manipulations.
Set the map constrain mode
Set debug options
Updates the state object of a feature within a style source.
Tells the map rendering engine that there is currently a gesture in progress. This affects how the map renders labels, as it will use different texture filters if a gesture is ongoing.
Set the map north orientation
Set the prefetch zoom delta
Sets whether multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If disabled, when the map is zoomed out far enough that a single representation of the world does not fill the map's entire container, there will be blank space beyond 180 and -180 degrees longitude. In this case, features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the map and the other on the left edge of the map) at every zoom level.
The tile cache budget hint to be used by the map. The budget can be given in tile units or in megabytes. A Map will do the best effort to keep memory allocations for a non essential resources within the budget.
Tells the map rendering engine that the animation is currently performed by the user (e.g. with a setCamera()
calls series). It adjusts the engine for the animation use case. In particular, it brings more stability to symbol placement and rendering.
Set the map viewport mode
Enable real-time collection of map rendering performance statistics, for development purposes. Use after render()
has been called for the first time.
Disable performance statistics collection.
Subscribes to CameraChanged
event.
Subscribes to an experimental GenericEvent
event.
Subscribes to MapIdle
event.
Subscribes to MapLoaded
event.
Subscribes to MapLoadingError
event.
Subscribes to RenderFrameFinished
event.
Subscribes to RenderFrameStarted
event.
Subscribes to ResourceRequest
event.
Subscribes to SourceAdded
event.
Subscribes to SourceDataLoaded
event.
Subscribes to SourceRemoved
event.
Subscribes to StyleDataLoaded
event.
Subscribes to StyleImageMissing
event.
Subscribes to StyleImageRemoveUnused
event.
Subscribes to StyleLoaded
event.
Returns tileIDs that cover current map camera
Triggers a repaint of the map.
Calculate a coordinate for a given point on the map in Mercator Projection.
Properties
Extensions
Extension function to add an image provided by the Style Extension to the Style.
Extension function to add 9-patch image provided by the Style Extension to the Style.
Adds an 9-patch image to be used in the style. X-stretches, Y-stretches and padding will be calculated from Bitmap.getNinePatchChunk.
Extension function to add a Layer provided by the Style Extension to the Style.
Extension function to add a Layer provided by the Style Extension to the Style.
Extension function to add a Layer provided by the Style Extension to the Style.
Extension function to add a Layer provided by the Style Extension to the Style.
Extension function to add a model provided by the Style Extension to the Style.
Add a callback that is invoked when the map is has received a fling gesture. Gesture plugin with id = Plugin.MAPBOX_GESTURES_PLUGIN_ID must be added while constructing MapView
as part of MapInitOptions.plugins
.
Add a callback that is invoked when the map is clicked. Gesture plugin with id = Plugin.MAPBOX_GESTURES_PLUGIN_ID must be added while constructing MapView
as part of MapInitOptions.plugins
.
Add a callback that is invoked when the map is long clicked. Gesture plugin with id = Plugin.MAPBOX_GESTURES_PLUGIN_ID must be added while constructing MapView
as part of MapInitOptions.plugins
.
Add a callback that is invoked when the map is moved. Gesture plugin with id = Plugin.MAPBOX_GESTURES_PLUGIN_ID must be added while constructing MapView
as part of MapInitOptions.plugins
.
Add a callback that is invoked when the map is rotated. Gesture plugin with id = Plugin.MAPBOX_GESTURES_PLUGIN_ID must be added while constructing MapView
as part of MapInitOptions.plugins
.
Add a callback that is invoked when the map is scaled. Gesture plugin with id = Plugin.MAPBOX_GESTURES_PLUGIN_ID must be added while constructing MapView
as part of MapInitOptions.plugins
.
Add a callback that is invoked when the map is shoved. Gesture plugin with id = Plugin.MAPBOX_GESTURES_PLUGIN_ID must be added while constructing MapView
as part of MapInitOptions.plugins
.
Add layer to the style persistently.
Extension function to add a Source provided by the Style Extension to the Style.
Convenience method that returns the CameraOptions object for given parameters.
Load a new style from a style extension, suspends until style is loaded.
Load a new style from a style URI or JSON, suspends until style is loaded.
Get the Style of the map.
Flow of CameraChanged updates from MapboxMap.subscribeCameraChanged.
Convenience method that returns the CameraOptions object for given parameters.
Extension easeTo() for MapPluginExtensionsDelegate Ease the map camera to a given camera options and animation options
Extension flyTo() function for MapPluginExtensionsDelegate Fly the map camera to a given camera options.
Flow of GenericEvent updates from MapboxMap.subscribeGenericEvent.
Extension function to get the atmosphere provided by the Style Extension.
Returns the children (original points or clusters) of a cluster (on the next zoom level) given its id (cluster_id value from feature properties) from a GeoJsonSource.
Returns the zoom on which the cluster expands into several children (useful for "click to zoom" feature) given the cluster's cluster_id (cluster_id value from feature properties) from a GeoJsonSource.
Returns all the leaves (original points) of a cluster (given its cluster_id) from a GeoJsonSource, with pagination support: limit is the number of leaves to return (set to Infinity for all points), and offset is the amount of points to skip (for pagination).
Get the current configured AndroidGesturesManager. Gesture plugin with id = Plugin.MAPBOX_GESTURES_PLUGIN_ID must be added while constructing MapView
as part of MapInitOptions.plugins
.
Extension function to get a Layer provided by the Style Extension by layer id.
Tries to cast the Layer to T.
Extension function to get 3D Light that has been applied to the style.
Extension function to get the projection provided by the Style Extension.
Extension function to get a Source provided by the Style Extension by source id.
Tries to cast the Source to T.
Extension function to get the terrain provided by the Style Extension.
Extension function to localize style labels
Flow of MapIdle updates from MapboxMap.subscribeMapIdle.
Flow of MapLoaded updates from MapboxMap.subscribeMapLoaded.
Flow of MapLoadingError updates from MapboxMap.subscribeMapLoadingError.
Extension moveBy() function for MapPluginExtensionsDelegate Move the map by a given screen coordinate with optional animation.
Extension pitchBy() function for MapPluginExtensionsDelegate Pitch the map by with optional animation.
Queries the map for rendered features.
Queries the map for source features.
Removes atmosphere from style if it was set.
Remove a callback that is invoked when the map is has received a fling gesture. Gesture plugin with id = Plugin.MAPBOX_GESTURES_PLUGIN_ID must be added while constructing MapView
as part of MapInitOptions.plugins
.
Remove a callback that is invoked when the map is clicked. Gesture plugin with id = Plugin.MAPBOX_GESTURES_PLUGIN_ID must be added while constructing MapView
as part of MapInitOptions.plugins
.
Remove a callback that is invoked when the map is long clicked. Gesture plugin with id = Plugin.MAPBOX_GESTURES_PLUGIN_ID must be added while constructing MapView
as part of MapInitOptions.plugins
.
Remove a callback that is invoked when the map is moved. Gesture plugin with id = Plugin.MAPBOX_GESTURES_PLUGIN_ID must be added while constructing MapView
as part of MapInitOptions.plugins
.
Remove a callback that is invoked when the map is rotated. Gesture plugin with id = Plugin.MAPBOX_GESTURES_PLUGIN_ID must be added while constructing MapView
as part of MapInitOptions.plugins
.
Remove a callback that is invoked when the map is scaled. Gesture plugin with id = Plugin.MAPBOX_GESTURES_PLUGIN_ID must be added while constructing MapView
as part of MapInitOptions.plugins
.
Remove a callback that is invoked when the map is shoved. Gesture plugin with id = Plugin.MAPBOX_GESTURES_PLUGIN_ID must be added while constructing MapView
as part of MapInitOptions.plugins
.
Removes terrain from style if it was set.
Flow of RenderFrameFinished updates from MapboxMap.subscribeRenderFrameFinished.
Flow of RenderFrameStarted updates from MapboxMap.subscribeRenderFrameStarted.
Flow of ResourceRequest updates from MapboxMap.subscribeResourceRequest.
Extension rotateBy() function for MapPluginExtensionsDelegate Rotate the map by with optional animation.
Extension scaleBy() function for MapPluginExtensionsDelegate Scale the map by with optional animation.
Extension function to set the Atmosphere provided by the Style Extension to the Style.
Set the AndroidGesturesManager instance. Gesture plugin with id = Plugin.MAPBOX_GESTURES_PLUGIN_ID must be added while constructing MapView
as part of MapInitOptions.plugins
.
Extension function to add dynamic light to the Style. dynamic light is built from AmbientLight and DirectionalLight.
Extension function to add the FlatLight to the Style.
Extension function to add list of lights.
Extension function to set the Projection provided by the Style Extension to the Style.
Extension function to set the Terrain provided by the Style Extension to the Style.
Flow of SourceAdded updates from MapboxMap.subscribeSourceAdded.
Flow of SourceDataLoaded updates from MapboxMap.subscribeSourceDataLoaded.
Flow of SourceRemoved updates from MapboxMap.subscribeSourceRemoved.
Flow of StyleDataLoaded updates from MapboxMap.subscribeStyleDataLoaded.
Flow of StyleImageMissing updates from MapboxMap.subscribeStyleImageMissing.
Flow of StyleImageRemoveUnused updates from MapboxMap.subscribeStyleImageRemoveUnused.
Flow of StyleLoaded updates from MapboxMap.subscribeStyleLoaded.