From b19bf20516f0f755e6cc827116999d83b1c53b63 Mon Sep 17 00:00:00 2001 From: Frank <33519926+Conengmo@users.noreply.github.com> Date: Sat, 13 Jun 2020 12:23:09 +0200 Subject: [PATCH] Use synchronous ajax in GeoJson --- folium/features.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/folium/features.py b/folium/features.py index 8f121294e..c710bfb32 100644 --- a/folium/features.py +++ b/folium/features.py @@ -428,17 +428,20 @@ class GeoJson(Layer): {% if this.style %} style: {{ this.get_name() }}_styler, {%- endif %} - }).addTo({{ this._parent.get_name() }}); + }); function {{ this.get_name() }}_add (data) { - {{ this.get_name() }}.addData(data); + {{ this.get_name() }} + .addData(data) + .addTo({{ this._parent.get_name() }}); } {%- if this.embed %} {{ this.get_name() }}_add({{ this.data|tojson }}); {%- else %} - $.ajax({{ this.embed_link|tojson }}, {dataType: 'json'}) + $.ajax({{ this.embed_link|tojson }}, {dataType: 'json', async: false}) .done({{ this.get_name() }}_add); {%- endif %} + {% endmacro %} """) # noqa