Compare commits

..

No commits in common. "f7ecd4326a91612b478d257ec1cc0a7dfe181b82" and "a783e6d889c2f6d6df7c89676d6183510f072f50" have entirely different histories.

6 changed files with 27 additions and 32 deletions

File diff suppressed because one or more lines are too long

View File

@ -63,6 +63,7 @@
<div class="modal"> <div class="modal">
<div class="modal-background"></div> <div class="modal-background"></div>
<div class="modal-content has-background-white"> <div class="modal-content has-background-white">
<!-- Any other Bulma elements you want -->
</div> </div>
<button class="modal-close is-large" aria-label="close"></button> <button class="modal-close is-large" aria-label="close"></button>
</div> </div>

View File

@ -105,16 +105,13 @@ GIS.initMap = async function (mapId, zoomLevel = this.INIT_ZOOM) {
data = await GIS._fetchData(layer.id); data = await GIS._fetchData(layer.id);
} }
// TODO: terrible! const marker = L.marker(coords)
if (!layer.id.includes('area')) { .addTo(map)
const marker = L.marker(coords) .bindTooltip(Object.keys(archeo).find(k => archeo[k] === layer))
.addTo(map) .openTooltip();
.bindTooltip(Object.keys(archeo).find(k => archeo[k] === layer))
.openTooltip(); if (typeof data === 'object') {
marker.on('click', () => UI.openModal(data));
if (typeof data === 'object') {
marker.on('click', () => UI.openModal(data));
}
} }
}); });
@ -131,14 +128,11 @@ GIS.initMap = async function (mapId, zoomLevel = this.INIT_ZOOM) {
GIS.initLayers = async function(map) { GIS.initLayers = async function(map) {
let layerMater = await this.loadLayer('matermania.geojson', optionsSiti, false); let layerMater = await this.loadLayer('matermania.geojson', optionsSiti, false);
let layerArsenale = await this.loadLayer('arsenale.geojson', optionsSiti, false); let layerArsenale = await this.loadLayer('arsenale.geojson', optionsSiti, false);
let layerArsenaleArea = await this.loadLayer('arsenale_area.geojson', optionsSiti, false);
let layerGradola = await this.loadLayer('gradola.geojson', optionsSiti, false); let layerGradola = await this.loadLayer('gradola.geojson', optionsSiti, false);
layerMater.id = 'matermania'; layerMater.id = 'matermania';
layerGradola.id = 'gradola'; layerGradola.id = 'gradola';
layerArsenale.id = 'arsenale'; layerArsenale.id = 'arsenale';
layerArsenaleArea.id = 'arsenale_area';
let layerVincoli = await this.loadLayer('vincoli.geojson', optionsVincoli); let layerVincoli = await this.loadLayer('vincoli.geojson', optionsVincoli);
// TODO named parameters?? // TODO named parameters??
let layerPaesistici = await this.loadLayer('paesistici.geojson', optionsPaesistici); let layerPaesistici = await this.loadLayer('paesistici.geojson', optionsPaesistici);
@ -148,7 +142,7 @@ GIS.initLayers = async function(map) {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}); });
const sitesGroup = new L.LayerGroup([layerMater, layerGradola, layerArsenale, layerArsenaleArea]); const sitesGroup = new L.LayerGroup([layerMater, layerGradola, layerArsenale]);
const baseGroup = new L.LayerGroup([osmap]); const baseGroup = new L.LayerGroup([osmap]);
baseGroup.addTo(map); baseGroup.addTo(map);
sitesGroup.addTo(map); sitesGroup.addTo(map);
@ -158,8 +152,7 @@ GIS.initLayers = async function(map) {
const archeo = { const archeo = {
"Villa di Gradola" : layerGradola, "Villa di Gradola" : layerGradola,
"Grotta di Matermania" : layerMater, "Grotta di Matermania" : layerMater,
"Grotta dell'Arsenale (planimetria)" : layerArsenale, "Grotta dell'Arsenale" : layerArsenale,
"Grotta dell'Arsenale (area)" : layerArsenaleArea,
"Vincoli archeologici" : layerVincoli, "Vincoli archeologici" : layerVincoli,
"Vincoli paesistici" : layerPaesistici, "Vincoli paesistici" : layerPaesistici,
}; };

View File

@ -1,4 +1,4 @@
import GIS from './gis.js'; import GIS from './caprigis.js';
import UI from './ui.js'; import UI from './ui.js';
document.addEventListener('DOMContentLoaded', async () => { document.addEventListener('DOMContentLoaded', async () => {
@ -8,4 +8,14 @@ document.addEventListener('DOMContentLoaded', async () => {
UI.addCenterMapControl(map, GIS.CENTER_COORDS, GIS.INIT_ZOOM); UI.addCenterMapControl(map, GIS.CENTER_COORDS, GIS.INIT_ZOOM);
UI.toggleMenu('siti'); UI.toggleMenu('siti');
UI.sitesMenu('.menu-list', map, sites); UI.sitesMenu('.menu-list', map, sites);
});
/*
for (let site of Object.keys(sites)) {
if (!site.includes('Vincoli')) {
let layer = sites[site];
const centerCoords = layer.getBounds().getCenter();
UI.addSitesControl(map, centerCoords, site, GIS.INIT_ZOOM);
}
}
*/
});

View File

@ -1,6 +1,6 @@
{ {
"source": { "source": {
"include": ["gis.js", "ui.js", "index.js"], "include": ["caprigis.js", "index.js"],
"includePattern": ".js$", "includePattern": ".js$",
"excludePattern": "(vendor/|docs)" "excludePattern": "(vendor/|docs)"
}, },

View File

@ -6,9 +6,9 @@
const UI = {}; const UI = {};
/** /**
* Add a Leaflet control to center the map * Add a control to center the map
* @param {Map} map The Leaflet map object * @param {Map} map
* @param {LatLngExpression} centerCoords The coordinates to center the map * @param {LatLngExpression} centerCoords
* @param {number} zoom Zoom level * @param {number} zoom Zoom level
*/ */
UI.addCenterMapControl = function (map, centerCoords, zoom) { UI.addCenterMapControl = function (map, centerCoords, zoom) {
@ -51,7 +51,7 @@ UI.toggleMenu = function (triggerId) {
menu.classList.toggle('is-hidden'); menu.classList.toggle('is-hidden');
menu.classList.toggle('is-2'); menu.classList.toggle('is-2');
document.querySelector('#map').parentElement.classList.toggle('is-full'); document.querySelector('#map').parentElement.classList.toggle('is-full');
}); })
} }
/** /**
* Open a modal with DB data * Open a modal with DB data