From 9e06578c4bfe854f48a2e61f67db905d23828cee Mon Sep 17 00:00:00 2001 From: leosw Date: Tue, 20 Oct 2026 19:40:12 +0200 Subject: [PATCH] =?UTF-8?q?Gestion=20des=20icones=20des=20pois=20affich?= =?UTF-8?q?=C3=A9s=20sur=20les=20carte=20des=20pages=20poi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/views/d.map.html | 2 +- public/views/d.poi.edit.html | 2 +- public/views/d.poi.view.html | 2 +- public/views/js/d.poi_map.js | 26 ++++++++++++-------------- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/public/views/d.map.html b/public/views/d.map.html index 443fcda..4aa09eb 100755 --- a/public/views/d.map.html +++ b/public/views/d.map.html @@ -41,7 +41,7 @@ ?> "": { color: "", size: , shape: "", icon: "" }, - "default": { color: "#ef2929", size: 16, shape: "square", icon: "img/default.svg" } + "default": { color: "#ef2929", size: 16, shape: "square", icon: "third/leaflet/images/marker-icon.png" } }; diff --git a/public/views/d.poi.edit.html b/public/views/d.poi.edit.html index e590dd9..507984f 100755 --- a/public/views/d.poi.edit.html +++ b/public/views/d.poi.edit.html @@ -251,7 +251,7 @@ $( "#name" ).change(function() { ?> "": { color: "", size: , shape: "", icon: "" }, - "default": { color: "#ef2929", size: 16, shape: "square", icon: "img/default.svg" } + "default": { color: "#ef2929", size: 16, shape: "square", icon: "third/leaflet/images/marker-icon.png" } }; diff --git a/public/views/d.poi.view.html b/public/views/d.poi.view.html index 54b223f..f7f22df 100644 --- a/public/views/d.poi.view.html +++ b/public/views/d.poi.view.html @@ -312,7 +312,7 @@ ?> "": { color: "", size: , shape: "", icon: "" }, - "default": { color: "#ef2929", size: 16, shape: "square", icon: "img/default.svg" } + "default": { color: "#ef2929", size: 16, shape: "square", icon: "third/leaflet/images/marker-icon.png" } }; diff --git a/public/views/js/d.poi_map.js b/public/views/js/d.poi_map.js index 423975a..b36bf90 100755 --- a/public/views/js/d.poi_map.js +++ b/public/views/js/d.poi_map.js @@ -155,14 +155,10 @@ $(document).ready(function() { var startLat = (typeof poi_lat !== "undefined" && poi_lat) ? poi_lat : 47; var startLon = (typeof poi_lon !== "undefined" && poi_lon) ? poi_lon : 3; - // Icône : si poi_type défini, on l’utilise, sinon icône Leaflet par défaut - var poiicon = null; + // Icône centrale : même règle que les POIs + var poiType = (typeof poi_type !== "undefined" && poi_type) ? poi_type : "default"; if (typeof poi_type !== "undefined" && poi_type) { - poiicon = L.icon({ - iconSize: [24, 24], - iconAnchor: [12, 12], - iconUrl: root + "views/img/" + poi_type + ".svg" - }); + var poiicon = getMarkerIconFor(poiType, mymap.getZoom()); } if (poiicon) { @@ -171,6 +167,13 @@ $(document).ready(function() { poi_layer = L.marker([startLat, startLon], { draggable: isEdit }).addTo(mymap); } + // Si le zoom change, on recalcule la taille comme pour les POIs + mymap.on('zoomend', function() { + if (poi_layer) { + poi_layer.setIcon(getMarkerIconFor(poiType, mymap.getZoom())); + } + }); + if (isEdit) { poi_layer.bindTooltip("Glissez moi au bon endroit.", { permanent: true, direction: 'auto' }).openTooltip(); } @@ -204,15 +207,10 @@ $(document).ready(function() { } }); - var editPoiIcon = L.icon({ - iconSize: [24, 24], - iconAnchor: [12, 12] - }); - $("#type_selector label").click(function(e) { poi_layer.unbindTooltip(); - editPoiIcon.options.iconUrl = e.currentTarget.firstChild.currentSrc; - poi_layer.setIcon(editPoiIcon); + poiType = e.currentTarget.getAttribute("for"); + poi_layer.setIcon(getMarkerIconFor(poiType, mymap.getZoom())); }); $("#elevation_icon").click(function(e) {