X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=org.argeo.app.geo.js%2Fsrc%2Forg.argeo.app.geo.js%2FMapPart.js;h=6635b0809e427e56db749e01cf794fa6e2ae02e3;hb=187dcc18d0f09b834774b74b32244113d6aa3daf;hp=fa4ba5cbed9e8969802f7a73fc01b59e279af5b0;hpb=78449dce988dbc690234d0508c6fd609feabe45a;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 fa4ba5c..6635b08 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 @@ -1,10 +1,72 @@ +/** API to be used by Java. + * @module MapPart + */ + +/** 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"); } + /** Set the center of the map to the given coordinates. */ 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"); + } }