Refactor everything to use GisState (WIP)
This commit is contained in:
59
webgis/js/state.js
Normal file
59
webgis/js/state.js
Normal file
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @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.<string, Object>} BibliographyLookup
|
||||
* A lookup table of bibliography data by category
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} GisStateType
|
||||
* @property {L.Map|null} map
|
||||
* @property {String|null} apiUrl
|
||||
* @property {MarkerLookup} markers
|
||||
* @property {LayerGroupLookup} layers
|
||||
* @property {BibliographyLookup} bibliography
|
||||
*/
|
||||
|
||||
/** @type {GisStateType} */
|
||||
export const GisState = {
|
||||
map: null,
|
||||
markers: {
|
||||
sites: {},
|
||||
notConserved: {},
|
||||
findings: {},
|
||||
prehistoric: {},
|
||||
underwater: {},
|
||||
},
|
||||
layers: {
|
||||
sites: {},
|
||||
notConserved: {},
|
||||
findings: {},
|
||||
prehistoric: {},
|
||||
underwater: {},
|
||||
},
|
||||
bibliography: {
|
||||
sites: {},
|
||||
notConserved: {},
|
||||
findings: {},
|
||||
prehistoric: {},
|
||||
underwater: {},
|
||||
},
|
||||
apiUrl : null,
|
||||
}
|
||||
|
||||
/**
|
||||
* @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]}`];
|
||||
}
|
||||
Reference in New Issue
Block a user