Skip to content
This repository was archived by the owner on Oct 7, 2024. It is now read-only.

Commit 65d9eee

Browse files
author
Langston Smith
authored
Updated WMS source example to fix missing 3rd party satellite imagery (#1260)
1 parent c6ef58d commit 65d9eee

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/styles/AddWmsSourceActivity.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
public 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

Comments
 (0)