Package com.mapbox.mapboxsdk.snapshotter
Contains the Mapbox Maps Android Snapshotter API classes.
Types
Name | Summary |
---|---|
MapSnaphotUtil | open class MapSnaphotUtil |
MapSnapshot | open class MapSnapshot A completed snapshot. |
MapSnapshotter | @UiThread() open class MapSnapshotter The map snapshotter creates a large of the map, rendered off the UI thread. |
MapSnaphotUtil
open class MapSnaphotUtil
Functions
Name | Summary |
---|---|
calculateInSampleSize | open fun calculateInSampleSize(options: BitmapFactory.Options, reqWidth: Int, reqHeight: Int): Int |
calculateInSampleSize
open fun calculateInSampleSize(options: BitmapFactory.Options, reqWidth: Int, reqHeight: Int): Int
MapSnapshot
open class MapSnapshot
A completed snapshot.
See also
Name | Summary |
---|---|
com.mapbox.mapboxsdk.snapshotter.MapSnapshotter | |
Functions
Name | Summary |
---|---|
isShowLogo | open fun isShowLogo(): Boolean Flag indicating to show the Mapbox logo. |
latLngForPixel | @NonNull() open fun latLngForPixel(pointF: PointF): LatLng Calculate geographical coordinates from a point in pixels on the Image |
pixelForLatLng | @NonNull() open fun pixelForLatLng(latLng: LatLng): PointF Calculate the point in pixels on the Image from geographical coordinates. |
Properties
Name | Summary |
---|---|
bitmap | private open val bitmap: Bitmap |
bitmap
private open val bitmap: Bitmap
isShowLogo
open fun isShowLogo(): Boolean
Return
Flag indicating to show the Mapbox logo.
latLngForPixel
@NonNull()
open fun latLngForPixel(pointF: PointF): LatLng
Calculate geographical coordinates from a point in pixels on the Image
Return
the geographical coordinates
Parameters
Name | Summary |
---|---|
pointF | the point in pixels |
pixelForLatLng
@NonNull()
open fun pixelForLatLng(latLng: LatLng): PointF
Calculate the point in pixels on the Image from geographical coordinates.
Return
the point on the image
Parameters
Name | Summary |
---|---|
latLng | the geographical coordinates |
MapSnapshotter
@UiThread()
open class MapSnapshotter
The map snapshotter creates a large of the map, rendered off the UI thread. The snapshotter itself must be used on the UI thread (for access to the main looper)
Constructors
Name | Summary |
---|---|
MapSnapshotter | open fun MapSnapshotter(context: Context, options: MapSnapshotter.Options)Creates the Map snapshotter, but doesn’t start rendering orloading yet. |
Types
Name | Summary |
---|---|
ErrorHandler | interface ErrorHandler Can be used to get notified of errorsin snapshot generation |
Observer | interface Observer Can be used to get notified on snapshotter style loadingcompletion. |
Options | open class Options MapSnapshotter options |
SnapshotReadyCallback | interface SnapshotReadyCallback Get notified on snapshot completion. |
Functions
Name | Summary |
---|---|
addImage | open fun addImage(name: String, bitmap: Bitmap, sdf: Boolean) Adds an image to be used in the snapshotter’s style |
cancel | open fun cancel() Must be called in on the threadthe object was created on. |
getLayer | @Nullable() open fun getLayer(layerId: String): Layer Returns Layer of a style that is used by a snapshotter |
getSource | @Nullable() open fun getSource(sourceId: String): Source Returns Source of a style that is used by a snapshotter |
setCameraPosition | open fun setCameraPosition(cameraPosition: CameraPosition) Updates the snapshotter with a new CameraPosition |
setRegion | open fun setRegion(region: LatLngBounds) Updates the snapshotter with a new LatLngBounds |
setSize | open fun setSize(width: Int, height: Int) Updates the snapshotter with a new size |
setStyleJson | open fun setStyleJson(styleJson: String) Updates the snapshotter with a new style json |
setStyleUrl | open fun setStyleUrl(styleUrl: String) Updates the snapshotter with a new style url |
start | open fun start(callback: MapSnapshotter.SnapshotReadyCallback) open fun start(callback: MapSnapshotter.SnapshotReadyCallback, errorHandler: MapSnapshotter.ErrorHandler) Starts loading and rendering the snapshot. |
Properties
Name | Summary |
---|---|
observer | @Nullable() private open var observer: MapSnapshotter.Observer |
addImage
open fun addImage(name: String, bitmap: Bitmap, sdf: Boolean)
Adds an image to be used in the snapshotter’s style
Parameters
Name | Summary |
---|---|
name | the name of the image |
bitmap | the pre-multiplied Bitmap |
sdf | the flag indicating image is an SDF or template image |
cancel
open fun cancel()
Must be called in on the threadthe object was created on.
getLayer
@Nullable()
open fun getLayer(layerId: String): Layer
Returns Layer of a style that is used by a snapshotter
Return
the Layer object if Layer with layerId exists, null otherwise
Parameters
Name | Summary |
---|---|
layerId | the id of a Layer |
getSource
@Nullable()
open fun getSource(sourceId: String): Source
Returns Source of a style that is used by a snapshotter
Return
the Source object if a Source with sourceId exists, null otherwise
Parameters
Name | Summary |
---|---|
sourceId | the id of a Source |
observer
@Nullable()
private open var observer: MapSnapshotter.Observer
setCameraPosition
open fun setCameraPosition(cameraPosition: CameraPosition)
Updates the snapshotter with a new CameraPosition
Parameters
Name | Summary |
---|---|
cameraPosition | the camera position |
setRegion
open fun setRegion(region: LatLngBounds)
Updates the snapshotter with a new LatLngBounds
Parameters
Name | Summary |
---|---|
region | the region |
setSize
open fun setSize(width: Int, height: Int)
Updates the snapshotter with a new size
Parameters
Name | Summary |
---|---|
width | the width |
height | the height |
setStyleJson
open fun setStyleJson(styleJson: String)
Updates the snapshotter with a new style json
Parameters
Name | Summary |
---|---|
styleJson | the style json |
setStyleUrl
open fun setStyleUrl(styleUrl: String)
Updates the snapshotter with a new style url
Parameters
Name | Summary |
---|---|
styleUrl | the style url |
start
open fun start(callback: MapSnapshotter.SnapshotReadyCallback)
Starts loading and rendering the snapshot. The callback will be firedon the calling thread.
Parameters
Name | Summary |
---|---|
callback | the callback to use when the snapshot is ready |
open fun start(callback: MapSnapshotter.SnapshotReadyCallback, errorHandler: MapSnapshotter.ErrorHandler)
Starts loading and rendering the snapshot. The callbacks will be firedon the calling thread.
Parameters
Name | Summary |
---|---|
callback | the callback to use when the snapshot is ready |
errorHandler | the error handler to use on snapshot errors |
ErrorHandler
interface ErrorHandler
Can be used to get notified of errorsin snapshot generation
See also
Name | Summary |
---|---|
com.mapbox.mapboxsdk.snapshotter.MapSnapshotter | MapSnapshotter#start(SnapshotReadyCallback, ErrorHandler) |
Functions
Name | Summary |
---|---|
onError | abstract fun onError(error: String) Called on error. |
onError
abstract fun onError(error: String)
Called on error. Snapshotting will notcontinue
Parameters
Name | Summary |
---|---|
error | the error message |
Observer
interface Observer
Can be used to get notified on snapshotter style loadingcompletion.
See also
Name | Summary |
---|---|
com.mapbox.mapboxsdk.snapshotter.MapSnapshotter | MapSnapshotter#setObserver(Observer) |
Functions
Name | Summary |
---|---|
onDidFinishLoadingStyle | abstract fun onDidFinishLoadingStyle() Called when snapshotter finishes loading its style. |
onStyleImageMissing | abstract fun onStyleImageMissing(imageName: String) Called when the map is missing an icon. |
onDidFinishLoadingStyle
abstract fun onDidFinishLoadingStyle()
Called when snapshotter finishes loading its style.
onStyleImageMissing
abstract fun onStyleImageMissing(imageName: String)
Called when the map is missing an icon.The icon should be added synchronously with addImage to be rendered on the current zoom level.When loading icons asynchronously, you can load a placeholder image and replace it when you icon has loaded.
Parameters
Name | Summary |
---|---|
imageName | the id of the icon that is missing |
Options
open class Options
MapSnapshotter options
Constructors
Name | Summary |
---|---|
Options | open fun Options(width: Int, height: Int)the width of the image |
Functions
Name | Summary |
---|---|
getApiBaseUri | @Nullable() open fun getApiBaseUri(): String The base of our API endpoint |
getStyleJson | @Nullable() open fun getStyleJson(): String the style json |
getStyleUri | open fun getStyleUri(): String the style uri |
withApiBaseUri | @NonNull() open fun withApiBaseUri(apiBaseUri: String): MapSnapshotter.Options Specifies the URI used for API endpoint. |
withCameraPosition | @NonNull() open fun withCameraPosition(cameraPosition: CameraPosition): MapSnapshotter.Options The camera position to use,the target is overriddenby region if set in conjunction. |
withLocalIdeographFontFamily | @NonNull() open fun withLocalIdeographFontFamily(fontFamilies: Array Set a font family from range of font families for generating glyphs locally for ideographs in the'CJK Unified Ideographs' and 'Hangul Syllables' ranges. @NonNull() open fun [withLocalIdeographFontFamily](#withlocalideographfontfamily)(fontFamily: String): [MapSnapshotter.Options](#mapsnapshotter.options) Set the font family for generating glyphs locally for ideographs in the 'CJK Unified Ideographs'and 'Hangul Syllables' ranges. |
withLogo | @NonNull() open fun withLogo(showLogo: Boolean): MapSnapshotter.Options The flag indicating to show the Mapbox logo. |
withPixelRatio | @NonNull() open fun withPixelRatio(pixelRatio: Float): MapSnapshotter.Options the pixel ratio to use (default: 1) |
withRegion | @NonNull() open fun withRegion(region: LatLngBounds): MapSnapshotter.Options the region to show in the snapshot. |
withStyle | @NonNull() open fun withStyle(uri: String): MapSnapshotter.Options The style URI to use |
withStyleBuilder | @NonNull() open fun withStyleBuilder(builder: Style.Builder): MapSnapshotter.Options Set a style builder to snapshotter, the contents in builder like layers/sources/images will be appliedto snapshotter. |
withStyleJson | @NonNull() open fun withStyleJson(styleJson: String): MapSnapshotter.Options The style json to use |
Properties
Name | Summary |
---|---|
apiBaseUrl | private open val apiBaseUrl: String |
builder | private open val builder: Style.Builder |
cameraPosition | private open val cameraPosition: CameraPosition |
height | private open val height: Int |
localIdeographFontFamily | private open val localIdeographFontFamily: String |
pixelRatio | private open val pixelRatio: Float |
region | private open val region: LatLngBounds |
width | private open val width: Int |
apiBaseUrl
private open val apiBaseUrl: String
builder
private open val builder: Style.Builder
cameraPosition
private open val cameraPosition: CameraPosition
getApiBaseUri
@Nullable()
open fun getApiBaseUri(): String
Return
The base of our API endpoint
getStyleJson
@Nullable()
open fun getStyleJson(): String
Return
the style json
getStyleUri
open fun getStyleUri(): String
Return
the style uri
height
private open val height: Int
localIdeographFontFamily
private open val localIdeographFontFamily: String
pixelRatio
private open val pixelRatio: Float
region
private open val region: LatLngBounds
width
private open val width: Int
withApiBaseUri
@NonNull()
open fun withApiBaseUri(apiBaseUri: String): MapSnapshotter.Options
Specifies the URI used for API endpoint.
Return
the mutated Options
Parameters
Name | Summary |
---|---|
apiBaseUri | The base of our API endpoint |
withCameraPosition
@NonNull()
open fun withCameraPosition(cameraPosition: CameraPosition): MapSnapshotter.Options
Return
the mutated Options
Parameters
Name | Summary |
---|---|
cameraPosition | The camera position to use,the target is overriddenby region if set in conjunction. |
withLocalIdeographFontFamily
@NonNull()
open fun withLocalIdeographFontFamily(fontFamily: String): MapSnapshotter.Options
Set the font family for generating glyphs locally for ideographs in the ‘CJK Unified Ideographs’and ‘Hangul Syllables’ ranges.
The font family argument is passed to create.Default system fonts are defined in ‘/system/etc/fonts.xml’Default font for local ideograph font family is DEFAULT_FONT.
Return
the mutated Options
Parameters
Name | Summary |
---|---|
fontFamily | font family for local ideograph generation. |
@NonNull()
open fun withLocalIdeographFontFamily(fontFamilies: Array
Set a font family from range of font families for generating glyphs locally for ideographs in the’CJK Unified Ideographs’ and ‘Hangul Syllables’ ranges.
The font families are checked against the default system fonts defined in’/system/etc/fonts.xml’. Default font for local ideograph font family is DEFAULT_FONT.
Return
the mutated Options
Parameters
Name | Summary |
---|---|
fontFamilies | font families for local ideograph generation. |
withLogo
@NonNull()
open fun withLogo(showLogo: Boolean): MapSnapshotter.Options
Return
the mutated Options
Parameters
Name | Summary |
---|---|
showLogo | The flag indicating to show the Mapbox logo. |
withPixelRatio
@NonNull()
open fun withPixelRatio(pixelRatio: Float): MapSnapshotter.Options
Return
the mutated Options
Parameters
Name | Summary |
---|---|
pixelRatio | the pixel ratio to use (default: 1) |
withRegion
@NonNull()
open fun withRegion(region: LatLngBounds): MapSnapshotter.Options
Return
the mutated Options
Parameters
Name | Summary |
---|---|
region | the region to show in the snapshot.This is applied after the camera position |
withStyleBuilder
@NonNull()
open fun withStyleBuilder(builder: Style.Builder): MapSnapshotter.Options
Set a style builder to snapshotter, the contents in builder like layers/sources/images will be appliedto snapshotter.
Return
the mutated Options
Parameters
Name | Summary |
---|---|
builder | The builder will applied to snapshotter |
withStyleJson
@NonNull()
open fun withStyleJson(styleJson: String): MapSnapshotter.Options
Return
the mutated Options
Deprecated
use withStyleBuilder instead
Parameters
Name | Summary |
---|---|
styleJson | The style json to use |
withStyle
@NonNull()
open fun withStyle(uri: String): MapSnapshotter.Options
Return
the mutated Options
Deprecated
use withStyleBuilder instead
Parameters
Name | Summary |
---|---|
uri | The style URI to use |
SnapshotReadyCallback
interface SnapshotReadyCallback
Get notified on snapshot completion.
See also
Name | Summary |
---|---|
com.mapbox.mapboxsdk.snapshotter.MapSnapshotter | MapSnapshotter#start(SnapshotReadyCallback, ErrorHandler) |
Functions
Name | Summary |
---|---|
onSnapshotReady | abstract fun onSnapshotReady(snapshot: MapSnapshot) Called when the snapshot is complete. |
onSnapshotReady
abstract fun onSnapshotReady(snapshot: MapSnapshot)
Called when the snapshot is complete.
Parameters
Name | Summary |
---|---|
snapshot | the snapshot |
Android SDK
SDK JS Reference
- Root
- attribution
- camera
- constants
- exceptions
- geometry
- http
- location
- location.engine
- location.modes
- location.permissions
- log
- maps
- maps.renderer
- maps.renderer.egl
- maps.renderer.glsurfaceview
- maps.renderer.textureview
- maps.widgets
- module.http
- module.loader
- net
- offline
- snapshotter
- storage
- style.expressions
- style.layers
- style.light
- style.sources
- style.types
- text
- utils