On centre la carte sur l'élément cliqué

This commit is contained in:
Jean-Marie Favreau 2024-07-06 16:44:50 +02:00
parent 533d52a24e
commit 5797dc98bb

View File

@ -64,7 +64,10 @@
{% for place in object_list %}
markerArray.push(L.marker([{{ place.location }}]).bindPopup('<a href="{% url 'view_place' place.pk %}">{{ place.name }}</a><br />{% if place.address %}{{ place.address }}, {% endif %}{{ place.city }}'));
window.mMapping[{{ place.id }}] = markerArray[markerArray.length - 1];
window.jQuery('a#open-map-{{ place.id }}').click(function(){ window.mMapping[{{ place.id }}].openPopup();});
window.jQuery('a#open-map-{{ place.id }}').click(function(){
window.mMapping[{{ place.id }}].openPopup();
map.panTo(window.mMapping[{{ place.id }}].getLatLng());
});
{% endfor %}
{% endif %}
var group = L.featureGroup(window.markerArray).addTo(map);