X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.app.geo.js%2Fsrc%2Forg.argeo.app.geo.js%2FMapPart.js;h=5711233a629767c5647405cbcf40e11b32a2c750;hb=455df52702432311c1825f366e01d01abd0319e2;hp=1a3dd2eb8818ed2672fe0cff91b285b887ca38f0;hpb=fc0e6e51c8167a19e76dbaf4fe60a13fe4f4215e;p=gpl%2Fargeo-suite.git diff --git a/org.argeo.app.geo.js/src/org.argeo.app.geo.js/MapPart.js b/org.argeo.app.geo.js/src/org.argeo.app.geo.js/MapPart.js index 1a3dd2e..5711233 100644 --- a/org.argeo.app.geo.js/src/org.argeo.app.geo.js/MapPart.js +++ b/org.argeo.app.geo.js/src/org.argeo.app.geo.js/MapPart.js @@ -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"); @@ -14,4 +26,47 @@ export default class MapPart { setCenter(lng, lat) { throw new Error("Abstract method"); } + + /** Add a single point. */ + addPoint(lng, lat, style) { + throw new Error("Abstract method"); + } + + 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"); + } }