2019-01-17 17:31:59 +00:00
|
|
|
"use strict";
|
|
|
|
|
2019-01-18 20:12:30 +00:00
|
|
|
import HeatmapOverlay from 'leaflet-heatmap';
|
2019-01-17 17:31:59 +00:00
|
|
|
|
|
|
|
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 = {
|
2019-01-18 20:12:30 +00:00
|
|
|
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);
|
2019-01-17 17:31:59 +00:00
|
|
|
this.map.addLayer(this.layer);
|
|
|
|
}
|
|
|
|
|
|
|
|
set_data(readings_list) {
|
2019-01-18 20:12:30 +00:00
|
|
|
let data_object = {
|
|
|
|
max: readings_list.reduce((prev, next) => next.value > prev ? next.value : prev, 0),
|
|
|
|
data: readings_list
|
|
|
|
}
|
|
|
|
this.layer.setData(data_object);
|
2019-01-17 17:31:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default LayerHeatmap;
|