54 lines
1.7 KiB
JavaScript
54 lines
1.7 KiB
JavaScript
// all function related to the map
|
|
|
|
import * as dt from './datetime.js'
|
|
import * as utils from "./chart_utilities.js"
|
|
import { showChart, loadAll } from './showcharts.js'
|
|
import * as mapn from './map_noise.js'
|
|
import * as mapg from './map_geiger.js'
|
|
import * as mapu from './map_utilities.js'
|
|
|
|
const mapparams = {
|
|
map: null,
|
|
bounds: null,
|
|
popuptext: '',
|
|
clickedSensor: 0,
|
|
APIURL: '/api/getmapdata?',
|
|
MAXZOOM: 19
|
|
}
|
|
|
|
export async function showMap(params) {
|
|
if(sysparams.category === 'laerm') {
|
|
utils.removeTabs()
|
|
if(mapparams.map && mapparams.map.remove) {
|
|
mapparams.map.off();
|
|
mapparams.map.remove();
|
|
}
|
|
}
|
|
mapparams.map = L.map('map', {scrollWheelZoom: false}).setView(params.center, parseInt(params.zoom))
|
|
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
maxZoom: mapparams.MAXZOOM,
|
|
attribution: '© <a href="http://www.js.openstreetmap.org/copyright">OpenStreetMap</a>'
|
|
}).addTo(mapparams.map)
|
|
mapparams.bounds = mapparams.map.getBounds();
|
|
|
|
mapparams.map.on('moveend', async function () {
|
|
mapparams.bounds = mapparams.map.getBounds()
|
|
await buildMarkers(params, mapparams)
|
|
});
|
|
|
|
if(sysparams.category === 'laerm') {
|
|
mapn.buildLegend(mapparams)
|
|
}
|
|
|
|
let lastdate = await buildMarkers(params, mapparams)
|
|
mapu.showLastDate(lastdate, mapparams);
|
|
}
|
|
|
|
const buildMarkers = async (params, mapparams) => {
|
|
if(sysparams.category === 'laerm') {
|
|
return mapn.buildMarkers(params, mapparams)
|
|
} else if(sysparams.category === 'multigeiger') {
|
|
return mapg.buildMarkers(params, mapparams)
|
|
}
|
|
}
|