LoRaWAN-Signal-Mapping/client_src/js/MapManager.mjs

55 lines
1.3 KiB
JavaScript
Raw Normal View History

"use strict";
import Config from './ClientConfig.mjs';
2019-07-22 14:46:07 +00:00
import L from 'leaflet';
import LayerGateways from './LayerGateways.mjs';
import LayerAI from './LayerAI.mjs';
class MapManager {
constructor() {
}
async setup() {
2019-07-22 14:46:07 +00:00
this.map = L.map("map", {
fullscreenControl: true
});
this.map.setView(Config.default_location, Config.default_zoom);
// Add the OpenStreetMap tile layer
this.layer_openstreet = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
id: "openstreetmap",
maxZoom: 19,
attribution: "&copy; <a href='https://www.openstreetmap.org/copyright'>OpenStreetMap contributors</a>"
}).addTo(this.map);
// Add the gateway markers layer
this.layer_gateways = new LayerGateways(this.map);
await this.layer_gateways.setup();
// Add the AI coverage prediction layer
this.layer_ai = new LayerAI(this.map);
await this.layer_ai.setup();
this.setup_layer_control();
}
setup_layer_control() {
this.layer_control = L.control.layers({
// Base layer(s)
"OpenStreetMap": this.layer_openstreet
}, { // Overlay(s)
"Gateways": this.layer_gateways.layer,
// FUTURE: Have 1 heatmap layer per reading type?
"Heatmap": this.layer_ai.layer
}, { // Options
});
this.layer_control.addTo(this.map);
}
}
export default MapManager;