首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将美国BLM WMS连接到Mapbox

将美国BLM WMS连接到Mapbox
EN

Stack Overflow用户
提问于 2020-02-24 21:10:28
回答 2查看 326关注 0票数 0

我试图将BLM.gov发布的PLSS (公共土地调查系统)的WMS添加到Mapbox地图中,以使乡镇/范围/区段网格可见,但无法在地图上显示。我怀疑Mapbox请求与BLM期望的查询之间存在语法问题。

我一直在使用mapbox发布的示例来添加WMS,为BLM站点建模,代码如下:

代码语言:javascript
复制
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网格,我会非常棒!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-02-25 05:36:44

根据Thomas下面的评论,我使用了tileLayer函数,如这里所描述的:docs.mapbox.com/mapbox.js/example/v1.0.0/wms来完成我的目标。代码如下:

代码语言:javascript
复制
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);
票数 1
EN

Stack Overflow用户

发布于 2020-02-25 05:39:00

PFA,

代码语言:javascript
复制
<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/

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60383958

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档