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:
Chandler Swift 2024-02-02 01:50:01 -06:00
parent ff77bc31e7
commit 77b4f845ae
Signed by: chandlerswift
GPG key ID: A851D929D52FB93F

View file

@ -118,3 +118,5 @@ map.on('click', function (evt) {
popupOverlay.setPosition(evt.coordinate);
});
new ResizeObserver(() => map.updateSize()).observe(document.getElementById("map"));