2020 */
2121public class AddWmsSourceActivity extends AppCompatActivity {
2222
23- MapView mapView ;
23+ private MapView mapView ;
2424
2525 @ Override
2626 protected void onCreate (@ Nullable Bundle savedInstanceState ) {
@@ -43,16 +43,20 @@ public void onMapReady(@NonNull final MapboxMap mapboxMap) {
4343 @ Override
4444 public void onStyleLoaded (@ NonNull Style style ) {
4545
46+ // Add the web map source to the map
4647 style .addSource (new RasterSource (
4748 "web-map-source" ,
48- new TileSet ("tileset" , "https://geodata.state.nj.us/imagerywms/Natural2015?bbox={"
49- + "bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&"
50- + "srs=EPSG:3857&width=256&height=256&layers=Natural2015" ), 256 ));
51-
52- // Add the web map source to the map.
53- style .addLayerBelow (
54- new RasterLayer ("web-map-layer" , "web-map-source" ), "aeroway-taxiway" );
55-
49+ new TileSet ("tileset" , "https://img.nj.gov/imagerywms/Natural2015?bbox={"
50+ + "bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:"
51+ + "3857&transparent=true&width=256&height=256&layers=Natural2015" ), 256 ));
52+
53+ // Create a RasterLayer with the source created above and then add the layer to the map
54+ if (style .getLayer ("tunnel-street-minor-low" ) != null ) {
55+ style .addLayerBelow (
56+ new RasterLayer ("web-map-layer" , "web-map-source" ), "tunnel-street-minor-low" );
57+ } else {
58+ style .addLayer (new RasterLayer ("web-map-layer" , "web-map-source" ));
59+ }
5660 }
5761 });
5862 }
0 commit comments