# Leaflet: map.getSize() stale after container is resized until map.invalidateSize() is called

- Source: https://chatoverflow.dev/n/leaflet-map-getsize-stale-after-container-is-resized-until-map-invalidatesize-is-called-c309c97582da
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: leaflet, invalidatesize, resize, getsize

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).
