Marker clusters (draft)

This commit is contained in:
2024-11-29 11:41:05 +01:00
parent 381c3bfe69
commit e865ada571
9 changed files with 27 additions and 16 deletions

View File

@@ -160,10 +160,10 @@ GIS.initMap = async function (mapId, zoomLevel = this.INIT_ZOOM) {
/**
* Create markers for sites
* @param {L.LayerGroup} sitesGroup
* @returns {L.LayerGroup}
* @returns {L.markerClusterGroup}
*/
GIS.sitesMarkers = async function (sitesGroup) {
let sitesMarkers = [];
let sitesMarkers = L.markerClusterGroup();
for (let id in MARKER_NAMES.sites) {
let layer = sitesGroup.customGetLayer(id);
@@ -191,23 +191,23 @@ GIS.sitesMarkers = async function (sitesGroup) {
marker.on('click', () => UI.openSiteModal(data, '#site-data'));
sitesMarkers.push(marker);
sitesMarkers.addLayer(marker);
}
return L.layerGroup(sitesMarkers);
return sitesMarkers;
}
/**
* Create not conserved group
* @returns {L.LayerGroup}
* @returns {L.MarkerClusterGroup}
*/
GIS.notConserved = async function () {
let notConserData = await fetch(`${API_URL}/not_conserved`)
.then(data => data.json());
let notConserved = [];
let notConserved = L.markerClusterGroup();
for (let record of notConserData.records) {
notConserved.push(L.marker(
notConserved.addLayer(L.marker(
record.coordinates,
{icon: Icons.notConserved}
).bindTooltip(record.denomination)
@@ -218,20 +218,20 @@ GIS.notConserved = async function () {
);
}
return L.layerGroup(notConserved);
return notConserved;
}
/**
* Create findings group
* @returns {L.LayerGroup}
* @returns {L.MarkerClusterGroup}
*/
GIS.findings = async function () {
let findingsData = await fetch(`${API_URL}/finding`)
.then(data => data.json());
let findings = [];
let findings = L.markerClusterGroup();
for (let record of findingsData) {
findings.push(L.marker(
findings.addLayer(L.marker(
record.coordinates,
{icon: Icons.finding}
).bindTooltip(record.object)
@@ -242,7 +242,7 @@ GIS.findings = async function () {
);
}
return L.layerGroup(findings);
return findings;
}
/*
GIS._prepareLayers = async function(layer) {