Mapbox添加WMS源

时间:2018-10-25 06:26:48

标签: android mapbox wms

当前,我正在本机android平台上在地图上添加WMS源。我正在使用mapbox在应用程序中显示地图。我正在尝试从地理服务器添加WMS源图层,但是WMS源图层在地图上多次添加,如图所示:

enter image description here

这是我用来添加WMS源的代码段:

@Override     public void onMapReady(MapboxMap mapboxMap){

    RasterSource webMapSource = new RasterSource(
            "web-map-source",
            new TileSet("tileset", "http://geo.skymetweather.com:8081/geoserver/cite/wms/cite:india_district_web?" +
                    "&bbox=68.036003112793,6.60812377929688,97.5504302978516," +
                    "37.2502937316895&format=image/png&service=WMS&version=1.1.1&" +
                    "request=GetMap&srs=EPSG:4326&width=493&height=512&layers=cite:india_district_web"), 256);

    mapboxMap.addSource(webMapSource);

    // Add the web map source to the map.
    RasterLayer webMapLayer = new RasterLayer("web-map-layer", "web-map-source");
    mapboxMap.addLayerBelow(webMapLayer, "aeroway-taxiway");

} 

请建议代码是否有问题或是否有人知道如何在地图上添加栅格源?

谢谢!

1 个答案:

答案 0 :(得分:1)

Mapbox仅支持“ EPSG:3857”来渲染WMS切片,您应该将源投影到此SRS。同样,也不需要像在TileSet的第二行中那样静态设置其边界框。使用此模板在您的应用程序中加载WMS:

RasterSource webMapSource = new RasterSource(
                       "web-map-source",
                        new TileSet("tileset",
                           'http://a.example.com/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&layers=example')
                           ,256);