Findings (WIP) + change some UI behaviour
This commit is contained in:
@@ -129,11 +129,13 @@ GIS.initMap = async function (mapId, zoomLevel = this.INIT_ZOOM) {
|
||||
|
||||
let markersGroup = await this.sitesMarkers(sitesGroup);
|
||||
let notConservedGroup = await this.notConserved();
|
||||
let findingsGroup = await this.findings();
|
||||
|
||||
const archeo = {
|
||||
'Beni archeologici (punti)' : markersGroup,
|
||||
'Beni archeologici (strutture)' : sitesGroup,
|
||||
'Beni non conservati' : notConservedGroup,
|
||||
'Rinvenimenti' : findingsGroup,
|
||||
'Vincoli archeologici' : layerVincoli,
|
||||
'Vincoli paesistici' : layerPaesistici,
|
||||
};
|
||||
@@ -141,6 +143,7 @@ GIS.initMap = async function (mapId, zoomLevel = this.INIT_ZOOM) {
|
||||
markersGroup.addTo(map);
|
||||
sitesGroup.addTo(map);
|
||||
notConservedGroup.addTo(map);
|
||||
findingsGroup.addTo(map);
|
||||
|
||||
L.control.layers(
|
||||
baseMap,
|
||||
@@ -178,8 +181,9 @@ GIS.sitesMarkers = async function (sitesGroup) {
|
||||
}
|
||||
|
||||
const marker = L.marker(coords, { icon: Icons.site })
|
||||
.bindTooltip(MARKER_NAMES.sites[id])
|
||||
.openTooltip();
|
||||
.bindTooltip(MARKER_NAMES.sites[id] + '<br>(Clicca per aprire scheda)');
|
||||
|
||||
marker.id = id;
|
||||
|
||||
marker.on('click', () => UI.openSiteModal(data, '#site-data'));
|
||||
|
||||
@@ -212,6 +216,30 @@ GIS.notConserved = async function () {
|
||||
|
||||
return L.layerGroup(notConserved);
|
||||
}
|
||||
/**
|
||||
* Create findings group
|
||||
* @returns {L.LayerGroup}
|
||||
*/
|
||||
GIS.findings = async function () {
|
||||
let findingsData = await fetch(`${API_URL}/finding`)
|
||||
.then(data => data.json());
|
||||
|
||||
let findings = [];
|
||||
|
||||
for (let record of findingsData) {
|
||||
findings.push(L.marker(
|
||||
record.coordinates,
|
||||
{icon: Icons.finding}
|
||||
).bindTooltip(record.object)
|
||||
.on(
|
||||
'click',
|
||||
() => UI.openFindingModal(record, '#finding-data')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return L.layerGroup(findings);
|
||||
}
|
||||
/*
|
||||
GIS._prepareLayers = async function(layer) {
|
||||
const fromStorage = localStorage.getItem(layer.id);
|
||||
@@ -254,6 +282,7 @@ GIS._prepareLayers = async function(layer) {
|
||||
* @returns {{baseMap: {"OpenStreetMap": L.TileLayer}, archeo: object, sitesGroup: L.LayerGroup}}
|
||||
*/
|
||||
GIS.initLayers = async function(map) {
|
||||
// TODO Move all this to separate array / object!
|
||||
let layerMater = await this.loadLayer('matermania.geojson', optionsSiti, false);
|
||||
let layerMaterArea = await this.loadLayer('matermania_area.geojson', optionsSiti, false);
|
||||
let layerArsenale = await this.loadLayer('arsenale.geojson', optionsSiti, false);
|
||||
|
||||
Reference in New Issue
Block a user