I'm trying to display a WMTS layer in a simple webmap based on OpenLayers 6.14.1, below my code:
var map = new ol.Map({
target: 'map',
controls: ol.control.defaults({
attribution: false
}),
});
var view = new ol.View({
center: ol.proj.fromLonLat([14.483733304611981, 40.69930245824812]),
zoom: 14,
maxZoom: 20,
minZoom: 12
});
map.setView(view);
var osm = new ol.layer.Tile({
source: new ol.source.OSM(),
zIndex: 0
});
map.addLayer(osm);
var wmtsSource = 'http://sit.cittametropolitana.na.it/geoserver/gwc/service/wmts'
var raster2021 = new ol.layer.Tile({
source: new ol.source.WMTS({
url: wmtsSource,
layer: 'raster:2021_Worldview3_RGB',
}),
});
map.addLayer(raster2021);
I'm be able to see raster:2020_Worldview3_RGB
in QGIS but I can't see it on a webmap because of this error:
Uncaught TypeError: r is null
px file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
ju file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
getTileInternal file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
getTile file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
getTile file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
renderFrame file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
render file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
renderFrame file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
Wi file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
Bi file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
render file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
dr file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
dispatchEvent file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
notify file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
set file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
setSize file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
updateSize file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
pr file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
dispatchEvent file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
notify file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
set file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
setProperties file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
n file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
n file:///home/max/DEV/StabiaeGIS/assets/libraries/openlayers6.14.1/ol.js:2
<anonymous> file:///home/max/DEV/StabiaeGIS/assets/js/test.js:2
It is the first time that I use the WMTS function, the log from error doesn't help me to understand where is the problem. Where is my mistake?