Created
May 5, 2017 08:57
-
-
Save frague59/f9f02f50db859052533ca7aa2c2bad92 to your computer and use it in GitHub Desktop.
Updates to use __PREFIX__ TEMPLATE VARIABLE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% load i18n %} | |
{% load static from staticfiles %} | |
{% if creatediv %} | |
<div id="{{ name }}" class="leaflet-container-default"></div>{% endif %} | |
<script type="text/javascript"> | |
(function () { | |
window.DEBUG_LEAFLET && console.debug('_leaflet_map.html : name = ' + '{{ name }}'); | |
function loadmap() { | |
window.DEBUG_LEAFLET && console.debug('_leaflet_map.html:loadmap()'); | |
var djoptions = {% autoescape off %}{{ djoptions }}{% endautoescape %}, | |
options = { | |
djoptions: djoptions, | |
initfunc: loadmap, | |
globals: {{ NO_GLOBALS|yesno:"false,true"}}, | |
callback: window.LEAFLET_FUNCTIONS['{{ name }}'] | |
// callback: {{ callback|default:"null" }} | |
}; | |
L.Map.djangoMap('{{ name }}', options); | |
} | |
var loadevents = {% autoescape off %}{{ loadevents }}{% endautoescape %}; | |
window.DEBUG_LEAFLET && console.debug('_leaflet_map.html: loadevents.length = ' + loadevents.length); | |
if (loadevents.length === 0) { | |
window.DEBUG_LEAFLET && console.debug('_leaflet_map.html: loadmap call'); | |
loadmap(); | |
} else if (window.addEventListener) { | |
for (var i = 0; i < loadevents.length; i++) { | |
var event = loadevents[i]; | |
window.DEBUG_LEAFLET && console.debug('_leaflet_map.html:addEventListener('+ event +')'); | |
// window.addEventListener(event, loadmap, false); | |
loadmap(); | |
} | |
} else if (window.jQuery) { | |
window.DEBUG_LEAFLET && console.debug('_leaflet_map.html:jQuery call !'); | |
jQuery(window).on(loadevents.join(' '), loadmap); | |
} | |
{% if not NO_GLOBALS %} | |
// Put initialization function in global scope (like django-leaflet < 0.7) | |
window['loadmap' + '{{ name }}'] = loadmap; | |
{% endif %} | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment