leaflet-extras / leaflet-providers

An extension to Leaflet that contains configurations for various free tile providers.
https://leaflet-extras.github.io/leaflet-providers/preview/
BSD 2-Clause "Simplified" License
2.16k stars 673 forks source link

Allow user to use maxNativeZoom and maxZoom to allow pixelized tile (instead of a grey tile) #323

Open JoffreyB31 opened 5 years ago

JoffreyB31 commented 5 years ago

Hi,

A small update I have done for a site i'm working on, it allow a layer to be pixelized above maxZoom and not showing a grey tile (like originaly).

I have done this because when you use a provider it "lock" the maxZoom value to the one set in the providers list. But if you want to use maxNativeZoom, the plugin will still try to fetch tiles with greater maxZoom than the one allowed and it will return grey tiles.

Thanks in advance :)

brunob commented 5 years ago

@jieter any thoughts about it ?

jieter commented 5 years ago

I'm not sure about this. I understand the use case to override maxzoom/maxnativezoom, but I don't like to do it by default.

brunob commented 5 years ago

@JoffreyBourdieux may implement this as an option ?

JoffreyB31 commented 5 years ago

I'm not sure about this. I understand the use case to override maxzoom/maxnativezoom, but I don't like to do it by default.

By default you cannot use the maxNativeZoom property of Leaflet, so you can't zoom "above" the max zoom of the layer (a gray layer is returned instead).

This update seem to not change the original behavior of the plugin, since if you dont tell Leaflet to use the property "maxNativeZoom" it will simply stop the maximum zoom to the one provided by "maxZoom"

@JoffreyBourdieux may implement this as an option ?

I'll look into it

JoffreyB31 commented 5 years ago

Hi,

It is now implemented as an option. Simply use :

L.tileLayer.provider("OpenStreetMap.DE", {
          maxZoom: 21,
          useNativeZoom: true
});

It use a key "useNativeZoom" to detect if the user want to override the default maxZoom value, then clone the maxZoom value inside a maxNativeZoom key and override the maxZoom from the providers list value with the user value.

Tell me if this modification suits you. Regards.

answerquest commented 1 year ago

Hi, I'm guessing this hasn't been implemented yet? I'm using the 'Stamen.Terrain' layer, want it to keep its maxNativeZoom at 10, then over that (as users will zoom in further for sure) should show zoomed-in tiles instead of vanishing into gray. how to achieve the same? I'm able to do this fine when using native leaflet tile layer. Would it be better to revert to the same?