From c6df2464af77d462fad7c5b1d0a5fb9c924987dd Mon Sep 17 00:00:00 2001 From: don philipe Date: Sun, 4 Aug 2024 21:03:07 +0200 Subject: [PATCH] Show raw features json in popup --- src/main/webapp/lib.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/webapp/lib.js b/src/main/webapp/lib.js index 76ff08e..c314bf1 100644 --- a/src/main/webapp/lib.js +++ b/src/main/webapp/lib.js @@ -47,9 +47,21 @@ const lib = new function () { const contextmenu = new maplibregl.Popup() .setLngLat(coordinates) - .setHTML('

') + .setHTML('


') .addTo(map); + let featbtn = document.getElementById("btn-feat"); + featbtn.onclick = function () { + contextmenu.remove(); + const features = map.queryRenderedFeatures(e.point); + const prop = features.map(function (feat) { + return feat["properties"]; + }); + const featPopup = new maplibregl.Popup() + .setLngLat(coordinates) + .setHTML(JSON.stringify(prop)) + .addTo(map); + }; let startbtn = document.getElementById("btn-start"); startbtn.onclick = function () { contextmenu.remove();