Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Add styleable snapshotter.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin committed Mar 9, 2020
1 parent 04722fd commit c6b289a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.maps.TelemetryDefinition;
import com.mapbox.mapboxsdk.storage.FileSource;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.utils.FontUtils;
import com.mapbox.mapboxsdk.utils.ThreadUtils;

Expand Down Expand Up @@ -412,6 +413,15 @@ public void start(@NonNull SnapshotReadyCallback callback, ErrorHandler errorHan
@Keep
public native void setStyleJson(String styleJson);

/**
* Add a new layer to snapshotter before snapshotter starts.
*
* @param layer the layer to add.
*/
public void addLayer(Layer layer){
nativeAddLayer(layer.getNativePtr());
}

/**
* Must be called in on the thread
* the object was created on.
Expand Down Expand Up @@ -631,6 +641,9 @@ protected native void nativeInitialize(MapSnapshotter mapSnapshotter,
@Keep
protected native void nativeCancel();

@Keep
protected native void nativeAddLayer(long id);

@Override
@Keep
protected native void finalize() throws Throwable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mapbox.mapboxsdk.testapp.activity.snapshot;

import android.graphics.Color;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.view.ViewTreeObserver;
Expand All @@ -12,6 +13,7 @@
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.snapshotter.MapSnapshotter;
import com.mapbox.mapboxsdk.style.layers.FillLayer;
import com.mapbox.mapboxsdk.testapp.R;

import java.util.ArrayList;
Expand All @@ -20,6 +22,9 @@

import timber.log.Timber;

import static com.mapbox.mapboxsdk.style.expressions.Expression.color;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor;

/**
* Test activity showing how to use a the {@link com.mapbox.mapboxsdk.snapshotter.MapSnapshotter}
*/
Expand Down Expand Up @@ -96,6 +101,10 @@ private void startSnapShot(final int row, final int column) {

MapSnapshotter snapshotter = new MapSnapshotter(MapSnapshotterActivity.this, options);

FillLayer water = new FillLayer("water","mapbox");
water.setProperties(fillColor(color(Color.GREEN)));

snapshotter.addLayer(water);
snapshotter.start(snapshot -> {
Timber.i("Got the snapshot");
ImageView imageView = new ImageView(MapSnapshotterActivity.this);
Expand Down
2 changes: 1 addition & 1 deletion vendor/mapbox-gl-native
Submodule mapbox-gl-native updated 65 files
+35 −5 CHANGELOG.md
+5 −3 CMakeLists.txt
+11 −1 circle.yml
+1 −1 include/mbgl/style/expression/within.hpp
+2 −2 include/mbgl/style/sources/geojson_source.hpp
+1 −1 mapbox-gl-js
+35 −0 metrics/android-render-test-runner/render-tests/tile-mode/streets-v11/metrics.json
+1 −1 metrics/binary-size/android-x86_64/metrics.json
+4 −4 metrics/binary-size/linux-clang8/metrics.json
+3 −3 metrics/binary-size/linux-gcc8/metrics.json
+1 −1 metrics/binary-size/macos-xcode11/metrics.json
+ metrics/cache-style.db
+4 −2 metrics/ignores/platform-all.json
+35 −0 metrics/ios-render-test-runner/render-tests/tile-mode/streets-v11/metrics.json
+35 −0 metrics/linux-clang8-release/render-tests/tile-mode/streets-v11/metrics.json
+35 −0 metrics/linux-gcc8-release/render-tests/tile-mode/streets-v11/metrics.json
+1 −0 metrics/macos-xcode11-debug-coverage-nightly-style.json
+0 −15 misc/buck/.buckconfig
+0 −4 misc/buck/mapbox-gl-native/Android.mk
+0 −2 misc/buck/mapbox-gl-native/Application.mk
+0 −151 misc/buck/mapbox-gl-native/BUCK
+0 −1 misc/buck/mapbox-gl-native/include
+0 −1 misc/buck/mapbox-gl-native/platform
+0 −1 misc/buck/mapbox-gl-native/src
+0 −1 misc/buck/mapbox-gl-native/vendor
+29 −26 platform/android/src/snapshotter/map_snapshotter.cpp
+14 −4 platform/android/src/snapshotter/map_snapshotter.hpp
+23 −14 platform/default/include/mbgl/map/map_snapshotter.hpp
+34 −3 platform/default/include/mbgl/storage/offline_database.hpp
+11 −12 platform/default/src/mbgl/i18n/number_format.cpp
+239 −146 platform/default/src/mbgl/map/map_snapshotter.cpp
+113 −22 platform/default/src/mbgl/storage/offline_database.cpp
+5 −1 platform/glfw/CMakeLists.txt
+117 −50 platform/glfw/glfw_view.cpp
+8 −1 platform/glfw/glfw_view.hpp
+3 −3 platform/glfw/main.cpp
+19 −4 platform/linux/linux.cmake
+30 −21 render-test/parser.cpp
+9 −6 render-test/runner.cpp
+5 −0 src/mbgl/annotation/annotation_manager.hpp
+8 −2 src/mbgl/annotation/annotation_tile.cpp
+1 −1 src/mbgl/annotation/annotation_tile.hpp
+18 −20 src/mbgl/map/map_impl.cpp
+4 −1 src/mbgl/renderer/render_orchestrator.cpp
+3 −1 src/mbgl/renderer/tile_parameters.hpp
+3 −1 src/mbgl/renderer/update_parameters.hpp
+49 −41 src/mbgl/style/expression/within.cpp
+1 −1 src/mbgl/text/collision_index.cpp
+1 −1 src/mbgl/text/collision_index.hpp
+43 −37 src/mbgl/text/placement.cpp
+13 −0 src/mbgl/util/geometry_within.cpp
+11 −0 test/CMakeLists.txt
+ test/fixtures/map/map_snapshotter_overlay/expected.png
+2 −2 test/fixtures/map/online/style.json
+ test/fixtures/offline_database/no_auto_vacuum.db
+138 −0 test/map/map_snapshotter.test.cpp
+52 −8 test/storage/offline_database.test.cpp
+5 −0 test/style/property_expression.test.cpp
+1 −1 test/style/source.test.cpp
+9 −11 test/tile/custom_geometry_tile.test.cpp
+9 −11 test/tile/geojson_tile.test.cpp
+9 −11 test/tile/raster_dem_tile.test.cpp
+9 −11 test/tile/raster_tile.test.cpp
+1 −1 test/tile/tile_cache.test.cpp
+9 −11 test/tile/vector_tile.test.cpp

0 comments on commit c6b289a

Please sign in to comment.