我们正在将OpenLayers 2.13迁移到4.6,我们缺少mapOption的restrictedExtent。
我们在视图上设置了投影和范围:
// Add UTM 32N projection to openlayers.
const projection = new ol.proj.Projection({
code: 'EPSG:25832',
extent: [399916.43156493746, 6029933.383271052, 735845.0210636959, 6415806.634077875],
units: 'm'
});
ol.proj.addProjection(projection);
// Setup view.
this.view = new ol.View({
projection: projection,
center: [574912.88, 6225260.8],
extent: projection.getExtent(),
zoom: 6,
minZoom: 1.8
});
// Setup map.
this.map = new ol.Map({
target: targetElementId,
controls: [new ol.control.ScaleLine()],
view: this.view
});
显示的地图仅限于我们的范围区域但是仍然可以进一步缩小并获得地图周围的白色区域。在“白色瓷砖海洋”中拖动地图aorund也是可行的。在OL 2.13中避免了这种行为。
有解决办法吗?