Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions docs/templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,19 @@ If it contains several layers, a layer switcher will then be added automatically
'TILES': [('Satellite', 'http://server/a/...', {'attribution': '© Big eye', 'maxZoom': 16}),
('Streets', 'http://server/b/...', {'attribution': '© Contributors'})]


If you omit this setting, a default OpenSTreetMap layer will be created for your convenience. If you do not want
a default layers (perhaps to add them in your own JavaScript code on map initialization), set the value to an empty
list, as shown below.
OpenStreetMap requires you to set the
`referer <https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/referrerPolicy>`_
Comment thread
maxfenv marked this conversation as resolved.
Outdated
header on all tile requests as part of their
`tile usage policy <https://operations.osmfoundation.org/policies/tiles/>`_.
Leaflet has a `mechanism to do this <https://leafletjs.com/reference.html#tilelayer-referrerpolicy>`_
which is enabled in django-leaflet by setting ``referrerPolicy``
as part of the ``options`` dict::

'TILES': [('Satellite', 'http://server/a/...', {'attribution': '...', 'referrerPolicy': 'strict-origin'}),

If you omit this setting, a default OpenStreetMap layer (with ``referrerPolicy: 'strict-origin'`` will
be created for your convenience. If you do not want any default layers (perhaps to add them in your
own JavaScript code on map initialization), set the value to an empty list, as shown below.

::

Expand Down
11 changes: 9 additions & 2 deletions leaflet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@
from django.utils.translation import gettext_lazy as _
from django.utils.functional import lazy, Promise

DEFAULT_TILES = [(_('OSM'), '//tile.openstreetmap.org/{z}/{x}/{y}.png',
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors')]
DEFAULT_TILES = [
(
_('OSM'), '//tile.openstreetmap.org/{z}/{x}/{y}.png',
{
'attribution': '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
'referrerPolicy': 'strict-origin',
}
)
]

LEAFLET_CONFIG = getattr(settings, 'LEAFLET_CONFIG', {})
app_settings = dict({
Expand Down
Loading