37 lines
741 B
JavaScript
37 lines
741 B
JavaScript
"use strict";
|
|
|
|
import L from 'leaflet';
|
|
|
|
import Config from './ClientConfig.mjs';
|
|
import GetFromUrl from './Helpers/GetFromUrl.mjs';
|
|
|
|
class LayerGateways {
|
|
constructor(map) {
|
|
this.map = map;
|
|
this.layer = L.layerGroup();
|
|
}
|
|
|
|
async setup() {
|
|
// TODO: Cache this in MapManager?
|
|
let gateways = JSON.parse(
|
|
await GetFromUrl(Config.ai_index_file)
|
|
);
|
|
|
|
// Generate markers for each of the gateways
|
|
for(let gateway of gateways.index) {
|
|
this.layer.addLayer(L.marker(
|
|
L.latLng(gateway.latitude, gateway.longitude),
|
|
{
|
|
title: gateway.id,
|
|
autoPan: true,
|
|
autoPanPadding: L.point(100, 100)
|
|
}
|
|
));
|
|
}
|
|
|
|
// Add the layer to the map
|
|
this.map.addLayer(this.layer);
|
|
}
|
|
}
|
|
|
|
export default LayerGateways;
|