Leaflet only loads one tile

I would guess that the size of the map upon initialization is the culprit.

Leaflet needs to know the size of the element it is embedded in when initializing. Leaflet uses that information to know how much tiles to load etc. Furthermore any programmatic changes (or changes that cannot be easily detected by Leaflet) to the size of the map have to be followed by map.invalidateSize(..) link.

I suspect that after you set the size, Leaflet fails to read properly the new size of the #map element. Try invalidating the size afterwards or run initialization asynchronously. I would add:

setTimeout(function () {
    map.invalidateSize();
}, 0);

and check if it gets any better.


I used that command to fix my missing tiles problem:

map.getSize();

Look like Leaflet needs to know the size of the element map in advance as Michal said.