MapSurface

A MapSurface provides an embeddable map interface. You use this class to display map information and to manipulate the map contents from your application. You can center the map on a given coordinate, specify the size of the area you want to display, and style the features of the map to fit your application's use case.

Use of MapSurface requires a Mapbox API access token. Obtain an access token on the Mapbox account page.

Warning: Please note that you are responsible for getting permission to use the map data, and for ensuring your use adheres to the relevant terms of use.

Constructors

Link copied to clipboard
fun MapSurface(context: Context, surface: Surface, mapInitOptions: MapInitOptions = MapInitOptions(context))

Functions

Link copied to clipboard
open override fun addRendererSetupErrorListener(rendererSetupErrorListener: RendererSetupErrorListener)

Add an instance of RendererSetupErrorListener.

Link copied to clipboard
open override fun addWidget(widget: Widget)

Add Widget to the map.

Link copied to clipboard
@JvmName(name = "getMapboxMapDeprecated")
fun getMapboxMap(): MapboxMap

Returns a MapboxMap object that can be used to interact with the map.

Link copied to clipboard
open override fun <T : MapPlugin> getPlugin(id: String): T?

Get the plugin instance.

Link copied to clipboard
open override fun onDestroy()

Called to dispose the renderer

Link copied to clipboard
open override fun onGenericMotionEvent(event: MotionEvent): Boolean

Called when a motion event has occurred.

Link copied to clipboard
open override fun onLowMemory()

Called to reduce memory use

Link copied to clipboard
open override fun onSizeChanged(w: Int, h: Int)

Called when the size has changed.

Link copied to clipboard
open override fun onStart()

Called to resume rendering

Link copied to clipboard
open override fun onStop()

Called to stop rendering

Link copied to clipboard
open override fun onTouchEvent(event: MotionEvent): Boolean

Called when a touch event has occurred.

Link copied to clipboard
open override fun queueEvent(event: Runnable, needRender: Boolean)

Queue a runnable to be executed on the map renderer thread. Consecutive events will be called in the order they were queued.

Link copied to clipboard
open override fun removeRendererSetupErrorListener(rendererSetupErrorListener: RendererSetupErrorListener)

Remove an instance of RendererSetupErrorListener.

Link copied to clipboard
open override fun removeWidget(widget: Widget): Boolean

Remove Widget from the map.

Link copied to clipboard
open override fun setMaximumFps(fps: Int)

Called to limit the maximum fps

Link copied to clipboard
open override fun setOnFpsChangedListener(listener: OnFpsChangedListener)

Set OnFpsChangedListener to get map rendering FPS.

Link copied to clipboard
open override fun snapshot(): Bitmap?

Called to capture a snapshot synchronously.

open override fun snapshot(listener: MapView.OnSnapshotReady)

Called to capture a snapshot asynchronously. Consecutive requests will return snapshots in the order they were added.

Link copied to clipboard
fun surfaceChanged(width: Int, height: Int)

Must be called when the surface dimensions have changed.

Link copied to clipboard

Must be called when the surface has been created.

Link copied to clipboard

Must be called when the surface is destroyed.

Properties

Link copied to clipboard
open override val mapboxMap: MapboxMap

Returns a MapboxMap object that can be used to interact with the map.

Link copied to clipboard

The surface to be used, set from the constructor.

Extensions

Link copied to clipboard

Extension val for MapView to get the Annotation plugin instance.

Link copied to clipboard

Extension val for MapView to get the Compass View plugin instance.

Link copied to clipboard

Extension val for MapView to get the Camera Animations plugin instance.

Link copied to clipboard

Extension val for MapView to get the Compass View plugin instance.

Link copied to clipboard

Extension val for MapView to get the Gestures plugin instance.

Link copied to clipboard

Extension function for MapView to get the lifecycle plugin instance.

Link copied to clipboard
@get:JvmName(name = "getLocationComponent")
val MapPluginProviderDelegate.location: LocationComponentPlugin

Extension val to get the LocationComponentPlugin instance.

Link copied to clipboard

Extension val for MapView to get the Logo View plugin instance.

Link copied to clipboard

Extension val for MapView to get the map overlay plugin instance.

Link copied to clipboard

Extension val for MapView to get the ScaleBar plugin instance.