MapLibreMap

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 definition for a callback to be invoked when a task is complete or cancelled.
Link copied to clipboard
Interface definition for a callback to be invoked when an info window will be shown.
Link copied to clipboard
Interface definition for a callback to be invoked for when camera movement has ended.
Link copied to clipboard
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 definition for a callback to be invoked for when the camera changes position.
Link copied to clipboard
Interface definition for a callback to be invoked for when the camera motion starts.
Link copied to clipboard
Interface definition for a callback to be invoked for when the compass is animating.
Link copied to clipboard
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 definition for a callback to be invoked when a frame is rendered to the map view.
Link copied to clipboard
Interface definition for a callback to be invoked when the user clicks on an info window.
Link copied to clipboard
Interface definition for a callback to be invoked when a marker's info window is closed.
Link copied to clipboard
Interface definition for a callback to be invoked when the user long presses on a marker's info window.
Link copied to clipboard
Interface definition for a callback to be invoked when the user clicks on the map view.
Link copied to clipboard
Interface definition for a callback to be invoked when the user long clicks on the map view.
Link copied to clipboard
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 definition for a callback to be invoked when the user clicks on a polygon.
Link copied to clipboard
Interface definition for a callback to be invoked when the user clicks on a polyline.
Link copied to clipboard
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 definition for a callback to be invoked when the snapshot has been taken.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open fun addMarker(@NonNull markerOptions: BaseMarkerOptions): Marker
open fun addMarker(@NonNull markerOptions: MarkerOptions): Marker
Adds a marker to this map.
Link copied to clipboard
open fun addMarkers(@NonNull markerOptionsList: List<out BaseMarkerOptions>): List<Marker>
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
open fun addPolygon(@NonNull polygonOptions: PolygonOptions): Polygon
Adds a polygon to this map.
Link copied to clipboard
open fun addPolygons(@NonNull polygonOptionsList: List<PolygonOptions>): List<Polygon>
Adds multiple polygons to this map.
Link copied to clipboard
open fun addPolyline(@NonNull polylineOptions: PolylineOptions): Polyline
Adds a polyline to this map.
Link copied to clipboard
open fun addPolylines(@NonNull polylineOptionsList: List<PolylineOptions>): List<Polyline>
Adds multiple polylines to this map.
Link copied to clipboard
fun animateCamera(@NonNull update: CameraUpdate, durationMs: Int)
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
open fun clear()
Removes all markers, polylines, polygons, overlays, etc from the map.
Link copied to clipboard
Cycles through the map debug options.
Link copied to clipboard
open fun deselectMarker(@NonNull marker: Marker)
Deselects a currently selected marker.
Link copied to clipboard
open fun deselectMarkers()
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)
fun easeCamera(@NonNull update: CameraUpdate, durationMs: Int, easingInterpolator: Boolean)
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
open fun getCameraForGeometry(@NonNull geometry: Geometry): CameraPosition
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.
Get a camera position that fits a provided shape with a given bearing and tilt.
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.
Get a camera position that fits a provided bounds, bearing and tilt.
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
open fun getGesturesManager(): AndroidGesturesManager
Get current AndroidGesturesManager that handles android.view.MotionEvents registered by the MapView
Link copied to clipboard
open fun getHeight(): Float
Returns the measured height of the Map.
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
open fun getMaxPitch(): Double
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
open fun getMinPitch(): Double
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
@IntRange(from = 0)
open fun getPrefetchZoomDelta(): Int
Check current pre-fetching zoom delta.
Link copied to clipboard
Gets the currently selected marker.
Link copied to clipboard
open fun getStyle(@NonNull onStyleLoaded: Style.OnStyleLoaded)
Get the Style of the map asynchronously.
Link copied to clipboard
Check whether tile cache is enabled or not.
Link copied to clipboard
open fun getWidth(): Float
Returns the measured width of the Map.
Link copied to clipboard
open fun getZoom(): Double
Returns the current zoom level.
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
open fun removeAnnotation(id: Long)
Removes an annotation from the map
open fun removeAnnotation(@NonNull annotation: Annotation)
Removes an annotation from the map.
Link copied to clipboard
Removes all annotations from the map.
open fun removeAnnotations(@NonNull annotationList: List<out Annotation>)
Removes multiple annotations from the map.
Link copied to clipboard
open fun removeMarker(@NonNull marker: Marker)
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
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
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
open fun removePolygon(@NonNull polygon: Polygon)
Convenience method for removing a Polygon from the map.
Link copied to clipboard
open fun removePolyline(@NonNull polyline: Polyline)
Convenience method for removing a Polyline from the map.
Link copied to clipboard
open fun resetNorth()
Resets the map view to face north.
Link copied to clipboard
open fun scrollBy(x: Float, y: Float)
open fun scrollBy(x: Float, y: Float, duration: Long)
Scrolls the camera over the map, shifting the center of view by the specified number of pixels in the x and y directions.
Link copied to clipboard
open fun selectMarker(@NonNull marker: Marker)
Selects a marker.
Changes whether the map allows concurrent multiple infowindows to be shown.
Link copied to clipboard
open fun setCameraPosition(@NonNull cameraPosition: CameraPosition)
Repositions the camera according to the cameraPosition.
Link copied to clipboard
open fun setDebugActive(debugActive: Boolean)
Changes whether the map debug information is shown.
Link copied to clipboard
open fun setFocalBearing(bearing: Double, focalX: Float, focalY: Float, duration: Long)
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)
Sets a custom AndroidGesturesManager to handle android.view.MotionEvents registered by the MapView.
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
Sets the maximum Pitch the map can be displayed at.
Link copied to clipboard
Sets the maximum zoom level the map can be displayed at.
Link copied to clipboard
Sets the minimum Pitch the map can be displayed at.
Link copied to clipboard
Sets the minimum zoom level the map can be displayed at.
Link copied to clipboard
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
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
open fun setPadding(left: Int, top: Int, right: Int, bottom: Int)
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
open fun setPrefetchesTiles(enable: Boolean)
Enable or disable tile pre-fetching.
Link copied to clipboard
open fun setPrefetchZoomDelta(@IntRange(from = 0) delta: Int)
Set the tile pre-fetching zoom delta.
Link copied to clipboard
open fun setStyle(style: String)
open fun setStyle(style: String, callback: Style.OnStyleLoaded)
Loads a new map style from the specified bundled style.
open fun setStyle(builder: Style.Builder)
open fun setStyle(builder: Style.Builder, callback: Style.OnStyleLoaded)
Loads a new map style from the specified builder.
Link copied to clipboard
open fun setSwapBehaviorFlush(flush: Boolean)
Link copied to clipboard
open fun setTileCacheEnabled(enabled: Boolean)
Indicating whether the map may cache tiles for different zoom levels or not.
Link copied to clipboard
open fun setZoom(zoom: Double, @NonNull focalPoint: PointF, duration: Long)
Zooms the camera to the specified level.
Link copied to clipboard
Takes a snapshot of the map.
Link copied to clipboard
open fun triggerRepaint()
Trigger the mapview to repaint.
Link copied to clipboard
open fun updateMarker(@NonNull updatedMarker: Marker)
Updates a marker on this map.
Link copied to clipboard
open fun updatePolygon(@NonNull polygon: Polygon)
Update a polygon on this map.
Link copied to clipboard
open fun updatePolyline(@NonNull polyline: Polyline)
Update a polyline on this map.