Leaflet maxZoom breaks through 18

In leaflet, the default maxZoom is 18. When you set the value greater than 18, and then zoom the map, although the map has a zoom effect, you will find that the map becomes blank, and the http request does not trigger the 19 request. If you need to load a tile image higher than zoom: 18, you can do the following:

When initializing tileLayer, add a parameter maxNativeZoom. This parameter allows you to set zoom values ​​beyond 18. For example, my configuration is as follows, then the leaflet will continue to zoom in after loading to 18 until it reaches 20.

 let layer = L.tileLayer();
 layer.options.minZoom = 10;
 layer.options.maxZoom = 20;
 layer.options.maxNativeZoom = 20;

When you use the following parameters, then leaflet is only loaded to zoom 20.

let layer = L.tileLayer();
layer.options.minZoom = 10;
layer.options.maxZoom = 25;
layer.options.maxNativeZoom = 20;

 

Guess you like

Origin blog.csdn.net/QiZi_Zpl/article/details/109843528