Zoom levels for clusters

This commit is contained in:
Nicolò P 2024-11-29 17:30:07 +01:00
parent 4ea00e9555
commit 1a0c5c1766
5 changed files with 35 additions and 15 deletions

View File

@ -120,9 +120,13 @@ a:visited {
.modal { .modal {
z-index: 1000; z-index: 1000;
} }
.modal-content { .modal-content,
.modal-card {
width: 60vw; width: 60vw;
} }
.modal-card {
min-height: 95vh;
}
.has-bottom-border { .has-bottom-border {
border-bottom: 1px #aaa solid; border-bottom: 1px #aaa solid;
} }

View File

@ -2,7 +2,7 @@ import { Controller } from "@hotwired/stimulus"
export default class extends Controller { export default class extends Controller {
static targets = ['coords']; static targets = ['coords'];
END_ZOOM = 20; END_ZOOM = 19;
mapAnimate = { mapAnimate = {
animate: true, animate: true,
duration: 1, duration: 1,

View File

@ -3,6 +3,24 @@ import { Controller } from "@hotwired/stimulus"
export default class extends Controller { export default class extends Controller {
static targets = ['close', 'modal']; static targets = ['close', 'modal'];
current(id) {
return this.modalTargets.find(m => m.getAttribute('data-id') === id);
}
homeOpen(event) {
const id = event.currentTarget.getAttribute('data-id');
const current = this.current(id);
current.classList.add('is-active');
}
homeClose(event) {
const id = event.currentTarget.getAttribute('data-id');
const current = this.current(id);
current.classList.remove('is-active');
}
open() { open() {
this.modalTarget.classList.add('is-active'); this.modalTarget.classList.add('is-active');
} }

View File

@ -100,7 +100,7 @@ function capitalize(text) {
/** /**
* @param {string} mapId * @param {string} mapId
* @param {number} zoomLevel * @param {number} zoomLevel
* @returns {{map: Map, sites: Layer}} * @returns {Map}
*/ */
GIS.initMap = async function (mapId, zoomLevel = this.INIT_ZOOM) { GIS.initMap = async function (mapId, zoomLevel = this.INIT_ZOOM) {
L.LayerGroup.include({ L.LayerGroup.include({
@ -115,7 +115,7 @@ GIS.initMap = async function (mapId, zoomLevel = this.INIT_ZOOM) {
let map = L.map(mapId, { let map = L.map(mapId, {
//attributionControl: false, //attributionControl: false,
minZoom: 2, minZoom: 11,
}).setView(this.CENTER_COORDS, zoomLevel); }).setView(this.CENTER_COORDS, zoomLevel);
map.crs = L.CRS.EPSG4326; map.crs = L.CRS.EPSG4326;
@ -146,16 +146,12 @@ GIS.initMap = async function (mapId, zoomLevel = this.INIT_ZOOM) {
notConservedGroup.addTo(map); notConservedGroup.addTo(map);
findingsGroup.addTo(map); findingsGroup.addTo(map);
L.control.layers( L.control.layers(baseMap, archeo).addTo(map);
baseMap,
archeo,
).addTo(map);
// TEMP!! Remove point for Lo Pozzo... // TEMP!! Remove point for Lo Pozzo...
map.removeLayer(sitesGroup.customGetLayer('lopozzo')); map.removeLayer(sitesGroup.customGetLayer('lopozzo'));
// TODO Horrible? return map;
return {map: map, sites: sitesGroup};
} }
/** /**
* Create markers for sites * Create markers for sites
@ -164,7 +160,8 @@ GIS.initMap = async function (mapId, zoomLevel = this.INIT_ZOOM) {
*/ */
GIS.sitesMarkers = async function (sitesGroup) { GIS.sitesMarkers = async function (sitesGroup) {
let sitesMarkers = L.markerClusterGroup({ let sitesMarkers = L.markerClusterGroup({
showCoverageOnHover: false showCoverageOnHover: false,
disableClusteringAtZoom: 19,
}); });
for (let id in MARKER_NAMES.sites) { for (let id in MARKER_NAMES.sites) {
@ -207,7 +204,8 @@ GIS.notConserved = async function () {
.then(data => data.json()); .then(data => data.json());
let notConserved = L.markerClusterGroup({ let notConserved = L.markerClusterGroup({
showCoverageOnHover: false showCoverageOnHover: false,
disableClusteringAtZoom: 19,
}); });
for (let record of notConserData.records) { for (let record of notConserData.records) {
@ -233,7 +231,8 @@ GIS.findings = async function () {
.then(data => data.json()); .then(data => data.json());
let findings = L.markerClusterGroup({ let findings = L.markerClusterGroup({
showCoverageOnHover: false showCoverageOnHover: false,
disableClusteringAtZoom: 19,
}); });
for (let record of findingsData) { for (let record of findingsData) {

View File

@ -12,9 +12,8 @@ document.addEventListener('DOMContentLoaded', async () => {
initStimulus(); initStimulus();
let progress = document.querySelector('progress'); let progress = document.querySelector('progress');
const init = await GIS.initMap('map'); const map = await GIS.initMap('map');
progress.classList.add('is-hidden'); progress.classList.add('is-hidden');
let {map, sites} = init;
map._container.setAttribute('aria-busy', false); map._container.setAttribute('aria-busy', false);