Refactor everything to use GisState (WIP)

This commit is contained in:
2025-06-02 09:42:26 +02:00
parent 86d692381d
commit c265e4aa94
9 changed files with 207 additions and 79 deletions

View File

@@ -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();
}
/**