I have been working on openlayers 4 and specifically my question is regarding limiting the extent the user sees, let's say 2 km by 2km is the viewing area, this configuration was done using the ol.View
class's extent
attribute.
In that case for the initial zoom level, I'm able to see the entire area of 4kms by panning across, when I zoom into the next level, then the area I can pan across is less than 4kms, how can I maintain the original extent, even on other zoom levels while panning?
Here is the code :
var matrixIds = new Array(14);
for (var i = 0; i < 14; ++i) {
matrixIds[i] = "EPSG:27700:" + i;
}
var resolutionsArray = [896.0, 448.0, 224.0, 112.0,
56.0, 28.0, 14.0, 7.0, 3.5, 1.75,
0.875, 0.4375, 0.21875, 0.109375
];
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.WMTS({
name: "OS Maps WMTS",
url: "<layer_url>",
layer: "Road 27700",
matrixSet: "EPSG:27700",
format: 'image/png',
projection: "EPSG:27700",
tileGrid: new ol.tilegrid.WMTS({
origin: [-238375.0, 1376256.0],
resolutions: resolutionsArray,
matrixIds: matrixIds
}),
style: '',
crossOrigin: "Anonymous"
})
})
],
view: new ol.View({
center: [529449, 189252],
zoom: 13,
maxZoom: 16,
minZoom: 13,
extent: [529449 - 1000, 189252 - 1000, 529449 + 1000, 189252 + 1000]
})
});