caprigis/webgis/js/state.js

53 lines
1.1 KiB
JavaScript

/**
* @typedef {Object.<string, L.Marker>} MarkerLookup
* A lookup table of markers keyed by 'lat lng' (no groupings)
*/
/**
* @typedef {Object.<string, L.LayerGroup>} LayerGroupLookup
* A lookup table of Leaflet layer groups by category
*/
/**
* @typedef {Object} GisStateType
* @property {L.Map|null} map
* @property {MarkerLookup} markers
* @property {LayerGroupLookup} layers
* @property {Object|null} bibliography
* @property {String|null} apiUrl
* @property {Object} cartography
*/
/** @type {GisStateType} */
export const GisState = {
map: null,
markers: {
sites: {},
notConserved: {},
findings: {},
prehistoric: {},
underwater: {},
},
layers: {
sites: {},
notConserved: {},
findings: {},
prehistoric: {},
underwater: {},
},
bibliography: null,
apiUrl : null,
cartography : {
historic: [],
}
}
/**
* @param {array} coords - ['lat', 'lng']
* @param {string} group
* @returns {L.Marker|undefined}
*/
export function getMarkerByCoords(coords, group) {
return GisState.markers[group][`${coords[0]} ${coords[1]}`];
}