Add underwater sites

This commit is contained in:
2025-04-29 11:59:39 +02:00
parent 46a4efe760
commit 962ba93355
8 changed files with 142 additions and 0 deletions

View File

@@ -120,6 +120,7 @@ GIS.initMap = async function (mapId, zoomLevel = this.INIT_ZOOM) {
this.notConserved().then(group => {group.addTo(map); window.NotConserved = group});
this.findings().then(group => {group.addTo(map); window.Findings = group});
this.prehistoric().then(group => {group.addTo(map); window.Prehistoric = group});
this.underwater().then(group => {group.addTo(map); window.Underwater = group});
const archeo = {
'Vincoli archeologici' : layerVincoli,
@@ -237,6 +238,30 @@ GIS.prehistoric = async function () {
return prehistoric;
}
/**
* Create underwater sites group
* @returns {L.MarkerClusterGroup}
*/
GIS.underwater = async function () {
let underwaterData = await fetch(`${API_URL}/underwater`)
.then(data => data.json());
let underwater = L.markerClusterGroup(clusterOptions);
for (let record of underwaterData.records) {
underwater.addLayer(L.marker(
record.coordinates,
{icon: Icons.underwater}
).bindTooltip(record.denomination)
.on(
'click',
() => UI.openUnderwaterModal(record, '#underwater-data')
)
);
}
return underwater;
}
/**
* Adds layers to map and returns an object
* with {baseMap, archeoLayers, sitesLayerGroup}