import Map from '../src/ol/Map.js'; import View from '../src/ol/View.js'; import TileLayer from '../src/ol/layer/Tile.js'; import OSM from '../src/ol/source/OSM.js'; var viewport = document.getElementById('map'); function getMinZoom() { var width = viewport.clientWidth; return Math.ceil(Math.LOG2E * Math.log(width / 256)); } var initialZoom = getMinZoom(); var view = new View({ center: [0, 0], minZoom: initialZoom, zoom: initialZoom }); var map = new Map({ layers: [ new TileLayer({ source: new OSM() }) ], target: 'map', view: view }); window.addEventListener('resize', function() { var minZoom = getMinZoom(); if (minZoom !== view.getMinZoom()) { view.setMinZoom(minZoom); } });