Customisable map styling
[gpl/argeo-suite.git] / org.argeo.app.geo.js / src / org.argeo.app.geo.js / MapPart.js
index ef19f58143143de9cf0ea5d25a50ccf0a7173df5..6635b0809e427e56db749e01cf794fa6e2ae02e3 100644 (file)
@@ -5,6 +5,18 @@
 /** Abstract base class for displaying a map. */
 export default class MapPart {
 
+       /** The name of the map, will also be the name of the variable */
+       #mapName;
+
+       constructor(mapName) {
+               this.#mapName = mapName;
+               this.createMapDiv(this.#mapName);
+       }
+
+       //
+       // ABSTRACT METHODS
+       //
+
        /** Zoom the map to the given value. */
        setZoom(zoom) {
                throw new Error("Abstract method");
@@ -23,4 +35,38 @@ export default class MapPart {
        addUrlLayer(url, format) {
                throw new Error("Abstract method");
        }
+
+       //
+       // EXTENSIONS
+       //
+       loadMapModule(url) {
+               var script = document.createElement("script");
+               script.src = url;
+               document.head.appendChild(script);
+               //              import(url)
+               //                      .then(module => { })
+               //                      .catch((error) => 'An error occurred while loading the component');
+       }
+
+       //
+       // AcCESSORS
+       //
+       getMapName() {
+               return this.#mapName;
+       }
+
+       //
+       // HTML
+       //
+       createMapDiv(id) {
+               var mapDiv = document.createElement('div');
+               mapDiv.id = id;
+               mapDiv.className = this.getMapDivCssClass();
+               mapDiv.style.cssText = 'width: 100%; height: 100vh;';
+               document.body.appendChild(mapDiv);
+       }
+
+       getMapDivCssClass() {
+               throw new Error("Abstract method");
+       }
 }