Map Libre Map
The general class to interact with in the Android MapLibre SDK. It exposes the entry point for all methods related to the MapView. You cannot instantiate MapLibreMap object directly, rather, you must obtain one from the getMapAsync() method on a MapFragment or MapView that you have added to your application.
Note: Similar to a View object, a MapLibreMap should only be read and modified from the main thread.
Types
Link copied to clipboard
interface CancelableCallback
Interface definition for a callback to be invoked when a task is complete or cancelled.
Link copied to clipboard
interface InfoWindowAdapter
Interface definition for a callback to be invoked when an info window will be shown.
Link copied to clipboard
interface OnCameraIdleListener
Interface definition for a callback to be invoked for when camera movement has ended.
Link copied to clipboard
interface OnCameraMoveCanceledListener
Interface definition for a callback to be invoked for when the camera's motion has been stopped or when the camera starts moving for a new reason.
Link copied to clipboard
interface OnCameraMoveListener
Interface definition for a callback to be invoked for when the camera changes position.
Link copied to clipboard
interface OnCameraMoveStartedListener
Interface definition for a callback to be invoked for when the camera motion starts.
Link copied to clipboard
interface OnCompassAnimationListener
Interface definition for a callback to be invoked for when the compass is animating.
Link copied to clipboard
interface OnDeveloperAnimationListener
Internal use.
Link copied to clipboard
interface OnFlingListener
Interface definition for a callback to be invoked when the map is flinged.
Link copied to clipboard
interface OnFpsChangedListener
Interface definition for a callback to be invoked when a frame is rendered to the map view.
Link copied to clipboard
interface OnInfoWindowClickListener
Interface definition for a callback to be invoked when the user clicks on an info window.
Link copied to clipboard
interface OnInfoWindowCloseListener
Interface definition for a callback to be invoked when a marker's info window is closed.
Link copied to clipboard
interface OnInfoWindowLongClickListener
Interface definition for a callback to be invoked when the user long presses on a marker's info window.
Link copied to clipboard
interface OnMapClickListener
Interface definition for a callback to be invoked when the user clicks on the map view.
Link copied to clipboard
interface OnMapLongClickListener
Interface definition for a callback to be invoked when the user long clicks on the map view.
Link copied to clipboard
interface OnMarkerClickListener
Interface definition for a callback to be invoked when the user clicks on a marker.
Link copied to clipboard
interface OnMoveListener
Interface definition for a callback to be invoked when the map is moved.
Link copied to clipboard
interface OnPolygonClickListener
Interface definition for a callback to be invoked when the user clicks on a polygon.
Link copied to clipboard
interface OnPolylineClickListener
Interface definition for a callback to be invoked when the user clicks on a polyline.
Link copied to clipboard
interface OnRotateListener
Interface definition for a callback to be invoked when the map is rotated.
Link copied to clipboard
interface OnScaleListener
Interface definition for a callback to be invoked when the map is scaled.
Link copied to clipboard
interface OnShoveListener
Interface definition for a callback to be invoked when the map is tilted.
Link copied to clipboard
interface SnapshotReadyCallback
Interface definition for a callback to be invoked when the snapshot has been taken.
Functions
Link copied to clipboard
Adds multiple markers to this map.
Link copied to clipboard
Adds a callback that is invoked when camera movement has ended.
Link copied to clipboard
Adds a callback that is invoked when camera movement was cancelled.
Link copied to clipboard
Adds a callback that is invoked when camera position changes.
Link copied to clipboard
Adds a callback that is invoked when camera movement has started.
Link copied to clipboard
Adds a callback that's invoked when the map is flinged.
Link copied to clipboard
Adds a callback that's invoked when the user clicks on the map view.
Link copied to clipboard
Adds a callback that's invoked when the user long clicks on the map view.
Link copied to clipboard
Adds a callback that's invoked when the map is moved.
Link copied to clipboard
Adds a callback that's invoked when the map is rotated.
Link copied to clipboard
Adds a callback that's invoked when the map is scaled.
Link copied to clipboard
Adds a callback that's invoked when the map is tilted.
Link copied to clipboard
Adds a polygon to this map.
Link copied to clipboard
Adds multiple polygons to this map.
Link copied to clipboard
Adds a polyline to this map.
Link copied to clipboard
Adds multiple polylines to this map.
Link copied to clipboard
fun animateCamera(@NonNull update: CameraUpdate, @Nullable callback: MapLibreMap.CancelableCallback)
fun animateCamera(@NonNull update: CameraUpdate, durationMs: Int, @Nullable callback: MapLibreMap.CancelableCallback)
Animate the camera to a new location defined within CameraUpdate using a transition animation that evokes powered flight.
Link copied to clipboard
Interrupts any ongoing gesture velocity animations.
Link copied to clipboard
Cancels ongoing animations.
Link copied to clipboard
Cycles through the map debug options.
Link copied to clipboard
Deselects a currently selected marker.
Link copied to clipboard
Deselects any currently selected marker.
Link copied to clipboard
Gradually move the camera by the default duration, zoom will not be affected unless specified within CameraUpdate.
fun easeCamera(@NonNull update: CameraUpdate, durationMs: Int, @Nullable callback: MapLibreMap.CancelableCallback)
fun easeCamera(@NonNull update: CameraUpdate, durationMs: Int, easingInterpolator: Boolean, @Nullable callback: MapLibreMap.CancelableCallback)
Gradually move the camera by a specified duration in milliseconds, zoom will not be affected unless specified within CameraUpdate.
Link copied to clipboard
Return a annotation based on its id.
Link copied to clipboard
Returns a list of all the annotations on the map.
Link copied to clipboard
Get a camera position that fits a provided shape.
open fun getCameraForGeometry(@NonNull geometry: Geometry, @NonNull @Size(value = 4 ) padding: Array<Int>): CameraPosition
Get a camera position that fits a provided shape and padding.
open fun getCameraForGeometry(@NonNull geometry: Geometry, @FloatRange(from = MapLibreConstants.MINIMUM_DIRECTION, to = MapLibreConstants.MAXIMUM_DIRECTION ) bearing: Double, @FloatRange(from = MapLibreConstants.MINIMUM_TILT, to = MapLibreConstants.MAXIMUM_TILT ) tilt: Double): CameraPosition
Get a camera position that fits a provided shape with a given bearing and tilt.
open fun getCameraForGeometry(@NonNull geometry: Geometry, @NonNull @Size(value = 4 ) padding: Array<Int>, @FloatRange(from = MapLibreConstants.MINIMUM_DIRECTION, to = MapLibreConstants.MAXIMUM_DIRECTION ) bearing: Double, @FloatRange(from = MapLibreConstants.MINIMUM_TILT, to = MapLibreConstants.MAXIMUM_TILT ) tilt: Double): CameraPosition
Get a camera position that fits a provided shape with a given padding, bearing and tilt.
Link copied to clipboard
Get a camera position that fits a provided bounds and the current camera tilt and bearing.
open fun getCameraForLatLngBounds(@NonNull latLngBounds: LatLngBounds, @NonNull @Size(value = 4 ) padding: Array<Int>): CameraPosition
Get a camera position that fits a provided bounds and padding and the current camera tilt and bearing.
open fun getCameraForLatLngBounds(@NonNull latLngBounds: LatLngBounds, @FloatRange(from = MapLibreConstants.MINIMUM_DIRECTION, to = MapLibreConstants.MAXIMUM_DIRECTION ) bearing: Double, @FloatRange(from = MapLibreConstants.MINIMUM_TILT, to = MapLibreConstants.MAXIMUM_TILT ) tilt: Double): CameraPosition
Get a camera position that fits a provided bounds, bearing and tilt.
open fun getCameraForLatLngBounds(@NonNull latLngBounds: LatLngBounds, @NonNull @Size(value = 4 ) padding: Array<Int>, @FloatRange(from = MapLibreConstants.MINIMUM_DIRECTION, to = MapLibreConstants.MAXIMUM_DIRECTION ) bearing: Double, @FloatRange(from = MapLibreConstants.MINIMUM_TILT, to = MapLibreConstants.MAXIMUM_TILT ) tilt: Double): CameraPosition
Get a camera position that fits a provided bounds, padding, bearing and tilt.
Link copied to clipboard
Gets the current position of the camera.
Link copied to clipboard
Link copied to clipboard
Gets the callback to be invoked when an info window will be shown.
Link copied to clipboard
Returns a list of all the markers on the map.
Link copied to clipboard
Gets the maximum Pitch the map can be displayed at.
Link copied to clipboard
Gets the maximum zoom level the map can be displayed at.
Link copied to clipboard
Gets the minimum Pitch the map can be displayed at.
Link copied to clipboard
Gets the minimum zoom level the map can be displayed at.
Link copied to clipboard
Return the InfoWindow click listener
Link copied to clipboard
Return the InfoWindow close listener
Link copied to clipboard
Return the InfoWindow long click listener
Link copied to clipboard
Returns the current configured content padding on map view.
Link copied to clipboard
Returns a list of all the polygons on the map.
Link copied to clipboard
Returns a list of all the polylines on the map.
Link copied to clipboard
Check whether tile pre-fetching is enabled or not.
Link copied to clipboard
Check current pre-fetching zoom delta.
Link copied to clipboard
Gets the currently selected marker.
Link copied to clipboard
Get the Style of the map asynchronously.
Link copied to clipboard
Check whether tile cache is enabled or not.
Link copied to clipboard
Returns whether the map allows concurrent multiple infowindows to be shown.
Link copied to clipboard
Returns whether the map debug information is currently shown.
Link copied to clipboard
Repositions the camera according to the instructions defined in the update.
Link copied to clipboard
open fun queryRenderedFeatures(@NonNull coordinates: PointF, @Nullable layerIds: Array<String>): List<Feature>
Queries the map for rendered features.
open fun queryRenderedFeatures(@NonNull coordinates: RectF, @Nullable layerIds: Array<String>): List<Feature>
open fun queryRenderedFeatures(@NonNull coordinates: PointF, @Nullable filter: Expression, @Nullable layerIds: Array<String>): List<Feature>
open fun queryRenderedFeatures(@NonNull coordinates: RectF, @Nullable filter: Expression, @Nullable layerIds: Array<String>): List<Feature>
Queries the map for rendered features Returns an empty list if either the map or underlying render surface has been destroyed.
Link copied to clipboard
Removes an annotation from the map
Removes an annotation from the map.
Link copied to clipboard
Removes all annotations from the map.
Removes multiple annotations from the map.
Link copied to clipboard
Convenience method for removing a Marker from the map.
Link copied to clipboard
Removes a callback that is invoked when camera movement has ended.
Link copied to clipboard
open fun removeOnCameraMoveCancelListener(@NonNull listener: MapLibreMap.OnCameraMoveCanceledListener)
Removes a callback that is invoked when camera movement was cancelled.
Link copied to clipboard
Removes a callback that is invoked when camera position changes.
Link copied to clipboard
open fun removeOnCameraMoveStartedListener(@NonNull listener: MapLibreMap.OnCameraMoveStartedListener)
Removes a callback that is invoked when camera movement has started.
Link copied to clipboard
Removes a callback that's invoked when the map is flinged.
Link copied to clipboard
Removes a callback that's invoked when the user clicks on the map view.
Link copied to clipboard
Removes a callback that's invoked when the user long clicks on the map view.
Link copied to clipboard
Removes a callback that's invoked when the map is moved.
Link copied to clipboard
Removes a callback that's invoked when the map is rotated.
Link copied to clipboard
Removes a callback that's invoked when the map is scaled.
Link copied to clipboard
Remove a callback that's invoked when the map is tilted.
Link copied to clipboard
Convenience method for removing a Polygon from the map.
Link copied to clipboard
Convenience method for removing a Polyline from the map.
Link copied to clipboard
Resets the map view to face north.
Link copied to clipboard
Selects a marker.
Link copied to clipboard
Changes whether the map allows concurrent multiple infowindows to be shown.
Link copied to clipboard
Repositions the camera according to the cameraPosition.
Link copied to clipboard
Changes whether the map debug information is shown.
Link copied to clipboard
Transform the map bearing given a bearing, focal point coordinates, and a duration.
Link copied to clipboard
open fun setGesturesManager(@NonNull androidGesturesManager: AndroidGesturesManager, attachDefaultListeners: Boolean, setDefaultMutuallyExclusives: Boolean)
Link copied to clipboard
Sets a custom renderer for the contents of info window.
Link copied to clipboard
Sets a LatLngBounds that constraints map transformations to this bounds.
Link copied to clipboard
open fun setMaxPitchPreference(@FloatRange(from = MapLibreConstants.MINIMUM_PITCH, to = MapLibreConstants.MAXIMUM_PITCH ) maxPitch: Double)
Sets the maximum Pitch the map can be displayed at.
Link copied to clipboard
open fun setMaxZoomPreference(@FloatRange(from = MapLibreConstants.MINIMUM_ZOOM, to = MapLibreConstants.MAXIMUM_ZOOM ) maxZoom: Double)
Sets the maximum zoom level the map can be displayed at.
Link copied to clipboard
open fun setMinPitchPreference(@FloatRange(from = MapLibreConstants.MINIMUM_PITCH, to = MapLibreConstants.MAXIMUM_PITCH ) minPitch: Double)
Sets the minimum Pitch the map can be displayed at.
Link copied to clipboard
open fun setMinZoomPreference(@FloatRange(from = MapLibreConstants.MINIMUM_ZOOM, to = MapLibreConstants.MAXIMUM_ZOOM ) minZoom: Double)
Sets the minimum zoom level the map can be displayed at.
Link copied to clipboard
open fun setOfflineRegionDefinition(@NonNull definition: OfflineRegionDefinition, @Nullable callback: Style.OnStyleLoaded)
Loads a new style from the specified offline region definition and moves the map camera to that region.
Link copied to clipboard
Sets a callback that's invoked on every frame rendered to the map view.
Link copied to clipboard
Sets a callback that's invoked when the user clicks on an info window.
Link copied to clipboard
Set an callback to be invoked when an InfoWindow closes.
Link copied to clipboard
open fun setOnInfoWindowLongClickListener(@Nullable listener: MapLibreMap.OnInfoWindowLongClickListener)
Sets a callback that's invoked when a marker's info window is long pressed.
Link copied to clipboard
Sets a callback that's invoked when the user clicks on a marker.
Link copied to clipboard
Sets a callback that's invoked when the user clicks on a polygon.
Link copied to clipboard
Sets a callback that's invoked when the user clicks on a polyline.
Link copied to clipboard
Sets the distance from the edges of the map view's frame to the edges of the map view's logical viewport.
Link copied to clipboard
Enable or disable tile pre-fetching.
Link copied to clipboard
Set the tile pre-fetching zoom delta.
Link copied to clipboard
Loads a new map style from the specified bundled style.
Loads a new map style from the specified builder.
Link copied to clipboard
Link copied to clipboard
Indicating whether the map may cache tiles for different zoom levels or not.
Link copied to clipboard
Takes a snapshot of the map.
Link copied to clipboard
Trigger the mapview to repaint.
Link copied to clipboard
Updates a marker on this map.
Link copied to clipboard
Update a polygon on this map.
Link copied to clipboard
Update a polyline on this map.