diff --git a/docs/templates.rst b/docs/templates.rst index 9a11247..9d033c2 100644 --- a/docs/templates.rst +++ b/docs/templates.rst @@ -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 `_ +header on all tile requests as part of their +`tile usage policy `_. +Leaflet has a `mechanism to do this `_ +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. :: diff --git a/leaflet/__init__.py b/leaflet/__init__.py index 08c3451..0dce647 100644 --- a/leaflet/__init__.py +++ b/leaflet/__init__.py @@ -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', - '© OpenStreetMap contributors')] +DEFAULT_TILES = [ + ( + _('OSM'), '//tile.openstreetmap.org/{z}/{x}/{y}.png', + { + 'attribution': '© OpenStreetMap contributors', + 'referrerPolicy': 'strict-origin', + } + ) +] LEAFLET_CONFIG = getattr(settings, 'LEAFLET_CONFIG', {}) app_settings = dict({