Skip to content

Commit 3d72f03

Browse files
committed
fix a doc bug and parse all options as json
1 parent eb05df4 commit 3d72f03

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

folium/map.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ class TileLayer(Layer):
411411
Adds the layer as an optional overlay (True) or the base layer (False).
412412
control : bool, default True
413413
Whether the Layer will be included in LayerControls.
414-
subdomains: string, default 'abc'
414+
subdomains: list of strings, default ['abc']
415415
Subdomains of the tile service.
416416
"""
417417
def __init__(self, tiles='OpenStreetMap', min_zoom=1, max_zoom=18,
@@ -425,12 +425,15 @@ def __init__(self, tiles='OpenStreetMap', min_zoom=1, max_zoom=18,
425425
self._name = 'TileLayer'
426426
self._env = ENV
427427

428-
self.min_zoom = min_zoom
429-
self.max_zoom = max_zoom
430-
self.no_wrap = no_wrap
431-
self.subdomains = subdomains
432-
433-
self.detect_retina = detect_retina
428+
options = {
429+
'minZoom': min_zoom,
430+
'maxZoom': max_zoom,
431+
'noWrap': no_wrap,
432+
'attribution': attr,
433+
'subdomains': subdomains,
434+
'detectRetina': detect_retina,
435+
}
436+
self.options = json.dumps(options, sort_keys=True, indent=2)
434437

435438
self.tiles = ''.join(tiles.lower().strip().split())
436439
if self.tiles in ('cloudmade', 'mapbox') and not API_key:
@@ -457,16 +460,8 @@ def __init__(self, tiles='OpenStreetMap', min_zoom=1, max_zoom=18,
457460
{% macro script(this, kwargs) %}
458461
var {{this.get_name()}} = L.tileLayer(
459462
'{{this.tiles}}',
460-
{
461-
maxZoom: {{this.max_zoom}},
462-
minZoom: {{this.min_zoom}},
463-
noWrap: {{this.no_wrap.__str__().lower()}},
464-
attribution: '{{this.attr}}',
465-
detectRetina: {{this.detect_retina.__str__().lower()}},
466-
subdomains: '{{this.subdomains}}'
467-
}
463+
{{ this.options }}
468464
).addTo({{this._parent.get_name()}});
469-
470465
{% endmacro %}
471466
""") # noqa
472467

0 commit comments

Comments
 (0)