MTMapViewController

class MTMapViewController(context: Context) : WebViewExecutorDelegate, EventProcessorDelegate, MTJavascriptDelegate, MTZoomable, MTNavigable

Object exposing methods and properties that enable changes to the map, and events that can be interacted with.

Constructors

constructor(context: Context)

Properties

Delegate object responsible for event propagation

Service responsible for gestures handling

Current options of the map object.

Proxy style object of the map.

Functions

Registers a content delegate that observes map events without replacing the primary delegate.

fun addSprite(identifier: String, url: URL)

Registers a sprite resource that can be referenced from style layers.

open suspend override fun areTilesLoaded(): Boolean

Returns whether all currently requested tiles are loaded.

open override fun centerOnIpPoint()

Centers the map on the coarse location inferred from the device's public IP address.

open override fun easeTo(cameraOptions: MTCameraOptions)

Changes any combination of center, zoom, bearing and pitch with an animated transition between old and new values.

open override fun fitBounds(bounds: MTBounds, options: MTFitBoundsOptions?)

Fits the viewport so that the supplied bounds are fully visible, applying optional padding or animation overrides.

open override fun fitToIpBounds()

Initiates an animated fit to the coarse bounds derived from the device's public IP address.

open override fun flyTo(cameraOptions: MTCameraOptions, flyToOptions: MTFlyToOptions?)

Changes any combination of center, zoom, bearing, and pitch, animating the transition along a curve that evokes flight.

open suspend override fun getBearing(): Double

Returns the map's current bearing.

open suspend override fun getBounds(): MTBounds

Returns the geographical bounds currently visible within the viewport.

open suspend override fun getCameraTargetElevation(): Double

Returns the elevation of the location currently targeted by the camera, in meters above sea level.

open suspend override fun getCenter(): LngLat

Returns the map's current center.

open suspend override fun getCenterClampedToGround(): Boolean

Returns whether the map's center is clamped to the ground.

open suspend override fun getCenterElevation(): Double

Returns the elevation of the map's center point in meters above sea level.

open suspend override fun getMaxBounds(): MTBounds?

Returns the geographical constraints currently applied to the map, if any.

open suspend override fun getMaxPitch(): Double

Returns the map's maximum pitch.

open suspend override fun getMaxZoom(): Double

Returns the map's maximum zoom level.

open suspend override fun getMinPitch(): Double

Returns the map's minimum pitch.

open suspend override fun getMinZoom(): Double

Returns the map's minimum zoom level.

open suspend override fun getPitch(): Double

Returns the map's current pitch.

open suspend override fun getPixelRatio(): Double

Returns the pixel ratio currently used to render the map.

Returns the current map projection type. Defaults to MTProjectionType.MERCATOR if unavailable.

open suspend override fun getRenderWorldCopies(): Boolean

Returns whether the map is set to render multiple world copies.

open suspend override fun getRoll(): Double

Returns the map's current roll.

open suspend override fun getZoom(): Double

Returns the map's current zoom level.

suspend fun gpxToGeoJSON(gpxXml: String): String?

Converts a GPX XML payload to a GeoJSON FeatureCollection string using the SDK converter.

open override fun jumpTo(cameraOptions: MTCameraOptions)

Changes any combination of center, zoom, bearing, and pitch, without an animated transition

suspend fun kmlToGeoJSON(kmlXml: String): String?

Converts a KML XML payload to a GeoJSON FeatureCollection string using the SDK converter.

open override fun onError(message: String)

Map error handler.

open override fun onEvent(event: MTEvent, data: MTData?)
open override fun onEventTriggered(processor: EventProcessor, event: MTEvent, data: MTData?)
open override fun onWebGLContextLost()

WebGL Context error handler

open override fun panBy(offset: MTPoint)

Pans the map by the specified offset.

open override fun panTo(coordinates: LngLat)

Pans the map to the specified location with an animated transition.

open suspend override fun project(coordinates: LngLat): MTPoint

Project coordinates to point on the container.

fun reload()

Unregisters a previously registered content delegate.

open override fun setBearing(bearing: Double)

Sets bearing of the map.

open override fun setCenter(center: LngLat)

Sets the geographical center of the map.

open override fun setCenterElevation(elevation: Double)

Sets the elevation of the map's center point, in meters above sea level.

open override fun setIsCenterClampedToGround(isCenterClampedToGround: Boolean)

Sets the center clamped to the ground.

open override fun setMaxBounds(bounds: MTBounds?)

Constrains map interactions to the provided bounds, or removes the constraint when null is supplied.

Sets the maximum number of images (raster tiles, sprites, icons) to load in parallel.

open override fun setMaxZoom(maxZoom: Double)

Sets the map's maximum zoom.

open override fun setMinZoom(minZoom: Double)

Sets the map's minimum zoom.

open override fun setPadding(padding: MTPaddingOptions)

Sets the padding in pixels around the viewport.

open override fun setPitch(pitch: Double)

Sets the map's pitch in degrees (0-85).

open override fun setPixelRatio(pixelRatio: Double)

Overrides the pixel ratio used to render the map.

open override fun setRoll(roll: Double)

Sets the map's roll angle.

fun setRTLTextPlugin(pluginUrl: String, deferred: Boolean = false)

Sets the map's RTL text plugin. Necessary for supporting the right-to-left text direction found in languages like Arabic and Hebrew.

Sets the secondary map language.

fun setSprite(spriteUrl: String)

Updates the sprite of the map.

Set the map terrain.

Set the duration (millisec) of the terrain animation for growing or flattening. Must be positive.

fun setTerrainExaggeration(exaggeration: Double, animate: Boolean? = null)

Change the terrain exaggeration.

open override fun setVerticalFieldOfView(verticalFieldOfView: Double)

Sets the map's vertical field of view in degrees (defaults to 36.87 degrees).

open override fun setZoom(zoom: Double)

Sets the map's zoom level.

Show or hide collision boxes

Show or hide overdraw inspector

fun showPadding(show: Boolean)

Show or hide padding

Show or hide tile boundaries

open override fun snapToNorth(options: MTAnimationOptions?)

Snaps the map so that north is up (bearing 0), animating the transition.

open override fun stop()

Stops any animated transition underway.

Trigger the rendering of a single frame. Use this method with custom layers to repaint the map when the layer changes. Calling this multiple times before the next frame is rendered will still result in only a single frame being rendered.

open suspend override fun unproject(point: MTPoint): LngLat

Unproject a point on the container to geographical coordinates.

open override fun zoomIn()

Increases the map's zoom level by 1.

open override fun zoomOut()

Decreases the map's zoom level by 1.

open override fun zoomTo(zoom: Double, options: MTAnimationOptions?)

Zooms the map to the specified zoom level, with an optional animation.