From c71583e7d5a0954288c70a8eb453a5a02ca35fc6 Mon Sep 17 00:00:00 2001 From: KhadeerBasha1232 Date: Fri, 20 Nov 2026 20:17:31 +0530 Subject: [PATCH] Camelize MiniMap tile layer options The MiniMap template serialized its tile layer's options with tojson, while TileLayer itself uses tojavascript. Leaflet ignored the resulting snake_case keys (tile_size, zoom_offset, max_native_zoom, detect_retina, no_wrap, ...), so the minimap didn't honour them. Co-Authored-By: Claude Opus 5.5 --- folium/plugins/minimap.py | 2 +- tests/plugins/test_minimap.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/folium/plugins/minimap.py b/folium/plugins/minimap.py index 0bd502d4db..7ca43420b3 100644 --- a/folium/plugins/minimap.py +++ b/folium/plugins/minimap.py @@ -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() }}, diff --git a/tests/plugins/test_minimap.py b/tests/plugins/test_minimap.py index f80f311526..b8b8d3fa87 100644 --- a/tests/plugins/test_minimap.py +++ b/tests/plugins/test_minimap.py @@ -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