Skip to content

Commit

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

'NO_GLOBALS' = False

Force Leaflet 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 break the method ``L.Icon.Default.imagePath()``.

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

'FORCE_IMAGE_PATH': True

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 88a408c

Please sign in to comment.