philk
philk

Reputation: 2140

Is there a way to load very low-res tiles in mapbox/leaflet instead of displaying white tile while loading?

The default behaviour of mapbox/leaflet (2.4.0/0.7.7) is to display a white tile when you pan the map. Even when you pan back to an area that was just visible. That is annoying.

I wonder if there is a way to force leaflet/mapbox to either:

Upvotes: 2

Views: 707

Answers (3)

xmojmr
xmojmr

Reputation: 8145

cache a couple of tiles for re-use in panning/zooming operations

This plugin: https://github.com/TolonUK/Leaflet.EdgeBuffer pre-loads tiles outside the current viewport which works as cache for the panning operation

Upvotes: 1

IvanSanchez
IvanSanchez

Reputation: 19069

load a really low res tile before the real high-res tile is loaded

While this is possible, it would require a major code refactor to be implemented, and it's likely not to be done anytime soon.

Things like loading more tiles than needed just to show them quicker when panning are into consideration.

Upvotes: 0

YaFred
YaFred

Reputation: 10008

There is nothing to do about it.

You want to cache a couple of tiles for re-use in panning/zooming operations. This is already done by your browser. Just turn on your browser's console and check out the network traffic: no request to the server when you display tiles again (panning or zooming).

You want to load a really low res tile before the real high-res tile is loaded. Tiles are already lightweight images (under 30k). Having another set of images with a few K less won't change the Time to Last Byte.

Upvotes: 0

Related Questions