Constrained Zoom

This example uses OpenLayers v4.0.1. The latest is v.

#### Constrained Zoom

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.

Related API documentation:

- ol.Map
,
- ol.View
,
- ol.layer.Tile
,
- ol.source.BingMaps

Copy Edit
Constrained Zoom Example of a zoom constrained view. 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 }) }); <div id="map" class="map"></div>

    <!DOCTYPE html>
    <html>
      <head>
        <title>Constrained Zoom</title>
        <link rel="stylesheet" href="https://openlayers.org/en/v4.0.1/css/ol.css" type="text/css">
        <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
        <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
        <script src="https://openlayers.org/en/v4.0.1/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>