Commit 1af1c62d authored by Florent Chehab's avatar Florent Chehab

Marker clustering added

parent 402c8fb9
../../../node_modules/leaflet.markercluster/dist/MarkerCluster.Default.css
\ No newline at end of file
../../../node_modules/leaflet.markercluster/dist/MarkerCluster.css
\ No newline at end of file
../../../node_modules/leaflet/dist/images
\ No newline at end of file
../../../node_modules/leaflet.markercluster/dist/leaflet.markercluster.js
\ No newline at end of file
......@@ -4,8 +4,14 @@
{% block content %}
<div id="mapid" style="height:400px"></div>
<link rel="stylesheet" href="{% static 'css/leaflet.css' %}"/>
<script type="text/javascript" src="{% static 'js/leaflet.js' %}"></script>
<link rel="stylesheet" href="{% static 'css/MarkerCluster.css' %}"/>
<link rel="stylesheet" href="{% static 'css/MarkerCluster.Default.css' %}"/>
<script type="text/javascript" src="{% static 'js/leaflet.markercluster.js' %}"></script>
<script>
var Stamen_Watercolor = L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.{ext}', {
......@@ -43,16 +49,23 @@
"Satellite": Esri_WorldImagery
};
// End of handling of layers, now let's handle markers.
var mymap = L.map('mapid', {'layers':Stamen}).setView([45, 1.2], 4);
var universities_markers = L.markerClusterGroup();
L.control.layers(baseLayers).addTo(mymap);
{% for univ in universities %}
L.marker([{{ univ.localization_lat }}, {{ univ.localization_lon }}]).addTo(mymap)
.bindPopup("<b>{{ univ.name }}</b>").openPopup();
L.marker([{{ univ.localization_lat }}, {{ univ.localization_lon }}]).addTo(universities_markers)
.bindPopup("<b>{{ univ.name }}</b>");
{% endfor %}
// Creation of map
var mymap = L.map('mapid', {'layers':[Stamen, universities_markers]}).setView([45, 1.2], 4);
L.control.layers(baseLayers).addTo(mymap);
// Extra feature
var popup = L.popup();
function onMapClick(e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment