Skip to content

Commit

Permalink
add django-geojson template filter to the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasalexanderweber committed Dec 29, 2023
1 parent 7f22676 commit a06d3fc
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion docs/templates.rst
Expand Up @@ -24,6 +24,21 @@ The easy way :

{% leaflet_map "yourmap" callback="window.map_init_basic" %}

django-leaflet is compatible with django-geojson fields, so you can draw e.g. markers based on the `django-geojson template filter <https://django-geojson.readthedocs.io/en/latest/views.html#geojson-template-filter/>`_:

::

<script>
function map_init_basic (map, options) {
...
var raw_data = '{{ object_list|geojsonfeature|safe|escapejs }}';
var data = JSON.parse(raw_data);
L.geoJSON(data).addTo(map);
...
}
</script>



**Using events**

Expand Down Expand Up @@ -52,7 +67,6 @@ For Internet Explorer support, we fallback on jQuery if available ::
...
});


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

Expand Down

0 comments on commit a06d3fc

Please sign in to comment.