@UiThread
public class MapSnapshotter
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
MapSnapshotter.ErrorHandler
Can be used to get notified of errors
in snapshot generation
|
static interface |
MapSnapshotter.Observer
Can be used to get notified on snapshotter style loading
completion.
|
static class |
MapSnapshotter.Options
MapSnapshotter options
|
static interface |
MapSnapshotter.SnapshotReadyCallback
Get notified on snapshot completion.
|
Constructor and Description |
---|
MapSnapshotter(android.content.Context context,
MapSnapshotter.Options options)
Creates the Map snapshotter, but doesn't start rendering or
loading yet.
|
Modifier and Type | Method and Description |
---|---|
void |
addImage(java.lang.String name,
android.graphics.Bitmap bitmap,
boolean sdf)
Adds an image to be used in the snapshotter's style
|
protected void |
addOverlay(MapSnapshot mapSnapshot)
Draw an overlay on the map snapshot.
|
void |
cancel()
Must be called in on the thread
the object was created on.
|
protected void |
finalize() |
Layer |
getLayer(java.lang.String layerId)
Returns Layer of a style that is used by a snapshotter
|
Source |
getSource(java.lang.String sourceId)
Returns Source of a style that is used by a snapshotter
|
protected void |
nativeCancel() |
protected void |
nativeInitialize(MapSnapshotter mapSnapshotter,
FileSource fileSource,
float pixelRatio,
int width,
int height,
java.lang.String styleUrl,
java.lang.String styleJson,
LatLngBounds region,
CameraPosition position,
boolean showLogo,
int glyphsRasterizationMode,
java.lang.String localIdeographFontFamily) |
protected void |
nativeStart() |
protected void |
onDidFailLoadingStyle(java.lang.String reason)
Called by JNI peer when snapshot style is ready.
|
protected void |
onDidFinishLoadingStyle()
Called by JNI peer when snapshot style is loaded.
|
protected void |
onSnapshotFailed(java.lang.String reason)
Called by JNI peer when snapshot has failed.
|
protected void |
onSnapshotReady(MapSnapshot snapshot)
Called by JNI peer when snapshot is ready.
|
protected void |
onStyleImageMissing(java.lang.String imageName)
Called by JNI peer when snapshot style image is missing.
|
protected void |
reset() |
void |
setCameraPosition(CameraPosition cameraPosition)
Updates the snapshotter with a new
CameraPosition |
void |
setObserver(MapSnapshotter.Observer observer)
Sets observer for a snapshotter
|
void |
setRegion(LatLngBounds region)
Updates the snapshotter with a new
LatLngBounds |
void |
setSize(int width,
int height)
Updates the snapshotter with a new size
|
void |
setStyleJson(java.lang.String styleJson)
Updates the snapshotter with a new style json
|
void |
setStyleUrl(java.lang.String styleUrl)
Updates the snapshotter with a new style url
|
void |
start(MapSnapshotter.SnapshotReadyCallback callback)
Starts loading and rendering the snapshot.
|
void |
start(MapSnapshotter.SnapshotReadyCallback callback,
MapSnapshotter.ErrorHandler errorHandler)
Starts loading and rendering the snapshot.
|
public MapSnapshotter(@NonNull android.content.Context context, @NonNull MapSnapshotter.Options options)
context
- the Context that is or contains the Application contextoptions
- the options to use for the snapshotpublic void start(@NonNull MapSnapshotter.SnapshotReadyCallback callback)
callback
- the callback to use when the snapshot is readypublic void start(@NonNull MapSnapshotter.SnapshotReadyCallback callback, MapSnapshotter.ErrorHandler errorHandler)
callback
- the callback to use when the snapshot is readyerrorHandler
- the error handler to use on snapshot errorspublic void setSize(int width, int height)
width
- the widthheight
- the heightpublic void setCameraPosition(CameraPosition cameraPosition)
CameraPosition
cameraPosition
- the camera positionpublic void setRegion(LatLngBounds region)
LatLngBounds
region
- the regionpublic void setStyleUrl(java.lang.String styleUrl)
styleUrl
- the style urlpublic void setStyleJson(java.lang.String styleJson)
styleJson
- the style jsonpublic void addImage(@NonNull java.lang.String name, @NonNull android.graphics.Bitmap bitmap, boolean sdf)
name
- the name of the imagebitmap
- the pre-multiplied Bitmapsdf
- the flag indicating image is an SDF or template imagepublic void cancel()
public void setObserver(@Nullable MapSnapshotter.Observer observer)
observer
- an Observer objectprotected void addOverlay(@NonNull MapSnapshot mapSnapshot)
mapSnapshot
- the map snapshot to draw the overlay onprotected void onSnapshotReady(@NonNull MapSnapshot snapshot)
snapshot
- the generated snapshotprotected void onSnapshotFailed(java.lang.String reason)
reason
- the exception stringprotected void onDidFailLoadingStyle(java.lang.String reason)
protected void onDidFinishLoadingStyle()
@Nullable public Layer getLayer(@NonNull java.lang.String layerId)
layerId
- the id of a Layer@Nullable public Source getSource(@NonNull java.lang.String sourceId)
sourceId
- the id of a Sourceprotected void onStyleImageMissing(java.lang.String imageName)
protected void reset()
protected void nativeInitialize(MapSnapshotter mapSnapshotter, FileSource fileSource, float pixelRatio, int width, int height, java.lang.String styleUrl, java.lang.String styleJson, LatLngBounds region, CameraPosition position, boolean showLogo, int glyphsRasterizationMode, java.lang.String localIdeographFontFamily)
protected void nativeStart()
protected void nativeCancel()
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable