diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java
index 72df86d80..8118f9ad9 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java
@@ -184,7 +184,7 @@ public class MapSnapshotter {
* Starts loading and rendering the snapshot. The callbacks will be fired
* on the calling thread.
*
- * @param callback the callback to use when the snapshot is ready
+ * @param callback the callback to use when the snapshot is ready
* @param errorHandler the error handler to use on snapshot errors
*/
public void start(@NonNull MapboxMap.SnapshotReadyCallback callback, ErrorHandler errorHandler) {
@@ -197,12 +197,42 @@ public class MapSnapshotter {
nativeStart();
}
+ /**
+ * Updates the snapshotter with a new size
+ *
+ * @param width the width
+ * @param height the height
+ */
+ public native void setSize(int width, int height);
+
+ /**
+ * Updates the snapshotter with a new {@link CameraPosition}
+ *
+ * @param cameraPosition the camera position
+ */
+ public native void setCameraPosition(CameraPosition cameraPosition);
+
+ /**
+ * Updates the snapshotter with a new {@link LatLngBounds}
+ *
+ * @param region the region
+ */
+ public native void setRegion(LatLngBounds region);
+
+ /**
+ * Updates the snapshotter with a new style url
+ *
+ * @param styleUrl the style url
+ */
+ public native void setStyleUrl(String styleUrl);
+
+
/**
* Must be called in on the thread
* the object was created on.
*/
public void cancel() {
- callback = null;
+ reset();
nativeCancel();
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
index bf97749b9..d6237bc16 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
@@ -377,6 +377,16 @@
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.FeatureOverviewActivity"/>
+
+
+
+
+
+
+
+
+
+
+
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml
index 4d1f7eac3..94dc66978 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml
@@ -60,6 +60,7 @@
Shows how to animate georeferenced images
Show 2 MapView on screen with a bottom sheet
Show a static bitmap taken with the MapSnapshotter
+ Show how to reuse a MapSnapshotter instance
Use Android SDK Animators to animate camera position changes
Use Android SDK Views as symbols
\ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml
index 8f394d0eb..4942bcab3 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml
@@ -60,6 +60,7 @@
Animated Image Source
Bottom sheet
Map Snapshotter
+ Map Snapshotter Reuse
Animator animation
SymbolGenerator
\ No newline at end of file
diff --git a/platform/android/src/snapshotter/map_snapshotter.cpp b/platform/android/src/snapshotter/map_snapshotter.cpp
index d64218d11..74e43c70a 100644
--- a/platform/android/src/snapshotter/map_snapshotter.cpp
+++ b/platform/android/src/snapshotter/map_snapshotter.cpp
@@ -81,9 +81,26 @@ void MapSnapshotter::start(JNIEnv&) {
void MapSnapshotter::cancel(JNIEnv&) {
MBGL_VERIFY_THREAD(tid);
-
snapshotCallback.reset();
- snapshotter.reset();
+}
+
+
+void MapSnapshotter::setStyleUrl(JNIEnv& env, jni::String styleURL) {
+ snapshotter->setStyleURL(jni::Make(env, styleURL));
+}
+
+void MapSnapshotter::setSize(JNIEnv&, jni::jint width, jni::jint height) {
+ auto size = mbgl::Size { static_cast(width), static_cast(height) };
+ snapshotter->setSize(size);
+}
+
+void MapSnapshotter::setCameraPosition(JNIEnv& env, jni::Object position) {
+ auto options = CameraPosition::getCameraOptions(env, position);
+ snapshotter->setCameraOptions(options);
+}
+
+void MapSnapshotter::setRegion(JNIEnv& env, jni::Object region) {
+ snapshotter->setRegion(LatLngBounds::getLatLngBounds(env, region));
}
// Static methods //
@@ -101,6 +118,10 @@ void MapSnapshotter::registerNative(jni::JNIEnv& env) {
std::make_unique, jni::Object, jni::jfloat, jni::jint, jni::jint, jni::String, jni::Object, jni::Object, jni::String>,
"nativeInitialize",
"finalize",
+ METHOD(&MapSnapshotter::setStyleUrl, "setStyleUrl"),
+ METHOD(&MapSnapshotter::setSize, "setSize"),
+ METHOD(&MapSnapshotter::setCameraPosition, "setCameraPosition"),
+ METHOD(&MapSnapshotter::setRegion, "setRegion"),
METHOD(&MapSnapshotter::start, "nativeStart"),
METHOD(&MapSnapshotter::cancel, "nativeCancel")
);
diff --git a/platform/android/src/snapshotter/map_snapshotter.hpp b/platform/android/src/snapshotter/map_snapshotter.hpp
index 093f589c0..fa8a2d7a5 100644
--- a/platform/android/src/snapshotter/map_snapshotter.hpp
+++ b/platform/android/src/snapshotter/map_snapshotter.hpp
@@ -40,6 +40,14 @@ public:
~MapSnapshotter();
+ void setStyleUrl(JNIEnv&, jni::String styleURL);
+
+ void setSize(JNIEnv&, jni::jint width, jni::jint height);
+
+ void setCameraPosition(JNIEnv&, jni::Object position);
+
+ void setRegion(JNIEnv&, jni::Object region);
+
void start(JNIEnv&);
void cancel(JNIEnv&);
diff --git a/platform/default/mbgl/map/map_snapshotter.cpp b/platform/default/mbgl/map/map_snapshotter.cpp
index 058e03c71..e542e2fb5 100644
--- a/platform/default/mbgl/map/map_snapshotter.cpp
+++ b/platform/default/mbgl/map/map_snapshotter.cpp
@@ -76,6 +76,7 @@ std::string MapSnapshotter::Impl::getStyleURL() const {
void MapSnapshotter::Impl::setSize(Size size) {
map.setSize(size);
+ frontend.setSize(size);
}
Size MapSnapshotter::Impl::getSize() const {