diff options
author | kevin <kevin.li@mapbox.com> | 2020-03-09 18:26:23 +0800 |
---|---|---|
committer | kevin <kevin.li@mapbox.com> | 2020-03-24 10:39:42 +0800 |
commit | 239ce4f44950772a0013723e09072f6da69f3a43 (patch) | |
tree | 7bd2008fb568b43b64a044d91decb779f5b8c087 /platform/android/src/snapshotter/map_snapshotter.cpp | |
parent | 1adc436c9d883663b2d6fb0cb9014043fa7bc2b6 (diff) | |
download | qtlocation-mapboxgl-239ce4f44950772a0013723e09072f6da69f3a43.tar.gz |
[android] Add jni binding for styleable snapshotter
Diffstat (limited to 'platform/android/src/snapshotter/map_snapshotter.cpp')
-rw-r--r-- | platform/android/src/snapshotter/map_snapshotter.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/platform/android/src/snapshotter/map_snapshotter.cpp b/platform/android/src/snapshotter/map_snapshotter.cpp index 852e1f6adb..c3172c1cbd 100644 --- a/platform/android/src/snapshotter/map_snapshotter.cpp +++ b/platform/android/src/snapshotter/map_snapshotter.cpp @@ -37,13 +37,12 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env, auto size = mbgl::Size { static_cast<uint32_t>(width), static_cast<uint32_t>(height) }; showLogo = _showLogo; - // Create the core snapshotter snapshotter = std::make_unique<mbgl::MapSnapshotter>( size, pixelRatio, mbgl::android::FileSource::getSharedResourceOptions(_env, _jFileSource), - mbgl::MapSnapshotterObserver::nullObserver(), + observer, _localIdeographFontFamily ? jni::Make<std::string>(_env, _localIdeographFontFamily) : optional<std::string>{}); if (position) { @@ -126,6 +125,15 @@ void MapSnapshotter::setRegion(JNIEnv& env, const jni::Object<LatLngBounds>& reg snapshotter->setRegion(LatLngBounds::getLatLngBounds(env, region)); } +void MapSnapshotter::addLayer(JNIEnv &, jlong nativeLayerPtr) { + assert(nativeLayerPtr != 0); + Layer *layer = reinterpret_cast<Layer *>(nativeLayerPtr); + style::Layer &t = layer->get(); + std::unique_ptr<style::Layer> u (&t); + observer.didFinishLoadingStyleCallback= [&] { + snapshotter->getStyle().addLayer(std::move(u)); + }; +} // Private methods // @@ -157,6 +165,7 @@ void MapSnapshotter::registerNative(jni::JNIEnv& env) { "nativeInitialize", "finalize", METHOD(&MapSnapshotter::setStyleUrl, "setStyleUrl"), + METHOD(&MapSnapshotter::addLayer, "nativeAddLayer"), METHOD(&MapSnapshotter::setStyleJson, "setStyleJson"), METHOD(&MapSnapshotter::setSize, "setSize"), METHOD(&MapSnapshotter::setCameraPosition, "setCameraPosition"), |