[android] - remove style loaded listener
This commit is contained in:
@@ -15,7 +15,7 @@ import com.mapbox.mapboxsdk.style.layers.Property
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
|
||||
|
||||
fun MapboxMap.querySourceFeatures(sourceId: String): List<Feature> {
|
||||
return this.getSourceAs<GeoJsonSource>(sourceId)?.querySourceFeatures(null) ?: emptyList()
|
||||
return this.style.getSourceAs<GeoJsonSource>(sourceId)?.querySourceFeatures(null) ?: emptyList()
|
||||
}
|
||||
|
||||
fun MapboxMap.queryRenderedFeatures(location: Location, layerId: String): List<Feature> {
|
||||
@@ -25,7 +25,7 @@ fun MapboxMap.queryRenderedFeatures(location: Location, layerId: String): List<F
|
||||
}
|
||||
|
||||
fun MapboxMap.isLayerVisible(layerId: String): Boolean {
|
||||
return this.getLayer(layerId)?.visibility?.value?.equals(Property.VISIBLE)!!
|
||||
return this.style.getLayer(layerId)?.visibility?.value?.equals(Property.VISIBLE)!!
|
||||
}
|
||||
|
||||
fun MapboxMap.waitForSource(uiController: UiController, sourceId: String) {
|
||||
|
||||
@@ -25,7 +25,7 @@ public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyC
|
||||
@Override
|
||||
public boolean onMapClick(@NonNull LatLng point) {
|
||||
if (mapboxMap != null) {
|
||||
mapboxMap.setStyle(Style.OUTDOORS, style -> Timber.d("Style Loaded %s", style));
|
||||
mapboxMap.setStyle(Style.OUTDOORS);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -39,6 +39,10 @@ public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyC
|
||||
mapView = findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(this);
|
||||
|
||||
mapView.addOnDidFinishLoadingStyleListener(() -> {
|
||||
Timber.d("Style Loaded");
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -93,6 +93,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
|
||||
mapView.setStyleUrl(STYLES[currentStyleIndex]);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(this);
|
||||
mapView.addOnDidFinishLoadingStyleListener(() -> Timber.d("Style loaded"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -160,7 +161,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
|
||||
if (currentStyleIndex == STYLES.length) {
|
||||
currentStyleIndex = 0;
|
||||
}
|
||||
mapboxMap.setStyleUrl(STYLES[currentStyleIndex], style -> Timber.d("Style loaded %s", style));
|
||||
mapboxMap.setStyleUrl(STYLES[currentStyleIndex]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -79,6 +79,14 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
|
||||
initFloatingActionButtons();
|
||||
isLoadingStyle = false;
|
||||
});
|
||||
|
||||
mapView.addOnDidFinishLoadingStyleListener(new MapView.OnDidFinishLoadingStyleListener() {
|
||||
@Override
|
||||
public void onDidFinishLoadingStyle() {
|
||||
addBusStop();
|
||||
isLoadingStyle = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addBusStopSource() {
|
||||
@@ -211,10 +219,7 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
|
||||
}
|
||||
|
||||
private void loadNewStyle() {
|
||||
mapboxMap.setStyleUrl(getNextStyle(), style -> {
|
||||
addBusStop();
|
||||
isLoadingStyle = false;
|
||||
});
|
||||
mapboxMap.setStyleUrl(getNextStyle());
|
||||
}
|
||||
|
||||
private void addBusStop() {
|
||||
|
||||
@@ -152,6 +152,8 @@ public class TextureViewDebugModeActivity extends AppCompatActivity implements O
|
||||
}
|
||||
|
||||
private void setupStyleChangeView() {
|
||||
mapView.addOnDidFinishLoadingStyleListener(() -> Timber.d("Style loaded"));
|
||||
|
||||
FloatingActionButton fabStyles = findViewById(R.id.fabStyles);
|
||||
fabStyles.setOnClickListener(view -> {
|
||||
if (mapboxMap != null) {
|
||||
@@ -159,7 +161,7 @@ public class TextureViewDebugModeActivity extends AppCompatActivity implements O
|
||||
if (currentStyleIndex == STYLES.length) {
|
||||
currentStyleIndex = 0;
|
||||
}
|
||||
mapboxMap.setStyleUrl(STYLES[currentStyleIndex], style -> Timber.d("Style loaded %s", style));
|
||||
mapboxMap.setStyleUrl(STYLES[currentStyleIndex]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user