Start trying to add a time dimension to the heatmap, but it doesn't work yet.

This commit is contained in:
Starbeamrainbowlabs 2019-03-18 20:44:12 +00:00
parent a3647fa716
commit 61baac288a
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
4 changed files with 24 additions and 4 deletions

View File

@ -3,6 +3,8 @@
// Import leaflet, but some plugins require it to have the variable name 'L' :-/ // Import leaflet, but some plugins require it to have the variable name 'L' :-/
import L from 'leaflet'; import L from 'leaflet';
import 'leaflet-fullscreen'; import 'leaflet-fullscreen';
import 'iso8601-js-period';
import '../../node_modules/leaflet-timedimension/dist/leaflet.timedimension.src.withlog.js';
import Config from './Config.mjs'; import Config from './Config.mjs';
import LayerDeviceMarkers from './LayerDeviceMarkers.mjs'; import LayerDeviceMarkers from './LayerDeviceMarkers.mjs';
@ -17,7 +19,12 @@ class MapManager {
setup() { setup() {
// Create the map // Create the map
this.map = L.map("map", { this.map = L.map("map", {
fullscreenControl: true fullscreenControl: true,
timeDimension: true,
timeDimensionOptions: {
timeInterval: `2019-01-01/${(new Date()).toISOString().split("T")[0]}`,
period: "PT6M" // 6 minutes, in ISO 8601 Durations format: https://en.wikipedia.org/wiki/ISO_8601#Durations
}
}); });
this.map.setView(Config.default_location, Config.default_zoom); this.map.setView(Config.default_location, Config.default_zoom);
@ -28,9 +35,15 @@ class MapManager {
attribution: "&copy; <a href='https://www.openstreetmap.org/copyright'>OpenStreetMap contributors</a>" attribution: "&copy; <a href='https://www.openstreetmap.org/copyright'>OpenStreetMap contributors</a>"
}).addTo(this.map); }).addTo(this.map);
// Add the attribution
this.map.attributionControl.addAttribution("Data: <a href='https://connectedhumber.org/'>Connected Humber</a>"); this.map.attributionControl.addAttribution("Data: <a href='https://connectedhumber.org/'>Connected Humber</a>");
this.map.attributionControl.addAttribution("<a href='https://github.com/ConnectedHumber/Air-Quality-Web/'>Air Quality Web</a> by <a href='https://starbeamrainbowlabs.com/'>Starbeamrainbowlabs</a>"); this.map.attributionControl.addAttribution("<a href='https://github.com/ConnectedHumber/Air-Quality-Web/'>Air Quality Web</a> by <a href='https://starbeamrainbowlabs.com/'>Starbeamrainbowlabs</a>");
// Add the time dimension
this.layer_time = L.timeDimension()
.addTo(this.map);
this.layer_time.on("timeloading", console.log);
// Add the device markers // Add the device markers
console.info("[map] Loading device markers...."); console.info("[map] Loading device markers....");
this.setup_device_markers().then(() => { this.setup_device_markers().then(() => {

View File

@ -1,6 +1,7 @@
"use strict"; "use strict";
import '../css/main.css'; import '../css/main.css';
import '../../node_modules/leaflet-timedimension/dist/leaflet.timedimension.control.css';
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

11
package-lock.json generated
View File

@ -1641,9 +1641,9 @@
"dev": true "dev": true
}, },
"iso8601-js-period": { "iso8601-js-period": {
"version": "0.2.0", "version": "0.2.1",
"resolved": "https://registry.npmjs.org/iso8601-js-period/-/iso8601-js-period-0.2.0.tgz", "resolved": "https://registry.npmjs.org/iso8601-js-period/-/iso8601-js-period-0.2.1.tgz",
"integrity": "sha1-5XQP1OcguWCoXraF/CBSAWIcAYw=" "integrity": "sha512-iDyz2TQFBd5WhCZjruOwHj01JkQGu7YbVLCVdpA7lCGEcBzE3ffCPAhLh/M8TAp//kCixPpYN4XU54WHCxvD2Q=="
}, },
"isobject": { "isobject": {
"version": "3.0.1", "version": "3.0.1",
@ -1745,6 +1745,11 @@
"leaflet": "~0.7.4 || ~1.0.0" "leaflet": "~0.7.4 || ~1.0.0"
}, },
"dependencies": { "dependencies": {
"iso8601-js-period": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/iso8601-js-period/-/iso8601-js-period-0.2.0.tgz",
"integrity": "sha1-5XQP1OcguWCoXraF/CBSAWIcAYw="
},
"leaflet": { "leaflet": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.0.3.tgz", "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.0.3.tgz",

View File

@ -19,6 +19,7 @@
"dependencies": { "dependencies": {
"chart.js": "^2.7.3", "chart.js": "^2.7.3",
"dom-create-element-query-selector": "github:hekigan/dom-create-element-query-selector", "dom-create-element-query-selector": "github:hekigan/dom-create-element-query-selector",
"iso8601-js-period": "^0.2.1",
"leaflet": "^1.4.0", "leaflet": "^1.4.0",
"leaflet-fullscreen": "^1.0.2", "leaflet-fullscreen": "^1.0.2",
"leaflet-timedimension": "^1.1.0", "leaflet-timedimension": "^1.1.0",