【问题标题】:Adding wmts layer to mapbox gl from geoserver从地理服务器将 wmts 图层添加到 mapbox gl
【发布时间】:2020-10-13 15:01:35
【问题描述】:

我正在尝试从 geoserver 2.18 添加 wmts 层。我的代码:

            window.mymap.addSource(
                "mvt-test-source", {
                 "type": "vector",
                "tiles": [
                    "http://localhost:8080/geoserver/gwc/service/wmts?SERVICE=WMTS&&VERSION=1.0.0&REQUEST=GetTile&layer=mapbox:roads4326&TILEMATRIX=EPSG:4326:{z}&TILEMATRIXSET=EPSG:4326&FORMAT=application/vnd.mapbox-vector-tile&TILECOL={x}&TILEROW={y}"
                    ],
                "minZoom": 0,
                "maxZoom": 14
            });

            window.mymap.addLayer(
                {
                    'id': 'my_mvt_layer',
                    'type': 'line',
                    'source': 'mvt-test-source',
                    'source-layer': 'mapbox:roads4326',
                    "visibility": "visible",
                    'paint': {
                        'line-color': 'Red',
                        'line-width': 7
                    }
                }
            );

浏览器没有错误,但是图层没有出现在地图上。 可能是什么原因? 当我尝试使用 wms 服务时 - 一切正常。 wms格式的下一段代码:

window.mymap.addSource("wms-test-source", {
                "type": 'raster',

                "tiles": [
                  "http://localhost:8080/geoserver/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&&version=1.1.1&request=GetMap&srs=EPSG:900913&transparent=true&width=256&height=256&layers=mapbox:roads4326"
                ],
                'tileSize': 256
            });

            window.mymap.addLayer(
                {
                    "id": 'wms-test-layer',
                    "type": 'raster',
                    "source": 'wms-test-source',
                    "paint": {
                    }
                }                
            );

【问题讨论】:

    标签: mapbox geoserver wms


    【解决方案1】:

    您的visibility 属性不应以这种方式添加。像这样添加它:

     window.mymap.addLayer(
                    {
                        'id': 'my_mvt_layer',
                        'type': 'line',
                        'source': 'mvt-test-source',
                        'source-layer': 'mapbox:roads4326',
                        'layout':{
                         "visibility": "visible",
                        }
                        'paint': {
                            'line-color': 'Red',
                            'line-width': 7
                        }
                    }
                );
    

    【讨论】:

      猜你喜欢
      • 2018-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-25
      • 1970-01-01
      • 2018-02-10
      相关资源
      最近更新 更多