Skip to content

Commit b819b3a

Browse files
committed
Remove add_tile_layer method, less arguments
Remove the `Map.add_tile_layer()` method, instead the `TileLayer` class should be used directly. Remove a couple advanced `TileLayer` arguments from `Map`. If someone needs those they should use `TileLayer` directly.
1 parent 87854a9 commit b819b3a

File tree

1 file changed

+30
-42
lines changed

1 file changed

+30
-42
lines changed

folium/folium.py

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,15 @@ class Map(MacroElement):
9393
tiles: str, default 'OpenStreetMap'
9494
Map tileset to use. Can choose from a list of built-in tiles,
9595
pass a custom URL or pass `None` to create a map without tiles.
96-
API_key: str, default None
97-
API key for Cloudmade or Mapbox tiles.
96+
For more advanced tile layer options, use the `TileLayer` class.
9897
min_zoom: int, default 0
9998
Minimum allowed zoom level for the tile layer that is created.
10099
max_zoom: int, default 18
101100
Maximum allowed zoom level for the tile layer that is created.
102-
max_native_zoom: int, default None
103-
The highest zoom level at which the tile server can provide tiles.
104-
If provided you can zoom in past this level. Else tiles will turn grey.
105101
zoom_start: int, default 10
106102
Initial zoom level for the map.
107103
attr: string, default None
108104
Map tile attribution; only required if passing custom tile URL.
109-
detect_retina: bool, default False
110-
If true and user is on a retina display, it will request four
111-
tiles of half the specified size and a bigger zoom level in place
112-
of one to utilize the high resolution.
113105
crs : str, default 'EPSG3857'
114106
Defines coordinate reference systems for projecting geographical points
115107
into pixel (screen) coordinates and back.
@@ -220,15 +212,32 @@ class Map(MacroElement):
220212
{% endmacro %}
221213
""")
222214

223-
def __init__(self, location=None, width='100%', height='100%',
224-
left='0%', top='0%', position='relative',
225-
tiles='OpenStreetMap', API_key=None, max_zoom=18, min_zoom=0,
226-
max_native_zoom=None, zoom_start=10, world_copy_jump=False,
227-
no_wrap=False, attr=None, min_lat=-90, max_lat=90,
228-
min_lon=-180, max_lon=180, max_bounds=False,
229-
detect_retina=False, crs='EPSG3857', control_scale=False,
230-
prefer_canvas=False, no_touch=False, disable_3d=False,
231-
subdomains='abc', png_enabled=False, zoom_control=True):
215+
def __init__(
216+
self,
217+
location=None,
218+
width='100%',
219+
height='100%',
220+
left='0%',
221+
top='0%',
222+
position='relative',
223+
tiles='OpenStreetMap',
224+
attr=None,
225+
min_zoom=0,
226+
max_zoom=18,
227+
zoom_start=10,
228+
min_lat=-90,
229+
max_lat=90,
230+
min_lon=-180,
231+
max_lon=180,
232+
max_bounds=False,
233+
crs='EPSG3857',
234+
control_scale=False,
235+
prefer_canvas=False,
236+
no_touch=False,
237+
disable_3d=False,
238+
png_enabled=False,
239+
zoom_control=True,
240+
):
232241
super(Map, self).__init__()
233242
self._name = 'Map'
234243
self._env = ENV
@@ -274,12 +283,9 @@ def __init__(self, location=None, width='100%', height='100%',
274283
self.objects_to_stay_in_front = []
275284

276285
if tiles:
277-
self.add_tile_layer(
278-
tiles=tiles, min_zoom=min_zoom, max_zoom=max_zoom,
279-
max_native_zoom=max_native_zoom, no_wrap=no_wrap, attr=attr,
280-
API_key=API_key, detect_retina=detect_retina,
281-
subdomains=subdomains
282-
)
286+
tile_layer = TileLayer(tiles=tiles, attr=attr,
287+
min_zoom=min_zoom, max_zoom=max_zoom)
288+
self.add_child(tile_layer, name=tile_layer.tile_name)
283289

284290
def _repr_html_(self, **kwargs):
285291
"""Displays the HTML Map in a Jupyter notebook."""
@@ -329,24 +335,6 @@ def _repr_png_(self):
329335
return None
330336
return self._to_png()
331337

332-
def add_tile_layer(self, tiles='OpenStreetMap', name=None,
333-
API_key=None, max_zoom=18, min_zoom=0,
334-
max_native_zoom=None, attr=None, active=False,
335-
detect_retina=False, no_wrap=False, subdomains='abc',
336-
**kwargs):
337-
"""
338-
Add a tile layer to the map. See TileLayer for options.
339-
340-
"""
341-
tile_layer = TileLayer(tiles=tiles, name=name,
342-
min_zoom=min_zoom, max_zoom=max_zoom,
343-
max_native_zoom=max_native_zoom,
344-
attr=attr, API_key=API_key,
345-
detect_retina=detect_retina,
346-
subdomains=subdomains,
347-
no_wrap=no_wrap)
348-
self.add_child(tile_layer, name=tile_layer.tile_name)
349-
350338
def render(self, **kwargs):
351339
"""Renders the HTML representation of the element."""
352340
figure = self.get_root()

0 commit comments

Comments
 (0)