Refactor everything to use GisState (WIP)
This commit is contained in:
@@ -1,21 +1,23 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
import { Controller } from "@hotwired/stimulus";
|
||||
import { GisState } from "../state.js";
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ['sites', 'findings', 'notconserved', 'prehist',];
|
||||
|
||||
/**
|
||||
* @todo Use Stimulus values?
|
||||
* @param {Event} event
|
||||
*/
|
||||
toggle(event) {
|
||||
let map = window.LMap;
|
||||
let map = GisState.map;
|
||||
let target = event.currentTarget;
|
||||
const id = target.parentElement.getAttribute('data-id');
|
||||
const layers = {
|
||||
'siti': window.Sites,
|
||||
'non-conser': window.NotConserved,
|
||||
'rinv': window.Findings,
|
||||
'preist': window.Prehistoric,
|
||||
'subacquei': window.Underwater,
|
||||
'siti': GisState.layers.sites,
|
||||
'non-conser': GisState.layers.notConserved,
|
||||
'rinv': GisState.layers.findings,
|
||||
'preist': GisState.layers.prehistoric,
|
||||
'subacquei': GisState.layers.underwater,
|
||||
}
|
||||
|
||||
let group = layers[id];
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
import { Controller } from "@hotwired/stimulus";
|
||||
import { GisState, getMarkerByCoords } from "../state.js";
|
||||
|
||||
export default class extends Controller {
|
||||
static values = {'coords': String };
|
||||
static values = {
|
||||
'coords': String,
|
||||
'group': String,
|
||||
'id': String,
|
||||
};
|
||||
|
||||
END_ZOOM = 19;
|
||||
// Animation breaks automatic tooltip opening...
|
||||
mapAnimate = {
|
||||
animate: true,
|
||||
duration: 1,
|
||||
@@ -14,19 +20,18 @@ export default class extends Controller {
|
||||
* @param {Event} event
|
||||
*/
|
||||
go() {
|
||||
let map = window.LMap;
|
||||
|
||||
console.log(this.coordsValue);
|
||||
|
||||
let map = GisState.map;
|
||||
const coords = this.coordsValue.split(' ');
|
||||
|
||||
map.setView(
|
||||
coords,
|
||||
this.END_ZOOM,
|
||||
this.mapAnimate
|
||||
{animate: false}
|
||||
);
|
||||
|
||||
let marker = this.getMarker(map, coords);
|
||||
// DEBUG for sites
|
||||
if (this.groupValue) marker = getMarkerByCoords(coords, this.groupValue);
|
||||
marker?.openTooltip();
|
||||
}
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user