Reputation: 119
I'm trying to add wmts layer from geoserver 2.18. 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 don't appear on the map. What could be the reason? 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": {
}
}
);
Upvotes: 0
Views: 1774
Reputation: 11
Your visibility
property should not be added that way. Add it like so:
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
}
}
);
Upvotes: 0