Reputation: 3454
I'm using tiles from IGN Géoportail WMTS to render a background map as outlined in this example:
var resolutions = [];
var matrixIds = [];
var proj3857 = getProjection('EPSG:3857');
var maxResolution = getWidth(proj3857.getExtent()) / 256;
for (var i = 0; i < 18; i++) {
matrixIds[i] = i.toString();
resolutions[i] = maxResolution / Math.pow(2, i);
}
var tileGrid = new WMTSTileGrid({
origin: [-20037508, 20037508],
resolutions: resolutions,
matrixIds: matrixIds
});
var ign_source = new WMTS({
url: 'https://wxs.ign.fr/pratique/geoportail/wmts',
layer: 'GEOGRAPHICALGRIDSYSTEMS.MAPS',
matrixSet: 'PM',
format: 'image/jpeg',
projection: 'EPSG:3857',
tileGrid: tileGrid,
style: 'normal',
attributions: '<a href="http://www.geoportail.fr/" target="_blank">' +
'<img src="https://api.ign.fr/geoportail/api/js/latest/' +
'theme/geoportal/img/logo_gp.gif"></a>'
});
var ign = new TileLayer({
source: ign_source,
opacity: 0.7
});
On zoom level 12, the map shows the details I need:
However, zooming out to zoom level 13, the tiles switch to less details, too few for my use case:
Is there a way to tell OpenLayers to "lock" the tile zoom to 12 while still allowing zooming beyond this threshold rendered by OpenLayers instead of the WMTS?
Or in other words: Let OpenLayers do all the zooming and always get zoom level 12 detail tiles from the WMTS.
Thanks for your help!
Upvotes: 2
Views: 405
Reputation: 17932
This will restrict the tilegrid to zoom level (matrix id) 13:
var tileGrid = new WMTSTileGrid({
origin: [-20037508, 20037508],
resolutions: resolutions.slice(13,14),
matrixIds: matrixIds.slice(13,14)
});
Upvotes: 2