// Constants ##################################################################################### // ############################################################################################### let customPopupOpts = { maxWidth: "1000", minWidth: "500", minHeight: "500", className: "custom-popup", }; let markerClusterOpts = { spiderfyOnMaxZoom: false, showCoverageOnHover: true, zoomToBoundsOnClick: true, removeOutsideVisibleBounds: true, disableClusteringAtZoom: 18, }; // Functions ##################################################################################### // ############################################################################################### /** * Switch LatLon coords in an array. * @param Array * @return Array */ function switchLatLon(inp) { return [inp[1], inp[0]]; } /** * * @param response * @returns json */ function getResponse(response) { return response.json(); } /** * @param STA Location object * @returns Leaflet Marker */ async function markerFromLocation(l) { // { // "description": "Centroid of intersection 0012 (Richard-Wagner-Str. / Max-Schott-Str.)", // "encodingType": "application/vnd.geo+json", // "@iot.id": 839, // "location": { // "type": "Point", // "coordinates": [ // 11.4123187, // 48.7754826 // ] // }, // "name": "0012", // "@iot.selfLink": "https://sta-savenow.westeurope.azurecontainer.io/frost/v1.1/Locations(839)" // } console.log(l.location.type); if (l.location.type == "Point") { return L.marker(switchLatLon(l.location.coordinates)); } } /** * Async function to query two datasets using fetch * @param {*} Query a * @param {*} Query b * @returns [Object, Object] */ async function fetchSTA(a, b, c) { const [latestObs, things, fois] = await Promise.all([ fetch(a, { headers: headers }), fetch(b, { headers: headers }), fetch(c, { headers: headers }), ]); const l = await latestObs.json(); const t = await things.json(); const f = await fois.json(); return [l, t, f]; }