Skip to content

Commit 60ae79c

Browse files
authored
GeoJson: add to parent after adding data (#1190)
1 parent 2122625 commit 60ae79c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

folium/features.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,14 +421,16 @@ class GeoJson(Layer):
421421
{% if this.style %}
422422
style: {{ this.get_name() }}_styler,
423423
{%- endif %}
424-
}).addTo({{ this._parent.get_name() }});
424+
});
425+
function {{ this.get_name() }}_add (data) {
426+
{{ this.get_name() }}.addData(data)
427+
.addTo({{ this._parent.get_name() }});
428+
}
425429
{%- if this.embed %}
426-
{{ this.get_name() }}.addData({{ this.data|tojson }});
430+
{{ this.get_name() }}_add({{ this.data|tojson }});
427431
{%- else %}
428-
$.ajax({url: {{ this.embed_link|tojson }}, dataType: 'json', async: true,
429-
success: function(data) {
430-
{{ this.get_name() }}.addData(data);
431-
}});
432+
$.ajax({{ this.embed_link|tojson }}, {dataType: 'json'})
433+
.done({{ this.get_name() }}_add);
432434
{%- endif %}
433435
{% endmacro %}
434436
""") # noqa

0 commit comments

Comments
 (0)