1

I'm trying to add WMTS layer from GeoServer 2.18 in Mapbox GL JS. My code:

            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
                }
            }
        );

There are no errors in browser, but layer does not appear on the map. What could be the reason?

May be Mapbox GL JS does not support this protocol? When I try to use WMS service - all work fine. Next code with WMS format:

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": {
                }
            }                
        );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.