From c4e5c463c46bacdc6a37cfb9f810e47ee8891091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P?= Date: Wed, 12 Jun 2024 18:20:16 +0200 Subject: [PATCH] Add markers + DB fields --- js/caprigis.js | 11 ++++++++++- js/ui.js | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/js/caprigis.js b/js/caprigis.js index ae28b08..8722b81 100644 --- a/js/caprigis.js +++ b/js/caprigis.js @@ -87,6 +87,15 @@ GIS.initMap = async function (mapId, zoomLevel = this.INIT_ZOOM) { ) .addTo(map); + sitesGroup.eachLayer(layer => { + const marker = L.marker(layer.getBounds().getCenter()) + .addTo(map); + marker.on('click', async () => { + const data = await GIS._fetchData(layer.id); + UI.openModal(data); + }); + }); + // TODO Horrible? return {map: map, sites: sitesGroup}; } @@ -144,7 +153,7 @@ GIS.loadLayer = async function (geoJSON, options, popup = true) { // Show data from feature in popUp? const layer = new L.geoJson(data, { - style: function (feature) { + style: function () { let style = options; return style; }, diff --git a/js/ui.js b/js/ui.js index 17dbfd3..4729cd1 100644 --- a/js/ui.js +++ b/js/ui.js @@ -76,6 +76,8 @@ UI.openModal = async function (data) { Materiali rinvenuti${data.materiali_rinv} Luogo custodia materiali${data.luogo_custodia_mat} Tutela vigente${data.tutela_vigente} + Stato di conservazione${data.stato_conserv} + Documenti${data.documenti} Descrizione${data.descrizione} `;