Open modal for internal links (WIP)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Controller } from "@hotwired/stimulus";
|
||||
import { GisState, getMarkerByCoords } from "../state.js";
|
||||
import UI from "../ui.js";
|
||||
|
||||
export default class extends Controller {
|
||||
static values = {
|
||||
@@ -7,6 +8,11 @@ export default class extends Controller {
|
||||
'group': String,
|
||||
'id': String,
|
||||
};
|
||||
|
||||
uiModals = {
|
||||
sites: '#site-data',
|
||||
notConserved: '#not-conserved-data',
|
||||
};
|
||||
|
||||
END_ZOOM = 19;
|
||||
// Animation breaks automatic tooltip opening...
|
||||
@@ -16,9 +22,6 @@ export default class extends Controller {
|
||||
easeLinearity: 0.25
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Event} event
|
||||
*/
|
||||
go() {
|
||||
let map = GisState.map;
|
||||
const coords = this.coordsValue.split(' ');
|
||||
@@ -31,8 +34,31 @@ export default class extends Controller {
|
||||
|
||||
let marker = this.getMarker(map, coords);
|
||||
// DEBUG for sites
|
||||
if (this.groupValue) marker = getMarkerByCoords(coords, this.groupValue);
|
||||
//if (this.groupValue) marker = getMarkerByCoords(coords, this.groupValue);
|
||||
marker?.openTooltip();
|
||||
|
||||
return marker;
|
||||
}
|
||||
/**
|
||||
* Go to a marker location on the map
|
||||
* and open its modal
|
||||
*/
|
||||
goAndOpen() {
|
||||
const marker = this.go();
|
||||
const selector = this.uiModals[this.groupValue];
|
||||
const data = marker.options.data;
|
||||
|
||||
switch(this.groupValue) {
|
||||
case 'sites':
|
||||
UI.openSiteModal(data, selector);
|
||||
break;
|
||||
case 'notConserved':
|
||||
UI.openNotConserModal(data, selector);
|
||||
break;
|
||||
default:
|
||||
console.log('Cannot open modal...');
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param {L.Map} map
|
||||
|
||||
Reference in New Issue
Block a user