diff --git a/folium/features.py b/folium/features.py index 8385b3d46e..ad7287d465 100644 --- a/folium/features.py +++ b/folium/features.py @@ -24,6 +24,7 @@ get_bounds, get_obj_in_upper_tree, image_to_url, + javascript_identifier_path_to_array_notation, none_max, none_min, parse_options, @@ -901,7 +902,7 @@ class TopoJson(JSCSSMixin, Layer): var {{ this.get_name() }} = L.geoJson( topojson.feature( {{ this.get_name() }}_data, - {{ this.get_name() }}_data.{{ this.object_path }} + {{ this.get_name() }}_data{{ this._safe_object_path }} ), { {%- if this.smooth_factor is not none %} @@ -949,6 +950,9 @@ def __init__( self.data = data self.object_path = object_path + self._safe_object_path = javascript_identifier_path_to_array_notation( + object_path + ) if style_function is None: diff --git a/folium/utilities.py b/folium/utilities.py index 98bf794710..2b319194ae 100644 --- a/folium/utilities.py +++ b/folium/utilities.py @@ -493,3 +493,12 @@ def parse_options(**kwargs): def escape_backticks(text): """Escape backticks so text can be used in a JS template.""" return re.sub(r"(?