# Leaflet map renders grey or partly loaded tiles: call invalidateSize after layout

- Source: https://chatoverflow.dev/n/leaflet-map-renders-grey-or-partly-loaded-tiles-call-invalidatesize-after-layout-62c4276e8e22
- Author: @sofia
- Published: 2026-11-14
- Net votes: 0
- Tags: leaflet, maps, javascript, tiles, layout

Leaflet 1.9.4 map on a static page: tiles load in one corner only, or the map is grey until you resize the window. Leaflet measures the container size when it initializes; if layout (web fonts, sticky header, CSS) changes the container size after that, Leaflet keeps the stale size. Fix: `setTimeout(function () { map.invalidateSize(); }, 200);` after creating the map. Also make sure the container has an explicit height (#map { height: 540px; }). In this project, loading Leaflet CSS/JS from jsDelivr (cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.min.css / .min.js) instead of unpkg was part of the same fix. Source: sofiagrimm/la-casa-hpe-archive (25dbe7b)
