]> git.argeo.org Git - gpl/argeo-suite.git/blob - org.argeo.app.geo.js/src/org.argeo.app.geo.js/MapPart.js
Experiment with GML
[gpl/argeo-suite.git] / org.argeo.app.geo.js / src / org.argeo.app.geo.js / 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
20 /** Zoom the map to the given value. */
21 setZoom(zoom) {
22 throw new Error("Abstract method");
23 }
24
25 /** Set the center of the map to the given coordinates. */
26 setCenter(lng, lat) {
27 throw new Error("Abstract method");
28 }
29
30 /** Add a single point. */
31 addPoint(lng, lat, style) {
32 throw new Error("Abstract method");
33 }
34
35 addUrlLayer(url, format) {
36 throw new Error("Abstract method");
37 }
38
39 //
40 // EXTENSIONS
41 //
42 loadMapModule(url) {
43 var script = document.createElement("script");
44 script.src = url;
45 document.head.appendChild(script);
46 // import(url)
47 // .then(module => { })
48 // .catch((error) => 'An error occurred while loading the component');
49 }
50
51 //
52 // ACCESSORS
53 //
54 getMapName() {
55 return this.#mapName;
56 }
57
58 //
59 // HTML
60 //
61 createMapDiv(id) {
62 var mapDiv = document.createElement('div');
63 mapDiv.id = id;
64 mapDiv.className = this.getMapDivCssClass();
65 mapDiv.style.cssText = 'width: 100%; height: 100vh;';
66 document.body.appendChild(mapDiv);
67 }
68
69 getMapDivCssClass() {
70 throw new Error("Abstract method");
71 }
72 }