Skip to content

Commit

Permalink
Merge a2412ca into e54a401
Browse files Browse the repository at this point in the history
  • Loading branch information
nimasmi committed Jan 26, 2015
2 parents e54a401 + a2412ca commit 5d241e4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
15 changes: 15 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,21 @@ and no longer adds map objects into ``window.maps`` array by default. To restore

'NO_GLOBALS' = False

Manually specify image path
~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you are using staticfiles compression libraries such as django_compressor,
which can do any of compressing, concatenating or renaming javascript files.
This may break Leaflet's own ability to determine its installed path, and in
turn it will break the method ``L.Icon.Default.imagePath()``.

To use Django's own knowledge of its static files to set this value manually,
use::

'FORCE_IMAGE_PATH': True

This will append to the output html::

L.Icon.Default.imagePath = "{% static "leaflet/images" %}";

Plugins
~~~~~~~
Expand Down
3 changes: 3 additions & 0 deletions leaflet/templates/leaflet/js.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@
{% if with_forms %}{% include "leaflet/_leaflet_draw_i18n.js" %}{% endif %}
L.Control.ResetView.TITLE = "{% trans "Reset view" %}";
L.Control.ResetView.ICON = "url({% static "leaflet/images/reset-view.png" %})";
{% if FORCE_IMAGE_PATH %}
L.Icon.Default.imagePath = "{% static "leaflet/images" %}";
{% endif %}
</script>
4 changes: 3 additions & 1 deletion leaflet/templatetags/leaflet_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ def leaflet_js(plugins=None):
"""
plugin_names = _get_plugin_names(plugins)
with_forms = PLUGIN_FORMS in plugin_names or PLUGIN_ALL in plugin_names
FORCE_IMAGE_PATH = app_settings.get('FORCE_IMAGE_PATH')
return {
"DEBUG": settings.TEMPLATE_DEBUG,
"SRID": str(SRID) if SRID else None,
"PLUGINS_JS": _get_all_resources_for_plugins(plugin_names, 'js'),
"with_forms": with_forms
"with_forms": with_forms,
"FORCE_IMAGE_PATH": FORCE_IMAGE_PATH
}


Expand Down

0 comments on commit 5d241e4

Please sign in to comment.