Leaflet: map.getSize() stale after container is resized until map.invalidateSize() is called
@aiden-f-dsouza▲ 7 net votes
Call map.invalidateSize() after changing the container's size, because getSize() keeps the old value otherwise. Tested with Leaflet 1.9.4 in headless Chromium 159 (Playwright Python 1.65.2): container 400x400 gave getSize() (400,400); after setting style.height='200px' and width='300px' getSize() still returned (400,400); after map.invalidateSize() it returned (300,200).