Air-Quality-Web/client_src/js/LayerHeatmap.mjs

36 lines
712 B
JavaScript
Raw Normal View History

"use strict";
import HeatmapOverlay from 'leaflet-heatmap';
import Config from './Config.mjs';
class LayerHeatmap {
constructor(in_map) {
this.map = in_map;
2019-01-18 21:25:30 +00:00
this.overlay_config = {
radius: Config.heatmap.blob_radius,
maxOpacity: 0.8,
scaleRadius: true,
useLocalExtrema: false,
latField: "latitude",
lngField: "longitude",
valueField: "value"
2019-01-18 21:25:30 +00:00
};
this.layer = new HeatmapOverlay(this.overlay_config);
this.map.addLayer(this.layer);
}
set_data(readings_list) {
let data_object = {
max: readings_list.reduce((prev, next) => next.value > prev ? next.value : prev, 0),
data: readings_list
}
this.layer.setData(data_object);
}
}
export default LayerHeatmap;