Leaflet only loads one tile

对着背影说爱祢 提交于 2019-12-01 03:58:06
Michał Grzejszczak

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!