Add Reuse asset type

This commit is contained in:
2025-08-08 12:06:38 +02:00
parent 9196653c0d
commit f849f885f9
9 changed files with 250 additions and 1 deletions

View File

@@ -158,6 +158,7 @@ GIS.addLayerGroups = async function (map) {
this.findings(),
this.prehistoric(),
this.underwater(),
this.reuse(),
]
);
groups.forEach(group => group.addTo(map));
@@ -322,7 +323,7 @@ GIS.underwater = async function () {
);
const markerLabel = `${record.coordinates[0]} ${record.coordinates[1]}`;
GisState.markers.prehistoric[markerLabel] = marker;
GisState.markers.underwater[markerLabel] = marker;
underwater.addLayer(marker);
}
@@ -331,6 +332,38 @@ GIS.underwater = async function () {
return underwater;
}
/**
* Create reused sites group ('reimpiego')
* @returns {L.MarkerClusterGroup}
*/
GIS.reuse = async function () {
let reuseData = await fetch(`${API_URL}/reuse`)
.then(data => data.json());
let reuse = L.markerClusterGroup(Options.cluster);
for (let record of reuseData.records) {
const marker = L.marker(
record.coordinates,
{icon: Icons.reuse}
).bindTooltip(record.label)
.on(
'click',
() => UI.openReuseModal(record, '#reuse-data')
);
const markerLabel = `${record.coordinates[0]} ${record.coordinates[1]}`;
marker.options.municipality = record.municipality;
marker.options.label = record.label;
GisState.markers.reuse[markerLabel] = marker;
reuse.addLayer(marker);
}
GisState.layers.reuse = reuse;
return reuse;
}
/**
* Adds layers to map and returns an object
* with {baseMap, archeoLayers, sitesLayerGroup}