]> git.argeo.org Git - gpl/argeo-suite.git/blob - js/src/geo/MapPart.js
Revert loading of XSD
[gpl/argeo-suite.git] / js / src / geo / MapPart.js
1 /** API to be used by Java.
2 * @module MapPart
3 */
4
5 /** Abstract base class for displaying a map. */
6 export default class MapPart {
7
8 /** The name of the map, will also be the name of the variable */
9 #mapName;
10
11 constructor(mapName) {
12 this.#mapName = mapName;
13 this.createMapDiv(this.#mapName);
14 }
15
16 //
17 // ABSTRACT METHODS
18 //
19 /** Set the center of the map to the given coordinates. */
20 setCenter(lng, lat) {
21 throw new Error("Abstract method");
22 }
23
24 //
25 // EXTENSIONS
26 //
27 loadMapModule(url) {
28 var script = document.createElement("script");
29 script.src = url;
30 document.head.appendChild(script);
31 // import(url)
32 // .then(module => { })
33 // .catch((error) => 'An error occurred while loading the component');
34 }
35
36 //
37 // ACCESSORS
38 //
39 getMapName() {
40 return this.#mapName;
41 }
42
43 //
44 // HTML
45 //
46 createMapDiv(id) {
47 var mapDiv = document.createElement('div');
48 mapDiv.id = id;
49 mapDiv.className = this.getMapDivCssClass();
50 mapDiv.style.cssText = 'width: 100%; height: 100vh;';
51 document.body.appendChild(mapDiv);
52 }
53
54 getMapDivCssClass() {
55 throw new Error("Abstract method");
56 }
57
58 newObject(js) {
59 const func = new Function(js);
60 return (func());
61 }
62 }