我试图将BLM.gov发布的PLSS (公共土地调查系统)的WMS添加到Mapbox地图中,以使乡镇/范围/区段网格可见,但无法在地图上显示。我怀疑Mapbox请求与BLM期望的查询之间存在语法问题。
我一直在使用mapbox发布的示例来添加WMS,为BLM站点建模,代码如下:
mapboxgl.accessToken = 'MY_KEY';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/light-v10',
zoom: 8,
center: [-95, 38]
});
map.on('load', function() {
map.addSource('wms-test-source', {
'type': 'raster',
'tiles': [
'https://gis.blm.gov/arcgis/services/Cadastral/BLM_Natl_PLSS_CadNSDI/MapServer/WmsServer?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.3.0&request=GetMap&srs=EPSG:3857&width=256&height=256&layers=1'
],
'tileSize': 256
});
map.addLayer(
{
'id': 'wms-test-layer',
'type': 'raster',
'source': 'wms-test-source',
'paint': {}
},
'aeroway-line'
);
});有没有人看到我需要改变什么才能让这个覆盖PLSS网格,我会非常棒!
发布于 2020-02-25 05:36:44
根据Thomas下面的评论,我使用了tileLayer函数,如这里所描述的:docs.mapbox.com/mapbox.js/example/v1.0.0/wms来完成我的目标。代码如下:
L.mapbox.accessToken = 'pk.eyJ1IjoicGV0cm9hbmFseXRpY2EiLCJhIjoiY2s2dTlicXQzMDdqbDNnbzhsNGo4ZjY0MCJ9.u5nBRLm8b6RwZKKXGh-L4w';
var map = L.mapbox.map('map')
.setView([37, -99], 8)
.addLayer(L.mapbox.styleLayer('mapbox://styles/mapbox/streets-v11'));
// Add each wms layer using L.tileLayer.wms
var Sections = L.tileLayer.wms('https://gis.blm.gov/arcgis/services/Cadastral/BLM_Natl_PLSS_CadNSDI/MapServer/WmsServer', {
format: 'img/png',
transparent: true,
layers: 2
}).addTo(map);
var Townships = L.tileLayer.wms('https://gis.blm.gov/arcgis/services/Cadastral/BLM_Natl_PLSS_CadNSDI/MapServer/WmsServer', {
format: 'img/png',
transparent: true,
layers: 1
}).addTo(map);发布于 2020-02-25 05:39:00
PFA,
<script>
L.mapbox.accessToken = '<your access token here>';
var map = L.mapbox.map('map')
.setView([37, -99], 3)
.addLayer(L.mapbox.styleLayer('mapbox://styles/mapbox/streets-v11'))
var temperature =
L.tileLayer.wms('http://gis.srh.noaa.gov/arcgis/services/NDFDTemps/MapServer/WMSServer', {
format: 'img/png',
transparent: true,
layers: 16
}).addTo(map);
var precipitation = L.tileLayer.wms('http://nowcoast.noaa.gov/arcgis/services/nowcoast/analysis_meteohydro_sfc_qpe_time/MapServer/WmsServer', {
format: 'image/png',
transparent: true,
layers: '5'
}).addTo(map);
document.getElementById('temperature').onclick = function () {
var enable = this.className !== 'active';
temperature.setOpacity(enable ? 1 : 0);
this.className = enable ? 'active' : '';
return false;
};
document.getElementById('precipitation').onclick = function () {
var enable = this.className !== 'active';
precipitation.setOpacity(enable ? 1 : 0);
this.className = enable ? 'active' : '';
return false;
};
</script>有关更多信息,请参考此链接。https://docs.mapbox.com/mapbox.js/example/v1.0.0/wms/
https://stackoverflow.com/questions/60383958
复制相似问题