Skip to content

Commit b0620d4

Browse files
nemesifierGagaro
authored andcommitted
[JS] Allow storing global leaflet map instances (makinacorpus#204)
This patch allows to store global references to leaflet map instances created in loadmap() in order to enable more complex customisations that require direct access to the leaflet map instances
1 parent cdeabf7 commit b0620d4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

leaflet/templates/leaflet/_leaflet_map.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
function loadmap() {
88
var djoptions = {% autoescape off %}{{ djoptions }}{% endautoescape %},
99
options = {djoptions: djoptions, initfunc: loadmap,
10-
globals: {{ NO_GLOBALS|yesno:"false,true"}}, callback: {{ callback|default:"null" }}};
11-
L.Map.djangoMap('{{ name }}', options);
10+
globals: {{ NO_GLOBALS|yesno:"false,true"}}, callback: {{ callback|default:"null" }}},
11+
map = L.Map.djangoMap('{{ name }}', options);
12+
{% if not NO_GLOBALS %}
13+
window['leafletmap' + '{{ name }}'] = map;
14+
{% endif %}
1215
}
1316
var loadevents = {% autoescape off %}{{ loadevents }}{% endautoescape %};
1417
if (loadevents.length === 0) loadmap();

0 commit comments

Comments
 (0)