Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion folium/plugins/minimap.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class MiniMap(JSCSSMixin, MacroElement):
{% macro script(this, kwargs) %}
var {{ this.tile_layer.get_name() }} = L.tileLayer(
{{ this.tile_layer.tiles|tojson }},
{{ this.tile_layer.options|tojson }}
{{ this.tile_layer.options|tojavascript }}
);
var {{ this.get_name() }} = new L.Control.MiniMap(
{{ this.tile_layer.get_name() }},
Expand Down
25 changes: 25 additions & 0 deletions tests/plugins/test_minimap.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,28 @@ def test_minimap():
out = normalize(m._parent.render())
# verify that tiles are being used
assert r"https://tile.openstreetmap.org" in out


def test_minimap_tile_layer_options_are_camelized():
"""The minimap's tile layer must get the same options as a regular one.

Leaflet ignores snake_case keys such as ``tile_size``, so options like
tileSize, zoomOffset and maxNativeZoom were lost on the minimap.
"""
m = folium.Map(tiles=None)
tile_layer = folium.TileLayer(
"https://example.com/{z}/{x}/{y}.png",
attr="example",
tile_size=512,
zoom_offset=-1,
max_native_zoom=14,
)
plugins.MiniMap(tile_layer=tile_layer).add_to(m)

out = normalize(m._parent.render())

assert '"tileSize": 512' in out
assert '"zoomOffset": -1' in out
assert '"maxNativeZoom": 14' in out
assert "tile_size" not in out
assert "max_native_zoom" not in out
Loading