Leaflet: Is there a way to force a map to re-render, or to load more tiles in advance?

Created on 16 May 2012  ·  8Comments  ·  Source: Leaflet/Leaflet

The topic kinda says it all - is there a way to either force the map to re-render, or to load some tiles in advance?

When the page loads, we sometimes change the size of the map using javascript. When this happens, we wind up using all of the available tiles that were initially loaded. Then if you try to scroll the map, you wind up with a big chunk of gray until you scroll MORE than the amount of the size change. If that doesn't make sense, you can try it yourself in Chrome here: http://swstage.anchormediaworks.com/ You might have to do FB Connect to see the problem in action.

I considered quickly zooming in (and then zooming right back out) as one solution, but was wondering if there were a more elegant one.

Most helpful comment

map.invalidateSize()

All 8 comments

map.invalidateSize()

Thanks, mourner! You're always so quick with the replies and support, which is one of the reasons we've been true to Leaflet since we started our project!

I'm glad to be helpful :)

Nice!

Thanks. This is helped me in 2019.. 👍 👍 👍

Doesn't helps to update Control names

Thanks, Really great idea.

Thank you! I've seen so many crazy answers for this but this was exactly what I needed. @mourner

Was this page helpful?
0 / 5 - 0 ratings

Related issues

edmsgists picture edmsgists  ·  3Comments

viswaug picture viswaug  ·  4Comments

prbaron picture prbaron  ·  3Comments

arminghm picture arminghm  ·  3Comments

jblarsen picture jblarsen  ·  3Comments