1

我正在尝试使用 wmts(来自 GeoTiff 的 GeoServer)作为 Mapbox-GL 源。Mapbox-GL 能够毫无错误地创建源和图层。但是,不会渲染图层,并且永远不会查询 GeoServer 以获取瓦片。

map.on('load', function() {

    // Create raster layer from GeoServer
    map.addSource('rasterTest', {
        'type': 'raster',
        'tiles': 'http://localhost:32769/geoserver/gwc/service/wmts?SERVICE=WMTS&REQUEST=GetTile&LAYER=enview:sample&TILEMATRIX=EPSG:900913:{z}&TILEMATRIXSET=EPSG:900913&format=image%2Fpng&TileCol={x}&TileRow={y}',
        'tileSize': 256,
    });

    map.addLayer({
        'id':1,
        'source': 'rasterTest',
        'type': 'raster',
        'visibility': 'visible',
        'source-layer': 'rasterTest',
    });

    console.log('map:');
    console.log(map);

})
4

2 回答 2

0

使用 wmts LAYER 名称更改“源层”。

'source-layer': 'enview:sample'或者'source-layer': 'sample'

//modified source 
map.on('load', function() {

    // Create raster layer from GeoServer
    map.addSource('rasterTest', {
        'type': 'raster',
        'tiles': 'http://localhost:32769/geoserver/gwc/service/wmts?SERVICE=WMTS&REQUEST=GetTile&LAYER=enview:sample&TILEMATRIX=EPSG:900913:{z}&TILEMATRIXSET=EPSG:900913&format=image%2Fpng&TileCol={x}&TileRow={y}',
        'tileSize': 256,
    });

    map.addLayer({
        'id':'rasterTest',
        'source': 'rasterTest',
        'type': 'raster',
        'visibility': 'visible',
        'source-layer': 'enview:sample' //'rasterTest',
    });

})
于 2018-01-14T21:30:46.723 回答
0

You've got 'tiles' listed as an option to addSource. I don't think that's valid for a raster source - see docs here . Instead you need an 'url' property.

The next gotcha is that the 'url' property is not directly an URL pattern as with many mapping libs, but the URL of a TileJSON doc (not enough rep to link, sorry!), which contains the pattern. This isn't properly doc'd at the link above.

Here's a minimal WMTS TileJSON doc I got to work with Mapbox GL JS 0.15.0: https://gist.github.com/georgemarrows/e6eba8207281a93a0fc1

于 2016-03-16T11:22:05.917 回答