Files
Mickael e9870f72f2 chore (refactoring): revamp map to plugin mechanism (#805)
* chore (refactoring): revamp map to plugin mechanism

* chore (docker): Dockerfile
2025-01-14 15:01:17 +11:00

20 lines
627 B
JavaScript

import { PLUGINS, DEFAULT_TILE_SERVER } from "./constant.js";
export default async function(IMap) {
const plugins = await Promise.all(PLUGINS.map((name) => import(`./plugins/${name}.js`)));
return class MapImpl extends IMap {
constructor(response, { map, $page }) {
super();
this.response = JSON.parse(new TextDecoder().decode(response));
window.L.tileLayer(DEFAULT_TILE_SERVER, { maxZoom: 21 }).addTo(map);
plugins.forEach((plugin) => plugin.default({ map, $page }));
}
async toGeoJSON() {
return this.response;
}
}
}