Django Leaflet Documentation, Release 0.20
2.3.2 Initial map center and zoom level
In addition to limiting your maps with SPATIAL_EXTENT, you can also specify initial map center, default, min and
max zoom level, coordinate values precision:
'DEFAULT_CENTER': (6.0, 45.0),
'DEFAULT_ZOOM': 16,
'MIN_ZOOM': 3,
'MAX_ZOOM': 18,
'DEFAULT_PRECISION': 6,
The tuple/list must contain (lat,lng) coords.
Notice that if you do not use SPATIAL_EXTENT, but you do specify a value for the DEFAULT_ZOOM entry, you
must also indicate a DEFAULT_CENTER, or you will get an empty, not working pane, for all new database records
without a default geometry value. This is regarded as an error in the configuration, not a bug in the software.
2.3.3 Default tiles layer
To globally add a tiles layer to your maps:
'TILES': 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
This setting can also be a list of tuples (name, url, options). The python dict options accepts all the
Leaflet tileLayers options.
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.
'TILES': []
Note that this will also prevent any overlays defined in settings from being displayed.
2.3.4 Overlay layers
To globally add an overlay layer, use the same syntax as tiles:
'OVERLAYS': [('Cadastral', 'http://server/a/{z}/{x}/{y}.png', {'attribution': '©
˓→IGN'})]
Currently, overlay layers from settings are limited to tiles. For vectorial overlays, you will have to add them via
JavaScript (see also events).
To add layers other than the tiles supported by the global config, e.g. WMS layers, insert a script block, get a reference
to the map’s layerscontrol, and add any layer supported by Leaflet as overlays to that layerscontrol object.
In a template:
2.3. Configuration 7