gpt4 book ai didi

android - Mapbox 添加 WMS 源

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:09:26 37 4
gpt4 key购买 nike

目前我正在努力在原生 android 平台的 map 上添加 WMS 源。我正在使用 mapbox 在应用程序中显示 map 。我正在尝试从 Geo-server 添加 WMS 源层但是 WMS 源层在 map 上多次添加,如图所示:

enter image description here

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

@覆盖 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");

}

如果代码有任何问题或有人知道如何在 map 上添加栅格源,请提出建议?

提前致谢!

最佳答案

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);

关于android - Mapbox 添加 WMS 源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52982663/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com