Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Leaflet zoom in further and stretch tiles

Tags:

leaflet

When I zoom in far enough on my map, the TileLayer disappears and I see a bunch of tiles that say "Map data not yet available". I believe these tiles may be coming from the provider, but I am not sure (I am using ESRI WorldImagery dataset).

Is there any way to, at a certain zoom level, just force the tiles to stretch, instead of requesting the tiles for that zoom level? I am ok with some blur, but I do need to zoom in further.

I tried playing around with the zoomOffset option, but whenever I put something there other than 0, my tiles just never load (all grey).

Thanks!

like image 950
elsurudo Avatar asked Sep 08 '13 18:09

elsurudo


1 Answers

This can be solved by using two of the options of L.TileLayer.

First, set maxNativeZoom to the highest zoom level your tiles provide (the last zoom level before the "Map data not available" starts to appear - this tells Leaflet to stop requesting new tiles when zooming in beyond this level; stretched tiles will be used instead.

Second, set maxZoom to whatever zoom is appropriate; you might not want this to be more than a couple of levels higher than maxNativeZoom, since the stretched tiles will start to look pretty horrible.

You can find out more about the details by checking under "Options" in the documentation for L.TileLayer: http://leafletjs.com/reference.html#tilelayer

like image 107
Liedman Avatar answered Sep 29 '22 20:09

Liedman