Skip to main content
*django-leaflet* allows you to use `Leaflet <http://leaflet.cloudmade.com>`_
in your `Django <https://www.djangoproject.com>`_ projects.


=======
INSTALL
=======

::

pip install django-leaflet

=====
USAGE
=====

* Add ``leaflet`` to your ``INSTALLED_APPS``

* Add the HTML header :

::

{% load leaflet_tags %}

<head>
...
{% leaflet_js %}
{% leaflet_css %}
</head>


* Add the map in your page, providing a name :
::

...
<body>
...
{% leaflet_map "yourmap" %}
...
</body>

* Your maps shows up!


Use Leaflet API
---------------

You can use the *Leaflet* API as usual in the map initialization callback :

::

<script type="text/javascript">
function yourmapInit(map, bounds) {
...
L.marker([50.5, 30.5]).addTo(map);
...
}
</script>


Customize map size
------------------

::

<style>

.leaflet-container { /* all maps */
width: 600px;
height: 400px;
}

#specialbigmap {
height: 800px;
}

</style>



Configuration
=============

In order to configure *django-leaflet*, just add a new section in your settings :

::

LEAFLET_CONFIG = {
# conf here
}


Spatial extent
--------------

You can configure a global spatial extent for your maps, that will automatically
center your maps, restrict panning and add reset view and scale controls.
(*See advanced usage to tweak that.*)

'SPATIAL_EXTENT' : (5.0, 44.0, 7.5, 46)

Default tiles layer
-------------------

To globally add a tiles layer to your maps :

'TILES_URL' : 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'

This setting can also be a list of tuples (name, url) ! A layer switcher
will then be added automatically.

Leaflet version
---------------

By default, it runs the last stable version (*0.4.4*) of Leaflet. But it is possible
to run the ``legacy`` version (*0.3.1*) or the ``unstable`` under development (*master*).

'LEAFLET_VERSION' : 'legacy'

Scale control
-------------

Disable scale control with km and miles :

'SCALE' : False


Advanced usage
==============

{% leaflet_map %} tag parameters
--------------------------------

callback

A Javascript function name for initialization callback. (Default:``name + Init``)

``{% leaflet_map "yourmap" callback="window.customMap" %}``

fixextent

Control if map initial view shoud be set to extent setting. (Default: ``True``).
Setting fixextent to ``False`` will prevent view reset and scale controls
to be added.


Projection
----------

It is possible to setup the map spatial reference in ``LEAFLET_CONFIG`` :

'SRID' : 2154 # See http://spatialreference.org

Additional parameters are then required to compute scale levels :

'MAX_RESOLUTION' : 1142.7383,
'TILES_EXTENT' : [700000,6325197,1060000,6617738],

For more information, `have a look at this example <http://blog.mathieu-leplatre.info/leaflet-tiles-in-lambert-93-projection-2154.html>`_.

By default, Django will try to load the spatial reference from your static files at "proj4js/{{ srid }}.js". If it fails, it will eventually rely on `<spatialreference.org>`_.

=======
AUTHORS
=======

* Mathieu Leplatre <mathieu.leplatre@makina-corpus.com>

|makinacom|_

.. |makinacom| image:: http://depot.makina-corpus.org/public/logo.gif
.. _makinacom: http://www.makina-corpus.com

=======
LICENSE
=======

* Lesser GNU Public License
* Leaflet Copyright - 2010-2011 CloudMade, Vladimir Agafonkin


=========
CHANGELOG
=========

0.2.0 (2012-09-22)
==================

* Fix packaging of templates
* Use template for <head> fragment
* Do not rely on spatialreference.org by default
* Default settings for SRID
* Default settings for map extent
* Default map height
* Default tiles base layer
* map variable is not global anymore

0.1.0 (2012-08-13)
==================

* Initial support for map projection
* Show zoom scale by default
* Spatial extent configuration
* Initialization callback instead of global JS variable
* Leaflet version switching
* Global layers configuration

0.0.2 (2012-03-22)
==================

* Add IE conditional CSS


0.0.1 (2012-03-16)
==================

* Initial working version

Metadata

Release files for django-leaflet 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-leaflet 0.2.0
File Size Uploaded Provenance Actions
django-leaflet-0.2.0.zip 276.2 kB Without provenance Details for django-leaflet-0.2.0.zip

Release files / django-leaflet-0.2.0.zip

Download URL django-leaflet-0.2.0.zip
Size 276.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e5f03403e25660ad88ebe5d7702a57930376d3891711794dbe671fa8a26e7fb5
BLAKE2b-256 checksum
How to use checksums
b12028bb51139db5b90afa85511be8937b2276b1d25576a5bfcb5e84528d6290
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-leaflet 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page