MapSnapshotterInterface(androidJvm)

MapSnapshotter exposes functionality to capture static map images.

interface MapSnapshotterInterface(androidJvm) : CameraManagerInterface

Functions

addPersistentStyleCustomLayer
Link copied to clipboard

Adds a new [style custom layer](https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers). Note: This is an experimental API and is a subject to change. Whenever a new style is being parsed and currently used style has persistent layers, an engine will try to do following: - keep the persistent layer at its relative position - keep the source used by a persistent layer - keep images added through `addStyleImage` method In cases when a new style has the same layer, source or image resource, style's resources would be used instead and `MapLoadingError` event will be emitted.

abstract fun addPersistentStyleCustomLayer(layerId: String, layerHost: CustomLayerHost, layerPosition: LayerPosition): Expected<String, None>
addPersistentStyleLayer
Link copied to clipboard

Adds a new [style layer](https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers). Note: This is an experimental API and is a subject to change. Whenever a new style is being parsed and currently used style has persistent layers, an engine will try to do following: - keep the persistent layer at its relative position - keep the source used by a persistent layer - keep images added through `addStyleImage` method In cases when a new style has the same layer, source or image resource, style's resources would be used instead and `MapLoadingError` event will be emitted.

abstract fun addPersistentStyleLayer(properties: Value, layerPosition: LayerPosition): Expected<String, None>
addStyleCustomGeometrySource
Link copied to clipboard

Adds a custom geometry to be used in the style. To add the data, implement the fetchTileFunction callback in the options and call setStyleCustomGeometrySourceTileData()

abstract fun addStyleCustomGeometrySource(sourceId: String, options: CustomGeometrySourceOptions): Expected<String, None>
addStyleCustomLayer
Link copied to clipboard

Adds a new [style custom layer](https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers). Runtime style layers are valid until they are either removed or a new style is loaded.

abstract fun addStyleCustomLayer(layerId: String, layerHost: CustomLayerHost, layerPosition: LayerPosition): Expected<String, None>
addStyleImage
Link copied to clipboard

Adds an image to be used in the style. This API can also be used for updating an image. If the image for a given `imageId` was already added, it gets replaced by the new image. The image can be used in [`icon-image`](https://www.mapbox.com/mapbox-gl-js/style-spec/#layout-symbol-icon-image), [`fill-pattern`](https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-fill-fill-pattern), [`line-pattern`](https://www.mapbox.com/mapbox-gl-js/style-spec/#paint-line-line-pattern) and [`text-field`](https://www.mapbox.com/mapbox-gl-js/style-spec/#layout-symbol-text-field) properties.

abstract fun addStyleImage(imageId: String, scale: Float, image: Image, sdf: Boolean, stretchX: List<ImageStretches>, stretchY: List<ImageStretches>, content: ImageContent): Expected<String, None>
addStyleLayer
Link copied to clipboard

Adds a new [style layer](https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers). Runtime style layers are valid until they are either removed or a new style is loaded.

abstract fun addStyleLayer(properties: Value, layerPosition: LayerPosition): Expected<String, None>
addStyleSource
Link copied to clipboard

Adds a new [style source](https://docs.mapbox.com/mapbox-gl-js/style-spec/#sources).

abstract fun addStyleSource(sourceId: String, properties: Value): Expected<String, None>
cameraForCoordinateBounds
Link copied to clipboard

Convenience method that returns the `camera options` object for given parameters.

abstract fun cameraForCoordinateBounds(bounds: CoordinateBounds, padding: EdgeInsets, bearing: Double, pitch: Double): CameraOptions
cameraForCoordinates
Link copied to clipboard

Convenience method that adjusts the provided `camera options` object for given parameters. Returns the provided `camera` options with zoom adjusted to fit `coordinates` into the `box`, so that `coordinates` on the left, top and right of the effective `camera` center at the principal point of the projection (defined by `padding`) fit into the `box`. Returns the provided `camera` options object unchanged upon an error. Note that this method may fail if the principal point of the projection is not inside the `box` or if there is no sufficient screen space, defined by principal point and the `box`, to fit the geometry.

abstract fun cameraForCoordinates(coordinates: List<Point>, camera: CameraOptions, box: ScreenBox): CameraOptions

Convenience method that returns the `camera options` object for given parameters.

abstract fun cameraForCoordinates(coordinates: List<Point>, padding: EdgeInsets, bearing: Double, pitch: Double): CameraOptions
cameraForGeometry
Link copied to clipboard

Convenience method that returns the `camera options` object for given parameters.

abstract fun cameraForGeometry(geometry: Geometry, padding: EdgeInsets, bearing: Double, pitch: Double): CameraOptions
cancel
Link copied to clipboard

Cancel the current snapshot operation. Cancel the current snapshot operation, if any. The callback passed to the start method is called with error parameter set.

abstract fun cancel()
coordinateBoundsForCamera
Link copied to clipboard

Returns the `coordinate bounds` for a given camera. Note that if the given `camera` shows the antimeridian, the returned wrapped `coordinate bounds` might not represent the minimum bounding box.

abstract fun coordinateBoundsForCamera(camera: CameraOptions): CoordinateBounds
coordinateBoundsZoomForCamera
Link copied to clipboard

Returns the `coordinate bounds` and the `zoom` for a given `camera`. Note that if the given `camera` shows the antimeridian, the returned wrapped `coordinate bounds` might not represent the minimum bounding box.

abstract fun coordinateBoundsZoomForCamera(camera: CameraOptions): CoordinateBoundsZoom
coordinateBoundsZoomForCameraUnwrapped
Link copied to clipboard

Returns the unwrapped `coordinate bounds` and `zoom` for a given `camera`. This method is particularly useful, if the `camera` shows the antimeridian.

abstract fun coordinateBoundsZoomForCameraUnwrapped(camera: CameraOptions): CoordinateBoundsZoom
coordinateForPixel
Link copied to clipboard

Calculates a geographical `coordinate` (i.e., longitude-latitude pair) that corresponds to a `screen coordinate`. The screen coordinate is in `platform pixels`relative to the top left corner of the map (not of the whole screen).

abstract fun coordinateForPixel(pixel: ScreenCoordinate): Point
coordinatesForPixels
Link copied to clipboard

Calculates geographical `coordinates` (i.e., longitude-latitude pairs) that correspond to `screen coordinates`. The screen coordinates are in `platform pixels` relative to the top left corner of the map (not of the whole screen).

abstract fun coordinatesForPixels(pixels: List<ScreenCoordinate>): List<Point>
dragEnd
Link copied to clipboard

Ends the ongoing drag gesture. This function should be called always after the user has ended a drag gesture initiated by `dragStart`.

abstract fun dragEnd()
dragStart
Link copied to clipboard

Prepares the drag gesture to use the provided screen coordinate as a pivot `point`. This function should be called each time when user starts a dragging action (e.g. by clicking on the map). The following dragging will be relative to the pivot.

abstract fun dragStart(point: ScreenCoordinate)
getBounds
Link copied to clipboard

Returns the `camera bounds` of the map.

abstract fun getBounds(): CameraBounds
getCameraState
Link copied to clipboard

Returns the current `camera state`.

abstract fun getCameraState(): CameraState
getDragCameraOptions
Link copied to clipboard

Calculates target point where camera should move after drag. The method should be called after `dragStart` and before `dragEnd`.

abstract fun getDragCameraOptions(fromPoint: ScreenCoordinate, toPoint: ScreenCoordinate): CameraOptions
getElevation
Link copied to clipboard

Get elevation for the given coordinate. Note: Elevation is only available for the visible region on the screen.

abstract fun getElevation(coordinate: Point): Double
getFreeCameraOptions
Link copied to clipboard

Gets the map's current free camera options. After mutation, it should be set back to the map.

abstract fun getFreeCameraOptions(): FreeCameraOptions
getMapProjection
Link copied to clipboard

Returns the currently active map projection and its properties as key-value pairs. Common properties shared by all map projections are: - "name" with possible values "mercator" or "globe".

abstract fun getMapProjection(): Value
getSize
Link copied to clipboard

Gets the size of the snapshot

abstract fun getSize(): Size
getStyleDefaultCamera
Link copied to clipboard

Returns the map style's default camera, if any, or a default camera otherwise. The map style's default camera is defined as follows: - [center](https://docs.mapbox.com/mapbox-gl-js/style-spec/#root-center) - [zoom](https://docs.mapbox.com/mapbox-gl-js/style-spec/#root-zoom) - [bearing](https://docs.mapbox.com/mapbox-gl-js/style-spec/#root-bearing) - [pitch](https://docs.mapbox.com/mapbox-gl-js/style-spec/#root-pitch) The style default camera is re-evaluated when a new style is loaded.

abstract fun getStyleDefaultCamera(): CameraOptions
getStyleImage
Link copied to clipboard

Get an `image` from the style.

abstract fun getStyleImage(imageId: String): Image
getStyleJSON
Link copied to clipboard

Get the JSON serialization string of the current style in use.

abstract fun getStyleJSON(): String
getStyleLayerProperties
Link copied to clipboard

Gets style layer properties.

abstract fun getStyleLayerProperties(layerId: String): Expected<String, Value>
getStyleLayerProperty
Link copied to clipboard

Gets the value of style layer property.

abstract fun getStyleLayerProperty(layerId: String, property: String): StylePropertyValue
getStyleLayers
Link copied to clipboard

Returns the existing style layers.

abstract fun getStyleLayers(): List<StyleObjectInfo>
getStyleLightProperty
Link copied to clipboard

Gets the value of a style light property.

abstract fun getStyleLightProperty(property: String): StylePropertyValue
getStyleSourceProperties
Link copied to clipboard

Gets style source properties.

abstract fun getStyleSourceProperties(sourceId: String): Expected<String, Value>
getStyleSourceProperty
Link copied to clipboard

Gets the value of style source property.

abstract fun getStyleSourceProperty(sourceId: String, property: String): StylePropertyValue
getStyleSources
Link copied to clipboard

Returns the existing style sources.

abstract fun getStyleSources(): List<StyleObjectInfo>
getStyleTerrainProperty
Link copied to clipboard

Gets the value of a style terrain property.

abstract fun getStyleTerrainProperty(property: String): StylePropertyValue
getStyleTransition
Link copied to clipboard

Returns the map style's transition options. By default, the style parser will attempt to read the style default transition options, if any, fallbacking to an immediate transition otherwise. Transition options can be overriden via `setStyleTransition`, but the options are reset once a new style has been loaded. The style transition is re-evaluated when a new style is loaded.

abstract fun getStyleTransition(): TransitionOptions
getStyleURI
Link copied to clipboard

Get the URI of the current style in use.

abstract fun getStyleURI(): String

Invalidate region for provided custom geometry source.

abstract fun invalidateStyleCustomGeometrySourceRegion(sourceId: String, bounds: CoordinateBounds): Expected<String, None>
invalidateStyleCustomGeometrySourceTile
Link copied to clipboard

Invalidate tile for provided custom geometry source.

abstract fun invalidateStyleCustomGeometrySourceTile(sourceId: String, tileId: CanonicalTileID): Expected<String, None>
isInTileMode
Link copied to clipboard

Returns `true` if the snapshotter is in the tile mode.

abstract fun isInTileMode(): Boolean
isStyleLayerPersistent
Link copied to clipboard

Checks if a style layer is persistent. Note: This is an experimental API and is a subject to change.

abstract fun isStyleLayerPersistent(layerId: String): Expected<String, Boolean>
isStyleLoaded
Link copied to clipboard

Check if the style is completely loaded. Note: The style specified sprite would be marked as loaded even with sprite loading error (An error will be emitted via `MapLoadingError`). Sprite loading error is not fatal and we don't want it to block the map rendering, thus the function will still return `true` if style and sources are fully loaded.

abstract fun isStyleLoaded(): Boolean
moveStyleLayer
Link copied to clipboard

Moves an existing style layer

abstract fun moveStyleLayer(layerId: String, layerPosition: LayerPosition): Expected<String, None>
pixelForCoordinate
Link copied to clipboard

Calculates a `screen coordinate` that corresponds to a geographical coordinate (i.e., longitude-latitude pair). The `screen coordinate` is in `platform pixels` relative to the top left corner of the map (not of the whole screen).

abstract fun pixelForCoordinate(coordinate: Point): ScreenCoordinate
pixelsForCoordinates
Link copied to clipboard

Calculates `screen coordinates` that correspond to geographical `coordinates` (i.e., longitude-latitude pairs). The `screen coordinates` are in `platform pixels` relative to the top left corner of the map (not of the whole screen).

abstract fun pixelsForCoordinates(coordinates: List<Point>): List<ScreenCoordinate>
removeStyleImage
Link copied to clipboard

Removes an image from the style.

abstract fun removeStyleImage(imageId: String): Expected<String, None>
removeStyleLayer
Link copied to clipboard

Removes an existing style layer.

abstract fun removeStyleLayer(layerId: String): Expected<String, None>
removeStyleSource
Link copied to clipboard

Removes an existing style source.

abstract fun removeStyleSource(sourceId: String): Expected<String, None>
setBounds
Link copied to clipboard

Sets the `camera bounds options` of the map. The map will retain its current values for any details not passed via the camera bounds options arguments. When camera bounds options are set, the camera center is constrained by these bounds, as well as the minimum zoom level of the camera, to prevent out of bounds areas to be visible. Note that tilting or rotating the map, or setting stricter minimum and maximum zoom within `options` may still cause some out of bounds areas to become visible.

abstract fun setBounds(options: CameraBoundsOptions): Expected<String, None>
setCamera
Link copied to clipboard

Changes the map view by any combination of center, zoom, bearing, and pitch, without an animated transition. The map will retain its current values for any details not passed via the camera options argument. It is not guaranteed that the provided `camera options` will be set, the map may apply constraints resulting in a different `camera state`.

abstract fun setCamera(cameraOptions: CameraOptions)

Sets the map view with the free camera options. The `free camera options` provides more direct access to the underlying camera entity. For backwards compatibility the state set using this API must be representable with `camera options` as well. Parameters are clamped to a valid range or discarded as invalid if the conversion to the pitch and bearing presentation is ambiguous. For example orientation can be invalid if it leads to the camera being upside down or the quaternion has zero length.

abstract fun setCamera(freeCameraOptions: FreeCameraOptions)
setMapProjection
Link copied to clipboard

Updates the active map projection. The function expects a collection of common and projection specific properties. Common properties shared by all map projections are: - "name" with possible values "mercator" or "globe".

abstract fun setMapProjection(projection: Value): Expected<String, None>
setSize
Link copied to clipboard

Sets the `size` of the snapshot

abstract fun setSize(size: Size)
setStyleCustomGeometrySourceTileData
Link copied to clipboard

Set tile data of a custom geometry.

abstract fun setStyleCustomGeometrySourceTileData(sourceId: String, tileId: CanonicalTileID, featureCollection: List<Feature>): Expected<String, None>
setStyleJSON
Link copied to clipboard

Load the style from a provided JSON string.

abstract fun setStyleJSON(json: String)
setStyleLayerProperties
Link copied to clipboard

Sets style layer properties. This method can be used to perform batch update for a style layer properties. The structure of a provided `properties` value must conform to a format for a corresponding [layer type](https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/). Modification of a layer [id](https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#id) and/or a [layer type] (https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#type) is not allowed.

abstract fun setStyleLayerProperties(layerId: String, properties: Value): Expected<String, None>
setStyleLayerProperty
Link copied to clipboard

Sets a value to a style layer property.

abstract fun setStyleLayerProperty(layerId: String, property: String, value: Value): Expected<String, None>
setStyleLight
Link copied to clipboard

Sets the style global [light](https://docs.mapbox.com/mapbox-gl-js/style-spec/#light) properties.

abstract fun setStyleLight(properties: Value): Expected<String, None>
setStyleLightProperty
Link copied to clipboard

Sets a value to the the style light property.

abstract fun setStyleLightProperty(property: String, value: Value): Expected<String, None>
setStyleSourceProperties
Link copied to clipboard

Sets style source properties. This method can be used to perform batch update for a style source properties. The structure of a provided `properties` value must conform to a format for a corresponding [source type](https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/). Modification of a source [type](https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#type) is not allowed.

abstract fun setStyleSourceProperties(sourceId: String, properties: Value): Expected<String, None>
setStyleSourceProperty
Link copied to clipboard

Sets a value to a style source property. Note: When setting the `data` property of a `geojson` source, this method never returns an error. In case of success, a `map-loaded` event will be propagated. In case of errors, a `map-loading-error` event will be propagated instead.

abstract fun setStyleSourceProperty(sourceId: String, property: String, value: Value): Expected<String, None>
setStyleTerrain
Link copied to clipboard

Sets the style global [terrain](https://docs.mapbox.com/mapbox-gl-js/style-spec/#terrain) properties.

abstract fun setStyleTerrain(properties: Value): Expected<String, None>
setStyleTerrainProperty
Link copied to clipboard

Sets a value to the the style terrain property.

abstract fun setStyleTerrainProperty(property: String, value: Value): Expected<String, None>
setStyleTransition
Link copied to clipboard

Overrides the map style's transition options with user-provided options. The style transition is re-evaluated when a new style is loaded.

abstract fun setStyleTransition(transitionOptions: TransitionOptions)
setStyleURI
Link copied to clipboard

Load style from provided URI. This is an asynchronous call. To check the result of this operation the user must register an observer observing `MapLoaded` or `MapLoadingError` events. In case of successful style load, `StyleLoaded` event will be also emitted.

abstract fun setStyleURI(uri: String)
setTileMode
Link copied to clipboard

Sets the snapshotter to the tile mode. In the tile mode, the snapshotter fetches the still image of a single tile.

abstract fun setTileMode(set: Boolean)
start
Link copied to clipboard

Start the rendering of a snapshot. Request that a new snapshot be rendered. If there is a pending snapshot request, it is cancelled automatically.

abstract fun start(callback: SnapshotCompleteCallback)
styleLayerExists
Link copied to clipboard

Checks whether a given style layer exists.

abstract fun styleLayerExists(layerId: String): Boolean
styleSourceExists
Link copied to clipboard

Checks whether a given style source exists.

abstract fun styleSourceExists(sourceId: String): Boolean
subscribe
Link copied to clipboard

Subscribes an `observer` to a provided array of event types. The `observable` will hold a strong reference to an `observer` instance, therefore, in order to stop receiving notifications, caller must call `unsubscribe` with an `observer` instance used for an initial subscription.

abstract fun subscribe(observer: Observer, events: List<String>)
unsubscribe
Link copied to clipboard

Unsubscribes an `observer` from all events.

abstract fun unsubscribe(observer: Observer)

Unsubscribes an `observer` from a provided array of event types.

abstract fun unsubscribe(observer: Observer, events: List<String>)
updateStyleImageSourceImage
Link copied to clipboard

Updates the image of an [image style source](https://docs.mapbox.com/mapbox-gl-js/style-spec/#sources-image).

abstract fun updateStyleImageSourceImage(sourceId: String, image: Image): Expected<String, None>

Inheritors

MapSnapshotter
Link copied to clipboard