Skip to content

Commit 1e2b38d

Browse files
authored
repair max_zoom and max_native_zoom (#1952)
1 parent 5086929 commit 1e2b38d

2 files changed

Lines changed: 21 additions & 16 deletions

File tree

folium/folium.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,12 @@ class Map(JSCSSMixin, MacroElement):
112112
pass a custom URL, pass a TileLayer object,
113113
or pass `None` to create a map without tiles.
114114
For more advanced tile layer options, use the `TileLayer` class.
115-
min_zoom: int, default 0
115+
min_zoom: int, optional, default 0
116116
Minimum allowed zoom level for the tile layer that is created.
117-
max_zoom: int, default 18
117+
Filled by xyzservices by default.
118+
max_zoom: int, optional, default 18
118119
Maximum allowed zoom level for the tile layer that is created.
120+
Filled by xyzservices by default.
119121
zoom_start: int, default 10
120122
Initial zoom level for the map.
121123
attr: string, default None
@@ -244,8 +246,8 @@ def __init__(
244246
position: str = "relative",
245247
tiles: Union[str, TileLayer, None] = "OpenStreetMap",
246248
attr: Optional[str] = None,
247-
min_zoom: int = 0,
248-
max_zoom: int = 18,
249+
min_zoom: Optional[int] = None,
250+
max_zoom: Optional[int] = None,
249251
zoom_start: int = 10,
250252
min_lat: int = -90,
251253
max_lat: int = 90,

folium/raster_layers.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ class TileLayer(Layer):
4040
You can also pass a custom tileset by passing a
4141
:class:`xyzservices.TileProvider` or a Leaflet-style
4242
URL to the tiles parameter: ``https://{s}.yourtiles.com/{z}/{x}/{y}.png``.
43-
min_zoom: int, default 0
44-
Minimum allowed zoom level for this tile layer.
45-
max_zoom: int, default 18
46-
Maximum allowed zoom level for this tile layer.
43+
min_zoom: int, optional, default 0
44+
Minimum allowed zoom level for this tile layer. Filled by xyzservices by default.
45+
max_zoom: int, optional, default 18
46+
Maximum allowed zoom level for this tile layer. Filled by xyzservices by default.
4747
max_native_zoom: int, default None
4848
The highest zoom level at which the tile server can provide tiles.
49-
If provided you can zoom in past this level. Else tiles will turn grey.
49+
Filled by xyzservices by default.
50+
By setting max_zoom higher than max_native_zoom, you can zoom in
51+
past max_native_zoom, tiles will be autoscaled.
5052
attr: string, default None
5153
Map tile attribution; only required if passing custom tile URL.
5254
detect_retina: bool, default False
@@ -89,8 +91,8 @@ class TileLayer(Layer):
8991
def __init__(
9092
self,
9193
tiles: Union[str, xyzservices.TileProvider] = "OpenStreetMap",
92-
min_zoom: int = 0,
93-
max_zoom: int = 18,
94+
min_zoom: Optional[int] = None,
95+
max_zoom: Optional[int] = None,
9496
max_native_zoom: Optional[int] = None,
9597
attr: Optional[str] = None,
9698
detect_retina: bool = False,
@@ -117,8 +119,9 @@ def __init__(
117119

118120
if isinstance(tiles, xyzservices.TileProvider):
119121
attr = attr if attr else tiles.html_attribution # type: ignore
120-
min_zoom = tiles.get("min_zoom", min_zoom)
121-
max_zoom = tiles.get("max_zoom", max_zoom)
122+
min_zoom = min_zoom or tiles.get("min_zoom")
123+
max_zoom = max_zoom or tiles.get("max_zoom")
124+
max_native_zoom = max_native_zoom or tiles.get("max_zoom")
122125
subdomains = tiles.get("subdomains", subdomains)
123126
if name is None:
124127
name = tiles.name.replace(".", "").lower()
@@ -137,9 +140,9 @@ def __init__(
137140
raise ValueError("Custom tiles must have an attribution.")
138141

139142
self.options = parse_options(
140-
min_zoom=min_zoom,
141-
max_zoom=max_zoom,
142-
max_native_zoom=max_native_zoom or max_zoom,
143+
min_zoom=min_zoom or 0,
144+
max_zoom=max_zoom or 18,
145+
max_native_zoom=max_native_zoom,
143146
no_wrap=no_wrap,
144147
attribution=attr,
145148
subdomains=subdomains,

0 commit comments

Comments
 (0)