[ios, android] Add methods to remove a custom layer

This commit is contained in:
John Firebaugh
2015-12-17 14:39:19 -08:00
parent d3c92a8b5c
commit 110f1ec796
11 changed files with 68 additions and 3 deletions

View File

@@ -76,6 +76,7 @@ public class MainActivity extends AppCompatActivity {
private int mSelectedStyle = R.id.actionStyleMapboxStreets;
private NavigationView mNavigationView;
private CoordinatorLayout mCoordinatorLayout;
private boolean mIsShowingCustomLayer;
// Used for GPS
private FloatingActionButton mLocationFAB;
@@ -397,7 +398,11 @@ public class MainActivity extends AppCompatActivity {
return true;
case R.id.action_custom_layer:
addCustomLayer();
if (mIsShowingCustomLayer) {
removeCustomLayer();
} else {
addCustomLayer();
}
return true;
default:
@@ -576,6 +581,7 @@ public class MainActivity extends AppCompatActivity {
}
private void addCustomLayer() {
mIsShowingCustomLayer = true;
mMapView.addCustomLayer(
new CustomLayer("custom",
ExampleCustomLayer.createContext(),
@@ -585,6 +591,11 @@ public class MainActivity extends AppCompatActivity {
null);
}
private void removeCustomLayer() {
mIsShowingCustomLayer = false;
mMapView.removeCustomLayer("custom");
}
// Called when FPS changes
private class MyOnFpsChangedListener implements MapView.OnFpsChangedListener {