|
11 | 11 | import android.view.animation.LinearInterpolator; |
12 | 12 | import android.widget.TextView; |
13 | 13 | import android.widget.Toast; |
| 14 | + |
14 | 15 | import com.mapbox.geojson.FeatureCollection; |
15 | 16 | import com.mapbox.geojson.Point; |
16 | 17 | import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; |
|
28 | 29 | import com.mapbox.mapboxsdk.style.sources.GeoJsonOptions; |
29 | 30 | import com.mapbox.mapboxsdk.utils.BitmapUtils; |
30 | 31 | import com.mapbox.mapboxsdk.utils.ColorUtils; |
31 | | -import timber.log.Timber; |
32 | 32 |
|
33 | 33 | import java.io.IOException; |
34 | 34 | import java.util.ArrayList; |
35 | 35 | import java.util.List; |
36 | 36 | import java.util.Locale; |
37 | 37 | import java.util.Random; |
38 | 38 |
|
| 39 | +import timber.log.Timber; |
| 40 | + |
39 | 41 | import static com.mapbox.mapboxsdk.style.expressions.Expression.eq; |
40 | 42 | import static com.mapbox.mapboxsdk.style.expressions.Expression.get; |
41 | 43 | import static com.mapbox.mapboxsdk.style.expressions.Expression.not; |
@@ -68,13 +70,14 @@ protected void onCreate(Bundle savedInstanceState) { |
68 | 70 | mapView = findViewById(R.id.mapView); |
69 | 71 | mapView.onCreate(savedInstanceState); |
70 | 72 | 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 | + }); |
72 | 77 |
|
73 | 78 | mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(2)); |
74 | 79 |
|
75 | | - style.addImage(ID_ICON_AIRPORT, |
76 | | - BitmapUtils.getBitmapFromDrawable(getResources().getDrawable(R.drawable.ic_airplanemode_active_black_24dp)), |
77 | | - true); |
| 80 | + addAirplaneImageToStyle(style); |
78 | 81 |
|
79 | 82 | // create symbol manager |
80 | 83 | GeoJsonOptions geoJsonOptions = new GeoJsonOptions().withTolerance(0.4f); |
@@ -156,6 +159,12 @@ private LatLng createRandomLatLng() { |
156 | 159 | (random.nextDouble() * -360.0) + 180.0); |
157 | 160 | } |
158 | 161 |
|
| 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 | + |
159 | 168 | @Override |
160 | 169 | public boolean onCreateOptionsMenu(Menu menu) { |
161 | 170 | getMenuInflater().inflate(R.menu.menu_symbol, menu); |
|
0 commit comments