目前,我正致力于在本地android平台上添加WMS源代码。我正在使用mapbox在应用程序中显示地图。我试图从Geo-server添加一个WMS源层,但是WMS源层在地图上被添加了多次,如图所示:

下面是我用来添加WMS源代码的代码片段:
@Override 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");
} 如果代码有什么问题,或者有人知道如何在地图上添加栅格源,请提出建议?
提前谢谢!
发布于 2018-11-18 10:27:19
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);https://stackoverflow.com/questions/52982663
复制相似问题