Fix onStyleImageMissing not fired in Snapshotter (#317)
* Modify example to trigger OnStyleMissing callback * Fix onStyleImageMissing callback not works in snapshotter. * Update gl-native * Update doc * Fix android check
This commit is contained in:
@@ -138,7 +138,8 @@ public class MapSnapshotterActivity extends AppCompatActivity {
|
||||
|
||||
// marker source
|
||||
FeatureCollection markerCollection = FeatureCollection.fromFeatures(new Feature[] {
|
||||
Feature.fromGeometry(Point.fromLngLat(4.91638, 52.34673), featureProperties("2", "Car"))
|
||||
Feature.fromGeometry(Point.fromLngLat(4.91638, 52.35673), featureProperties("1", "Android")),
|
||||
Feature.fromGeometry(Point.fromLngLat(4.91638, 12.34673), featureProperties("2", "Car"))
|
||||
});
|
||||
Source markerSource = new GeoJsonSource(MARKER_SOURCE, markerCollection);
|
||||
|
||||
@@ -156,17 +157,32 @@ public class MapSnapshotterActivity extends AppCompatActivity {
|
||||
builder.withImage("Car", Objects.requireNonNull(carBitmap), false)
|
||||
.withSources(markerSource)
|
||||
.withLayers(markerSymbolLayer);
|
||||
options.withCameraPosition(new CameraPosition.Builder()
|
||||
.target(new LatLng(5.537109374999999,
|
||||
52.07950600379697))
|
||||
.zoom(1)
|
||||
.padding(1, 1, 1, 1)
|
||||
.build()
|
||||
);
|
||||
options
|
||||
.withRegion(null)
|
||||
.withCameraPosition(new CameraPosition.Builder()
|
||||
.target(new LatLng(5.537109374999999,
|
||||
52.07950600379697))
|
||||
.zoom(1)
|
||||
.padding(1, 1, 1, 1)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
options.withStyleBuilder(builder);
|
||||
MapSnapshotter snapshotter = new MapSnapshotter(MapSnapshotterActivity.this, options);
|
||||
snapshotter.setObserver(new MapSnapshotter.Observer() {
|
||||
@Override
|
||||
public void onDidFinishLoadingStyle() {
|
||||
Timber.i("onDidFinishLoadingStyle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStyleImageMissing(String imageName) {
|
||||
Bitmap androidIcon = BitmapUtils.getBitmapFromDrawable(getResources().getDrawable(R.drawable.ic_android_2));
|
||||
snapshotter.addImage(imageName, androidIcon, false);
|
||||
}
|
||||
});
|
||||
|
||||
snapshotter.start(snapshot -> {
|
||||
Timber.i("Got the snapshot");
|
||||
ImageView imageView = new ImageView(MapSnapshotterActivity.this);
|
||||
|
||||
@@ -48,6 +48,9 @@ class MapSnapshotterWithinExpression : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private val snapshotterObserver = object : MapSnapshotter.Observer {
|
||||
override fun onStyleImageMissing(imageName: String?) {
|
||||
}
|
||||
|
||||
override fun onDidFinishLoadingStyle() {
|
||||
// Show only POI labels inside geometry using within expression
|
||||
(snapshotter.getLayer("poi-label") as SymbolLayer).setFilter(
|
||||
|
||||
Reference in New Issue
Block a user