From 85d504d77892e1963a98029f03381571827e23a6 Mon Sep 17 00:00:00 2001 From: langsmith Date: Tue, 5 Nov 2019 17:33:41 -0800 Subject: [PATCH] updates wms source example --- .../examples/styles/AddWmsSourceActivity.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/styles/AddWmsSourceActivity.java b/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/styles/AddWmsSourceActivity.java index adc189afa..c37dce542 100644 --- a/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/styles/AddWmsSourceActivity.java +++ b/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/styles/AddWmsSourceActivity.java @@ -20,7 +20,7 @@ */ public class AddWmsSourceActivity extends AppCompatActivity { - MapView mapView; + private MapView mapView; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -43,16 +43,20 @@ public void onMapReady(@NonNull final MapboxMap mapboxMap) { @Override public void onStyleLoaded(@NonNull Style style) { + // Add the web map source to the map style.addSource(new RasterSource( "web-map-source", - new TileSet("tileset", "https://geodata.state.nj.us/imagerywms/Natural2015?bbox={" - + "bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&" - + "srs=EPSG:3857&width=256&height=256&layers=Natural2015"), 256)); - - // Add the web map source to the map. - style.addLayerBelow( - new RasterLayer("web-map-layer", "web-map-source"), "aeroway-taxiway"); - + new TileSet("tileset", "https://img.nj.gov/imagerywms/Natural2015?bbox={" + + "bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:" + + "3857&transparent=true&width=256&height=256&layers=Natural2015"), 256)); + + // Create a RasterLayer with the source created above and then add the layer to the map + if (style.getLayer("tunnel-street-minor-low") != null) { + style.addLayerBelow( + new RasterLayer("web-map-layer", "web-map-source"), "tunnel-street-minor-low"); + } else { + style.addLayer(new RasterLayer("web-map-layer", "web-map-source")); + } } }); }