From 2093a584bbe7551cbdc9ac92f4f96aa0c25ae5f1 Mon Sep 17 00:00:00 2001 From: leosw Date: Sun, 18 Oct 2026 19:16:39 +0200 Subject: [PATCH] =?UTF-8?q?Les=20styles=20de=20poi=20du=20calque=20de=20tu?= =?UTF-8?q?iles=20pbf=20sont=20d=C3=A9finis=20dans=20la=20structure=20php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/views/d.map.html | 11 +++++++++++ public/views/js/d.map.js | 19 +++++++++---------- src/Core/poi_types.struct.php | 6 ++++++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/public/views/d.map.html b/public/views/d.map.html index 846017a..ac03542 100755 --- a/public/views/d.map.html +++ b/public/views/d.map.html @@ -38,6 +38,17 @@ "default": "img/default.svg" }; + + window.poi_style_map = { + $t) { + $color = isset($t[2]) ? $t[2] : '#ef2929'; + // Read size/shape from structure if provided, else fallback to sensible defaults + $size = isset($t[6]) ? (int)$t[6] : 16; + $shape = isset($t[7]) ? $t[7] : 'square'; + ?> + "": { color: "", size: , shape: "" }, + + }; diff --git a/public/views/js/d.map.js b/public/views/js/d.map.js index 4146bb8..092c0e0 100755 --- a/public/views/js/d.map.js +++ b/public/views/js/d.map.js @@ -52,7 +52,7 @@ $(document).ready(function() { // --------------------------------------------------------- // Fonction qui génère le SVG du point pour les calques en pbf - function svgDataUriFor(color, size, shape, strokeOpacity = 0.2) { + function svgDataUriFor(color, size, shape, strokeOpacity = 0.4) { const w = size, h = size, strokeWidth = 1, r = Math.max(1, Math.round(size * 0.15)); const inset = 2 + strokeWidth / 2, innerW = w - inset * 2, innerH = h - inset * 2; let shapeSvg; @@ -74,18 +74,17 @@ $(document).ready(function() { return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`; } - var poiStyleMap = { - "wilderness_hut": { color: "#d73a3a", size: 16, shape: "square" }, - "basic_hut": { color: "#d73a3a", size: 14, shape: "square" }, - "alpine_hut": { color: "#d73a3a", size: 18, shape: "square" }, - "halt": { color: "#4caf50", size: 18, shape: "square" }, - "bivouac": { color: "#d73a3a", size: 16, shape: "triangle" }, - "campsite": { color: "#4caf50", size: 16, shape: "triangle" } - }; + function getPoiStyle(type) { + if (window.poi_style_map && window.poi_style_map[type]) { + return window.poi_style_map[type]; + } + // Final hardcoded fallback (keeps previous defaults) + return { color: "#ef2929", size: 14, shape: "square" }; + } function buildPoiVectorIcon(properties) { var type = (properties && (properties.type || properties.poi_type || properties.poiType)) || "default"; - var style = poiStyleMap[type] || { color: "#d73a3a", size: 14, shape: "square" }; + var style = getPoiStyle(type); var iconUrl = svgDataUriFor(style.color, style.size, style.shape); return L.icon({ diff --git a/src/Core/poi_types.struct.php b/src/Core/poi_types.struct.php index e42889a..b860671 100644 --- a/src/Core/poi_types.struct.php +++ b/src/Core/poi_types.struct.php @@ -15,6 +15,7 @@ $poi_types = array( 'b_water' => "💧 Eau à proximité ?", 'b_wood' => "🌲 Bois à proximité ?" ) + , 14, "square" ), "wilderness_hut" => array("Cabane non gardée", "Cabane", "#ef2929", "wilderness_hut", @@ -33,6 +34,7 @@ $poi_types = array( 'b_fireplace' => "🔥 Cheminée ou poêle à bois ?", 'b_toilet' => "🚽 Latrines ou toilettes ?" ) + , 16, "square" ), "alpine_hut" => array("Refuge gardé", "Refuge", "#ef2929", "alpine_hut", @@ -52,6 +54,7 @@ $poi_types = array( 'b_toilet' => "🚽 Latrines ou toilettes ?", 'l_water' => "URL du site web :" ) + , 18, "square" ), "halt" => array("Gîte d'étape", "Gîte", "#4e9a06", "halt", @@ -65,6 +68,7 @@ $poi_types = array( 'b_water' => "💧 Possibilité de se ravitailler en eau ?", 'l_water' => "URL du site web :" ) + , 16, "square" ), "bivouac" => array("Zone de bivouac", "Bivouac", "#ef2929", "bivouac", @@ -77,6 +81,7 @@ $poi_types = array( 'b_wood' => "🌲 Bois à proximité ?", 'b_fireplace' => "🔥 Emplacement pour faire un feu ?" ) + , 18, "triangle" ), "campsite" => array("Camping", "Camping", "#4e9a06", "campsite", @@ -89,6 +94,7 @@ $poi_types = array( 'b_water' => "💧 Possibilité de se ravitailler en eau ?", 'l_water' => "URL du site web :" ) + , 18, "triangle" ) );