Skip to content

Commit 9df40c7

Browse files
author
Łukasz Paczos
committed
[annotation] re-add airplane bitmap when symbol example style changes
1 parent 7777117 commit 9df40c7

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

app/src/main/java/com/mapbox/mapboxsdk/plugins/testapp/activity/annotation/SymbolActivity.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import android.view.animation.LinearInterpolator;
1212
import android.widget.TextView;
1313
import android.widget.Toast;
14+
1415
import com.mapbox.geojson.FeatureCollection;
1516
import com.mapbox.geojson.Point;
1617
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
@@ -28,14 +29,15 @@
2829
import com.mapbox.mapboxsdk.style.sources.GeoJsonOptions;
2930
import com.mapbox.mapboxsdk.utils.BitmapUtils;
3031
import com.mapbox.mapboxsdk.utils.ColorUtils;
31-
import timber.log.Timber;
3232

3333
import java.io.IOException;
3434
import java.util.ArrayList;
3535
import java.util.List;
3636
import java.util.Locale;
3737
import java.util.Random;
3838

39+
import timber.log.Timber;
40+
3941
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
4042
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
4143
import static com.mapbox.mapboxsdk.style.expressions.Expression.not;
@@ -68,13 +70,14 @@ protected void onCreate(Bundle savedInstanceState) {
6870
mapView = findViewById(R.id.mapView);
6971
mapView.onCreate(savedInstanceState);
7072
mapView.getMapAsync(mapboxMap -> mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
71-
findViewById(R.id.fabStyles).setOnClickListener(v -> mapboxMap.setStyle(Utils.INSTANCE.getNextStyle()));
73+
findViewById(R.id.fabStyles).setOnClickListener(v -> {
74+
mapboxMap.setStyle(Utils.INSTANCE.getNextStyle());
75+
mapboxMap.getStyle(this::addAirplaneImageToStyle);
76+
});
7277

7378
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(2));
7479

75-
style.addImage(ID_ICON_AIRPORT,
76-
BitmapUtils.getBitmapFromDrawable(getResources().getDrawable(R.drawable.ic_airplanemode_active_black_24dp)),
77-
true);
80+
addAirplaneImageToStyle(style);
7881

7982
// create symbol manager
8083
GeoJsonOptions geoJsonOptions = new GeoJsonOptions().withTolerance(0.4f);
@@ -156,6 +159,12 @@ private LatLng createRandomLatLng() {
156159
(random.nextDouble() * -360.0) + 180.0);
157160
}
158161

162+
private void addAirplaneImageToStyle(Style style) {
163+
style.addImage(ID_ICON_AIRPORT,
164+
BitmapUtils.getBitmapFromDrawable(getResources().getDrawable(R.drawable.ic_airplanemode_active_black_24dp)),
165+
true);
166+
}
167+
159168
@Override
160169
public boolean onCreateOptionsMenu(Menu menu) {
161170
getMenuInflater().inflate(R.menu.menu_symbol, menu);

0 commit comments

Comments
 (0)