Example of a zoom constrained view.
This map has a view that is constrained between zoom levels 9 and 13. This is done using the minZoom
and maxZoom
view options.
<!DOCTYPE html>
<html>
<head>
<title>Constrained Zoom</title>
<link rel="stylesheet" href="https://openlayers.org/en/v4.6.4/css/ol.css" type="text/css">
<!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
<script src=""></script>
<script src="https://openlayers.org/en/v4.6.4/build/ol.js"></script>
</head>
<body>
<div id="map" class="map"></div>
<script>
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.BingMaps({
key: 'Your Bing Maps Key from http://www.bingmapsportal.com/ here',
imagerySet: 'Aerial'
})
})
],
view: new ol.View({
center: [-13553864, 5918250],
zoom: 11,
minZoom: 9,
maxZoom: 13
})
});
</script>
</body>
</html>