Resize map on div size change
By default, OpenLayers listens for and resizes on page resize, but not on map div size change. (Pre-2021ish, this was maybe impossible to do? But ResizeObserver makes this easy.) This means from the first time the sidebar is collapsed until the first time a resize event was triggered (e.g. on mobile rotating the device) the map wouldn't render render its full size.
This commit is contained in:
parent
ff77bc31e7
commit
77b4f845ae
1 changed files with 2 additions and 0 deletions
2
main.js
2
main.js
|
|
@ -118,3 +118,5 @@ map.on('click', function (evt) {
|
|||
|
||||
popupOverlay.setPosition(evt.coordinate);
|
||||
});
|
||||
|
||||
new ResizeObserver(() => map.updateSize()).observe(document.getElementById("map"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue