Map

class Map : CameraManager, MapInterface

Map class provides map rendering functionality.

Constructors

Map
Link copied to clipboard
open fun Map(client: MapClient, mapOptions: MapOptions, resourceOptions: ResourceOptions)
Initializes the map object.

Functions

addPersistentStyleCustomLayer
Link copied to clipboard
open fun addPersistentStyleCustomLayer(layerId: String, layerHost: CustomLayerHost, layerPosition: LayerPosition): Expected<String, None>
Adds a new [style custom layer](https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers).
addPersistentStyleLayer
Link copied to clipboard
open fun addPersistentStyleLayer(properties: Value, layerPosition: LayerPosition): Expected<String, None>
Adds a new [style layer](https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers).
addStyleCustomGeometrySource
Link copied to clipboard
open fun addStyleCustomGeometrySource(sourceId: String, options: CustomGeometrySourceOptions): Expected<String, None>
Adds a custom geometry to be used in the style.
addStyleCustomLayer
Link copied to clipboard
open fun addStyleCustomLayer(layerId: String, layerHost: CustomLayerHost, layerPosition: LayerPosition): Expected<String, None>
Adds a new [style custom layer](https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers).
addStyleImage
Link copied to clipboard
open fun addStyleImage(imageId: String, scale: Float, image: Image, sdf: Boolean, stretchX: List<ImageStretches>, stretchY: List<ImageStretches>, content: ImageContent): Expected<String, None>
Adds an image to be used in the style.
addStyleLayer
Link copied to clipboard
open fun addStyleLayer(properties: Value, layerPosition: LayerPosition): Expected<String, None>
Adds a new [style layer](https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers).
addStyleSource
Link copied to clipboard
open fun addStyleSource(sourceId: String, properties: Value): Expected<String, None>
Adds a new [style source](https://docs.mapbox.com/mapbox-gl-js/style-spec/#sources).
addViewAnnotation
Link copied to clipboard
open fun addViewAnnotation(identifier: String, options: ViewAnnotationOptions): Expected<String, None>
cameraForCoordinateBounds
Link copied to clipboard
open fun cameraForCoordinateBounds(bounds: CoordinateBounds, padding: EdgeInsets, bearing: Double, pitch: Double): CameraOptions
Convenience method that returns the `camera options` object for given parameters.
cameraForCoordinates
Link copied to clipboard
open fun cameraForCoordinates(coordinates: List<Point>, camera: CameraOptions, box: ScreenBox): CameraOptions
Convenience method that adjusts the provided `camera options` object for given parameters.
open fun cameraForCoordinates(coordinates: List<Point>, padding: EdgeInsets, bearing: Double, pitch: Double): CameraOptions
Convenience method that returns the `camera options` object for given parameters.
cameraForGeometry
Link copied to clipboard
open fun cameraForGeometry(geometry: Geometry, padding: EdgeInsets, bearing: Double, pitch: Double): CameraOptions
Convenience method that returns the `camera options` object for given parameters.
clearData
Link copied to clipboard
open fun clearData(resourceOptions: ResourceOptions, callback: AsyncOperationResultCallback)
Clears temporary map data.
coordinateBoundsForCamera
Link copied to clipboard
open fun coordinateBoundsForCamera(camera: CameraOptions): CoordinateBounds
Returns the `coordinate bounds` for a given camera.
coordinateBoundsForCameraUnwrapped
Link copied to clipboard
open fun coordinateBoundsForCameraUnwrapped(camera: CameraOptions): CoordinateBounds
Returns the `coordinate bounds` for a given camera.
coordinateBoundsZoomForCamera
Link copied to clipboard
open fun coordinateBoundsZoomForCamera(camera: CameraOptions): CoordinateBoundsZoom
Returns the `coordinate bounds` and the `zoom` for a given `camera`.
coordinateBoundsZoomForCameraUnwrapped
Link copied to clipboard
open fun coordinateBoundsZoomForCameraUnwrapped(camera: CameraOptions): CoordinateBoundsZoom
Returns the unwrapped `coordinate bounds` and `zoom` for a given `camera`.
coordinateForPixel
Link copied to clipboard
open fun coordinateForPixel(pixel: ScreenCoordinate): Point
Calculates a geographical `coordinate` (i.e., longitude-latitude pair) that corresponds to a `screen coordinate`.
coordinatesForPixels
Link copied to clipboard
open fun coordinatesForPixels(pixels: List<ScreenCoordinate>): List<Point>
Calculates geographical `coordinates` (i.e., longitude-latitude pairs) that correspond to `screen coordinates`.
createRenderer
Link copied to clipboard
open fun createRenderer()
Creates the infrastructure needed for rendering the map.
destroyRenderer
Link copied to clipboard
open fun destroyRenderer()
Destroys the infrastructure needed for rendering the map, releasing resources.
dragEnd
Link copied to clipboard
open fun dragEnd()
Ends the ongoing drag gesture.
dragStart
Link copied to clipboard
open fun dragStart(point: ScreenCoordinate)
Prepares the drag gesture to use the provided screen coordinate as a pivot `point`.
getBounds
Link copied to clipboard
open fun getBounds(): CameraBounds
Returns the `camera bounds` of the map.
getCameraState
Link copied to clipboard
open fun getCameraState(): CameraState
Returns the current `camera state`.
getDebug
Link copied to clipboard
open fun getDebug(): List<MapDebugOptions>
Returns the `map debug options`.
getDragCameraOptions
Link copied to clipboard
open fun getDragCameraOptions(fromPoint: ScreenCoordinate, toPoint: ScreenCoordinate): CameraOptions
Calculates target point where camera should move after drag.
getElevation
Link copied to clipboard
open fun getElevation(coordinate: Point): Double
Gets elevation for the given coordinate.
getFeatureState
Link copied to clipboard
open fun getFeatureState(sourceId: String, sourceLayerId: String, featureId: String, callback: QueryFeatureStateCallback)
Gets the state map of a feature within a style source.
getFreeCameraOptions
Link copied to clipboard
open fun getFreeCameraOptions(): FreeCameraOptions
Gets the map's current free camera options.
getMapOptions
Link copied to clipboard
open fun getMapOptions(): MapOptions
Returns the `map options`.
getNativePtr
Link copied to clipboard
open fun getNativePtr(): Long
Experimental feature.
getPrefetchZoomDelta
Link copied to clipboard
open fun getPrefetchZoomDelta(): Byte
Returns the map's prefetch zoom delta.
getRenderCacheOptions
Link copied to clipboard
open fun getRenderCacheOptions(): RenderCacheOptions
Returns the `render cache options` used by the map.
getResourceOptions
Link copied to clipboard
open fun getResourceOptions(): ResourceOptions
Gets the resource options for the map.
getSize
Link copied to clipboard
open fun getSize(): Size
Gets the size of the map.
getStyleDefaultCamera
Link copied to clipboard
open fun getStyleDefaultCamera(): CameraOptions
Returns the map style's default camera, if any, or a default camera otherwise.
getStyleImage
Link copied to clipboard
open fun getStyleImage(imageId: String): Image
Get an `image` from the style.
getStyleJSON
Link copied to clipboard
open fun getStyleJSON(): String
Get the JSON serialization string of the current style in use.
getStyleLayerProperties
Link copied to clipboard
open fun getStyleLayerProperties(layerId: String): Expected<String, Value>
Gets style layer properties.
getStyleLayerProperty
Link copied to clipboard
open fun getStyleLayerProperty(layerId: String, property: String): StylePropertyValue
Gets the value of style layer property.
getStyleLayerPropertyDefaultValue
Link copied to clipboard
open fun getStyleLayerPropertyDefaultValue(layerType: String, property: String): StylePropertyValue
Gets the default value of style layer property
getStyleLayers
Link copied to clipboard
open fun getStyleLayers(): List<StyleObjectInfo>
Returns the existing style layers.
getStyleLightProperty
Link copied to clipboard
open fun getStyleLightProperty(property: String): StylePropertyValue
Gets the value of a style light property.
getStyleProjectionProperty
Link copied to clipboard
open fun getStyleProjectionProperty(property: String): StylePropertyValue
Gets the value of a style projection property.
getStyleSourceProperties
Link copied to clipboard
open fun getStyleSourceProperties(sourceId: String): Expected<String, Value>
Gets style source properties.
getStyleSourceProperty
Link copied to clipboard
open fun getStyleSourceProperty(sourceId: String, property: String): StylePropertyValue
Gets the value of style source property.
getStyleSourcePropertyDefaultValue
Link copied to clipboard
open fun getStyleSourcePropertyDefaultValue(sourceType: String, property: String): StylePropertyValue
Gets the default value of style source property.
getStyleSources
Link copied to clipboard
open fun getStyleSources(): List<StyleObjectInfo>
Returns the existing style sources.
getStyleTerrainProperty
Link copied to clipboard
open fun getStyleTerrainProperty(property: String): StylePropertyValue
Gets the value of a style terrain property.
getStyleTransition
Link copied to clipboard
open fun getStyleTransition(): TransitionOptions
Returns the map style's transition options.
getStyleURI
Link copied to clipboard
open fun getStyleURI(): String
Get the URI of the current style in use.
getViewAnnotationOptions
Link copied to clipboard
open fun getViewAnnotationOptions(identifier: String): Expected<String, ViewAnnotationOptions>
hasStyleImage
Link copied to clipboard
open fun hasStyleImage(imageId: String): Boolean
Checks whether an image exists.
open fun invalidateStyleCustomGeometrySourceRegion(sourceId: String, bounds: CoordinateBounds): Expected<String, None>
Invalidate region for provided custom geometry source.
invalidateStyleCustomGeometrySourceTile
Link copied to clipboard
open fun invalidateStyleCustomGeometrySourceTile(sourceId: String, tileId: CanonicalTileID): Expected<String, None>
Invalidate tile for provided custom geometry source.
isGestureInProgress
Link copied to clipboard
open fun isGestureInProgress(): Boolean
Returns `true` if a gesture is currently in progress.
isMapLoaded
Link copied to clipboard
open fun isMapLoaded(): Boolean
Returns `true` when the map is completely rendered, `false` otherwise.
isStyleLayerPersistent
Link copied to clipboard
open fun isStyleLayerPersistent(layerId: String): Expected<String, Boolean>
Checks if a style layer is persistent.
isStyleLoaded
Link copied to clipboard
open fun isStyleLoaded(): Boolean
Check if the style is completely loaded.
isUserAnimationInProgress
Link copied to clipboard
open fun isUserAnimationInProgress(): Boolean
Returns `true` if user animation is currently in progress.
moveStyleLayer
Link copied to clipboard
open fun moveStyleLayer(layerId: String, layerPosition: LayerPosition): Expected<String, None>
Moves an existing style layer
pixelForCoordinate
Link copied to clipboard
open fun pixelForCoordinate(coordinate: Point): ScreenCoordinate
Calculates a `screen coordinate` that corresponds to a geographical coordinate (i.e., longitude-latitude pair).
pixelsForCoordinates
Link copied to clipboard
open fun pixelsForCoordinates(coordinates: List<Point>): List<ScreenCoordinate>
Calculates `screen coordinates` that correspond to geographical `coordinates` (i.e., longitude-latitude pairs).
queryFeatureExtensions
Link copied to clipboard
open fun queryFeatureExtensions(sourceIdentifier: String, feature: Feature, extension: String, extensionField: String, args: HashMap<String, Value>, callback: QueryFeatureExtensionCallback)
Queries for feature extension values in a GeoJSON source.
queryRenderedFeatures
Link copied to clipboard
open fun queryRenderedFeatures(geometry: RenderedQueryGeometry, options: RenderedQueryOptions, callback: QueryFeaturesCallback): Cancelable
Queries the map for rendered features.
open fun queryRenderedFeatures(box: ScreenBox, options: RenderedQueryOptions, callback: QueryFeaturesCallback)
Queries the map for rendered features.
open fun queryRenderedFeatures(pixel: ScreenCoordinate, options: RenderedQueryOptions, callback: QueryFeaturesCallback)
Queries the map for rendered features.
open fun queryRenderedFeatures(shape: List<ScreenCoordinate>, options: RenderedQueryOptions, callback: QueryFeaturesCallback)
Queries the map for rendered features.
querySourceFeatures
Link copied to clipboard
open fun querySourceFeatures(sourceId: String, options: SourceQueryOptions, callback: QueryFeaturesCallback)
Queries the map for source features.
reduceMemoryUse
Link copied to clipboard
open fun reduceMemoryUse()
Reduces memory use.
removeFeatureState
Link copied to clipboard
open fun removeFeatureState(sourceId: String, sourceLayerId: String, featureId: String, stateKey: String)
Removes entries from a feature state object.
removeStyleImage
Link copied to clipboard
open fun removeStyleImage(imageId: String): Expected<String, None>
Removes an image from the style.
removeStyleLayer
Link copied to clipboard
open fun removeStyleLayer(layerId: String): Expected<String, None>
Removes an existing style layer.
removeStyleSource
Link copied to clipboard
open fun removeStyleSource(sourceId: String): Expected<String, None>
Removes an existing style source.
removeViewAnnotation
Link copied to clipboard
open fun removeViewAnnotation(identifier: String): Expected<String, None>
render
Link copied to clipboard
open fun render()
Renders the map.
setBounds
Link copied to clipboard
open fun setBounds(options: CameraBoundsOptions): Expected<String, None>
Sets the `camera bounds options` of the map.
setCamera
Link copied to clipboard
open fun setCamera(cameraOptions: CameraOptions)
Changes the map view by any combination of center, zoom, bearing, and pitch, without an animated transition.
open fun setCamera(freeCameraOptions: FreeCameraOptions)
Sets the map view with the free camera options.
setConstrainMode
Link copied to clipboard
open fun setConstrainMode(mode: ConstrainMode)
Sets the map `constrain mode`.
setDebug
Link copied to clipboard
open fun setDebug(debugOptions: List<MapDebugOptions>, value: Boolean)
Sets the `map debug options` and enables debug mode based on the passed value.
setFeatureState
Link copied to clipboard
open fun setFeatureState(sourceId: String, sourceLayerId: String, featureId: String, state: Value)
Updates the state object of a feature within a style source.
setGestureInProgress
Link copied to clipboard
open fun setGestureInProgress(inProgress: Boolean)
Tells the map rendering engine that there is currently a gesture in progress.
setMemoryBudget
Link copied to clipboard
open fun setMemoryBudget(memoryBudget: MapMemoryBudget)
setNorthOrientation
Link copied to clipboard
open fun setNorthOrientation(orientation: NorthOrientation)
Sets the north `orientation mode`.
setPrefetchZoomDelta
Link copied to clipboard
open fun setPrefetchZoomDelta(delta: Byte)
When loading a map, if prefetch zoom `delta` is set to any number greater than 0, the map will first request a tile at zoom level lower than `zoom - delta`, with requested zoom level a multiple of `delta`, in an attempt to display a full map at lower resolution as quick as possible.
setRenderCacheOptions
Link copied to clipboard
open fun setRenderCacheOptions(options: RenderCacheOptions)
Enables or disables the experimental render cache feature.
setSize
Link copied to clipboard
open fun setSize(size: Size)
Sets the size of the map.
setStyleCustomGeometrySourceTileData
Link copied to clipboard
open fun setStyleCustomGeometrySourceTileData(sourceId: String, tileId: CanonicalTileID, featureCollection: List<Feature>): Expected<String, None>
Set tile data of a custom geometry.
setStyleJSON
Link copied to clipboard
open fun setStyleJSON(json: String)
Load the style from a provided JSON string.
setStyleLayerProperties
Link copied to clipboard
open fun setStyleLayerProperties(layerId: String, properties: Value): Expected<String, None>
Sets style layer properties.
setStyleLayerProperty
Link copied to clipboard
open fun setStyleLayerProperty(layerId: String, property: String, value: Value): Expected<String, None>
Sets a value to a style layer property.
setStyleLight
Link copied to clipboard
open fun setStyleLight(properties: Value): Expected<String, None>
Sets the style global [light](https://docs.mapbox.com/mapbox-gl-js/style-spec/#light) properties.
setStyleLightProperty
Link copied to clipboard
open fun setStyleLightProperty(property: String, value: Value): Expected<String, None>
Sets a value to the the style light property.
setStyleProjection
Link copied to clipboard
open fun setStyleProjection(properties: Value): Expected<String, None>
Sets the map's [projection](https://docs.mapbox.com/mapbox-gl-js/style-spec/projection/).
setStyleProjectionProperty
Link copied to clipboard
open fun setStyleProjectionProperty(property: String, value: Value): Expected<String, None>
Sets a value to the the style projection property.
setStyleSourceProperties
Link copied to clipboard
open fun setStyleSourceProperties(sourceId: String, properties: Value): Expected<String, None>
Sets style source properties.
setStyleSourceProperty
Link copied to clipboard
open fun setStyleSourceProperty(sourceId: String, property: String, value: Value): Expected<String, None>
Sets a value to a style source property.
setStyleTerrain
Link copied to clipboard
open fun setStyleTerrain(properties: Value): Expected<String, None>
Sets the style global [terrain](https://docs.mapbox.com/mapbox-gl-js/style-spec/#terrain) properties.
setStyleTerrainProperty
Link copied to clipboard
open fun setStyleTerrainProperty(property: String, value: Value): Expected<String, None>
Sets a value to the the style terrain property.
setStyleTransition
Link copied to clipboard
open fun setStyleTransition(transitionOptions: TransitionOptions)
Overrides the map style's transition options with user-provided options.
setStyleURI
Link copied to clipboard
open fun setStyleURI(uri: String)
Load style from provided URI.
setUserAnimationInProgress
Link copied to clipboard
open fun setUserAnimationInProgress(inProgress: Boolean)
Tells the map rendering engine that the animation is currently performed by the user (e.g.
setViewportMode
Link copied to clipboard
open fun setViewportMode(mode: ViewportMode)
Sets the `viewport mode`.
styleLayerExists
Link copied to clipboard
open fun styleLayerExists(layerId: String): Boolean
Checks whether a given style layer exists.
styleSourceExists
Link copied to clipboard
open fun styleSourceExists(sourceId: String): Boolean
Checks whether a given style source exists.
subscribe
Link copied to clipboard
open fun subscribe(observer: Observer, events: List<String>)
Subscribes an `observer` to a provided array of event types.
triggerRepaint
Link copied to clipboard
open fun triggerRepaint()
Triggers a repaint of the map.
unsubscribe
Link copied to clipboard
open fun unsubscribe(observer: Observer)
Unsubscribes an `observer` from all events.
open fun unsubscribe(observer: Observer, events: List<String>)
Unsubscribes an `observer` from a provided array of event types.
updateStyleImageSourceImage
Link copied to clipboard
open fun updateStyleImageSourceImage(sourceId: String, image: Image): Expected<String, None>
Updates the image of an [image style source](https://docs.mapbox.com/mapbox-gl-js/style-spec/#sources-image).
updateViewAnnotation
Link copied to clipboard
open fun updateViewAnnotation(identifier: String, options: ViewAnnotationOptions): Expected<String, None>