简体   繁体   English

在 Mapbox GL JS 中添加 WMS v 1.3.0

[英]Adding WMS v 1.3.0 in Mapbox GL JS

So, I want to add WMS v 1.3.0 layer in Mapbox GL JS.所以,我想在 Mapbox GL JS 中添加 WMS v 1.3.0 层。

The WMS source is: https://portal.ina-sdi.or.id/gis/rest/services/PPBW/BATASWILAYAH_10K_ADMINISTRASI_AR_KELDESA/MapServer WMS源为: https://portal.ina-sdi.or.id/gis/rest/services/PPBW/BATASWILAYAH_10K_ADMINISTRASI_AR_KELDESA/MapServer

And Here is my code:这是我的代码:

map.addSource('wms-test-source', {
            'type': 'raster',
            'tiles': [
                'https://portal.ina-sdi.or.id/gis/services/PPBW/BATASWILAYAH_10K_ADMINISTRASI_AR_KELDESA/MapServer/WmsServer?bbox={bbox-epsg-4326}&format=image/png&service=WMS&version=1.3.0&request=GetMap&CRS=EPSG:4326&transparent=true&width=256&height=256&layer=0'
            ],
            'tileSize': 256
        });
        map.addLayer(
            {
                'id': 'wms-test-layer',
                'type': 'raster',
                'source': 'wms-test-source',
                'paint': {}
            }
        );

I have tried using this tutorial: https://docs.mapbox.com/mapbox-gl-js/example/wms/ , But I still can't figure why i can't add this WMS layer, is this because the WMS version is 1.3.0?我已经尝试使用本教程: https://docs.mapbox.com/mapbox-gl-js/example/wms/ ,但我仍然不明白为什么我不能添加这个 WMS 层,这是因为 WMS版本是1.3.0? I've change the link many times and get some error Http 400 and sometimes CORS.我已经多次更改链接并收到一些错误 Http 400 有时是 CORS。 I've tried this WMS in QGIS and leaflet, and this WMS works well, please help!我已经在 QGIS 和 leaflet 中尝试过这个 WMS,这个 WMS 运行良好,请帮忙!

and here my jsfiddle snippet: https://jsfiddle.net/yekjzhvq/这里是我的 jsfiddle 片段: https://jsfiddle.net/yekjzhvq/

It seems the WMS layer is only available in EPSG:4326, mapboxgl only supports EPSG:3857 layers, you are importing it as EPSG:4326 and the server doesnt respond.似乎 WMS 图层仅在 EPSG:4326 中可用,mapboxgl 仅支持 EPSG:3857 图层,您将其导入为 EPSG:4326 并且服务器没有响应。 You should make sure the layer is available in EPSG:3857 and then try to import it as您应该确保图层在 EPSG:3857 中可用,然后尝试将其导入为

'tiles': [
            'https://portal.ina-sdi.or.id/gis/services/PPBW/BATASWILAYAH_10K_ADMINISTRASI_AR_KELDESA/MapServer/WmsServer?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.3.0&request=GetMap&CRS=EPSG:3857&transparent=true&width=256&height=256&layer=0'
        ],

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM