@eox/drawtools 1.1.5 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/eox-drawtools.js +1507 -1309
  2. package/dist/eox-drawtools.umd.cjs +50 -50
  3. package/dist/material-symbols-outlined.woff2 +0 -0
  4. package/dist/material-symbols-rounded.woff2 +0 -0
  5. package/dist/material-symbols-sharp.woff2 +0 -0
  6. package/dist/material-symbols-subset.woff2 +0 -0
  7. package/package.json +2 -2
  8. package/src/components/controller.js +7 -7
  9. package/src/main.js +92 -18
  10. package/src/methods/draw/emit-drawn-features.js +7 -1
  11. package/src/methods/draw/index.js +1 -0
  12. package/src/methods/draw/init-layer.js +65 -32
  13. package/src/methods/draw/init-measuring.js +69 -0
  14. package/types/drawtools/src/main.d.ts +33 -7
  15. package/types/drawtools/src/main.d.ts.map +1 -1
  16. package/types/drawtools/src/methods/draw/emit-drawn-features.d.ts.map +1 -1
  17. package/types/drawtools/src/methods/draw/index.d.ts +1 -0
  18. package/types/drawtools/src/methods/draw/init-layer.d.ts.map +1 -1
  19. package/types/drawtools/src/methods/draw/init-measuring.d.ts +10 -0
  20. package/types/drawtools/src/methods/draw/init-measuring.d.ts.map +1 -0
  21. package/types/map/src/controls/GlobeSwitcher.d.ts +19 -0
  22. package/types/map/src/controls/GlobeSwitcher.d.ts.map +1 -0
  23. package/types/map/src/controls/controls.d.ts +1 -2
  24. package/types/map/src/controls/controls.d.ts.map +1 -1
  25. package/types/map/src/controls/geo-location.d.ts +14 -4
  26. package/types/map/src/controls/geo-location.d.ts.map +1 -1
  27. package/types/map/src/custom/layers/MapboxStyle.d.ts +2 -2
  28. package/types/map/src/custom/layers/MapboxStyle.d.ts.map +1 -1
  29. package/types/map/src/custom/sources/Cluster.d.ts +6 -2
  30. package/types/map/src/custom/sources/Cluster.d.ts.map +1 -1
  31. package/types/map/src/custom/sources/FlatGeoBuf.d.ts +4 -2
  32. package/types/map/src/custom/sources/FlatGeoBuf.d.ts.map +1 -1
  33. package/types/map/src/custom/sources/WMTSCapabilities.d.ts.map +1 -1
  34. package/types/map/src/helpers/cluster-explode.d.ts +5 -1
  35. package/types/map/src/helpers/cluster-explode.d.ts.map +1 -1
  36. package/types/map/src/helpers/generate.d.ts.map +1 -1
  37. package/types/map/src/helpers/layer.d.ts +3 -1
  38. package/types/map/src/helpers/layer.d.ts.map +1 -1
  39. package/types/map/src/helpers/parse-text.d.ts +11 -0
  40. package/types/map/src/helpers/parse-text.d.ts.map +1 -1
  41. package/types/map/src/helpers/select.d.ts +6 -2
  42. package/types/map/src/helpers/select.d.ts.map +1 -1
  43. package/types/map/src/layers.d.ts +2 -1
  44. package/types/map/src/layers.d.ts.map +1 -1
  45. package/types/map/src/main.d.ts +105 -35
  46. package/types/map/src/main.d.ts.map +1 -1
  47. package/types/map/src/methods/map/first-updated.d.ts.map +1 -1
  48. package/types/map/src/methods/map/getters.d.ts.map +1 -1
  49. package/types/map/src/methods/map/index.d.ts +1 -1
  50. package/types/map/src/methods/map/setters.d.ts +1 -0
  51. package/types/map/src/methods/map/setters.d.ts.map +1 -1
  52. package/types/map/src/plugins/globe/index.d.ts +6 -0
  53. package/types/map/src/plugins/globe/index.d.ts.map +1 -0
  54. package/types/map/src/plugins/globe/methods.d.ts +8 -0
  55. package/types/map/src/plugins/globe/methods.d.ts.map +1 -0
  56. package/types/map/src/plugins/globe/openglobus.d.ts +25 -0
  57. package/types/map/src/plugins/globe/openglobus.d.ts.map +1 -0
  58. package/types/map/src/types.d.ts +20 -1
  59. package/types/map/src/types.d.ts.map +1 -1
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eox/drawtools",
3
- "version": "1.1.5",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@eox/elements-utils": "^1.1.0",
42
- "@eox/ui": "^0.5.0",
42
+ "@eox/ui": "^1.1.0",
43
43
  "lit": "^3.2.0",
44
44
  "ol": "^10.4.0"
45
45
  }
@@ -219,9 +219,9 @@ export class EOxDrawToolsController extends LitElement {
219
219
  <i class="small"
220
220
  >${this.select ? pointerIcon : shapeIcons[this.type]}</i
221
221
  >
222
- <div class="tooltip bottom">
222
+ <span class="tooltip bottom">
223
223
  ${this.select ? "Select" : "Draw"}
224
- </div>
224
+ </span>
225
225
  `}
226
226
  </button>
227
227
 
@@ -237,7 +237,7 @@ export class EOxDrawToolsController extends LitElement {
237
237
  ? "discard"
238
238
  : html`
239
239
  <i class="small">${discardIcon}</i>
240
- <div class="tooltip bottom">Discard</div>
240
+ <span class="tooltip bottom">Discard</span>
241
241
  `}
242
242
  </button>
243
243
  </div>
@@ -259,7 +259,7 @@ export class EOxDrawToolsController extends LitElement {
259
259
  ? "import"
260
260
  : html`
261
261
  <i class="small">${editIcon}</i>
262
- <div class="tooltip bottom">Edit features</div>
262
+ <span class="tooltip bottom">Edit features</span>
263
263
  `}
264
264
  </button>
265
265
  `,
@@ -291,7 +291,7 @@ export class EOxDrawToolsController extends LitElement {
291
291
  ? "import"
292
292
  : html`
293
293
  <i class="small">${importIcon}</i>
294
- <div class="tooltip bottom">Import features</div>
294
+ <span class="tooltip bottom">Import features</span>
295
295
  `}
296
296
  </button>
297
297
  `,
@@ -302,7 +302,7 @@ export class EOxDrawToolsController extends LitElement {
302
302
  ${when(
303
303
  this.showEditor,
304
304
  () => html`
305
- <div id="editor" class="field textarea border extra hidden">
305
+ <div id="editor" class="field border extra hidden">
306
306
  <!-- Geo JSON Editor -->
307
307
  <textarea
308
308
  style="font-family: monospace; font-size: small; line-height: 1.4; padding: 0.4rem;"
@@ -322,7 +322,7 @@ export class EOxDrawToolsController extends LitElement {
322
322
  ? "copy"
323
323
  : html`
324
324
  <i class="tiny">${copyIcon}</i>
325
- <div class="tooltip top">Copy</div>
325
+ <span class="tooltip top">Copy</span>
326
326
  `}
327
327
  </button>
328
328
  </div>
package/src/main.js CHANGED
@@ -54,6 +54,7 @@ export class EOxDrawTools extends LitElement {
54
54
  featureStyles: { attribute: false },
55
55
  modify: { attribute: false, state: true },
56
56
  multipleFeatures: { attribute: "multiple-features", type: Boolean },
57
+ measure: { type: Boolean },
57
58
  importFeatures: { attribute: "import-features", type: Boolean },
58
59
  showEditor: { attribute: "show-editor", type: Boolean },
59
60
  showList: { attribute: "show-list", type: Boolean },
@@ -84,11 +85,21 @@ export class EOxDrawTools extends LitElement {
84
85
  * @type string
85
86
  */
86
87
  #layerId;
88
+ /**
89
+ * @type boolean
90
+ */
91
+ #internalUpdate = false;
92
+
87
93
  /**
88
94
  * @type boolean
89
95
  */
90
96
  #continuous;
91
97
 
98
+ /**
99
+ * @type Array<import("ol").Feature>
100
+ */
101
+ #drawnFeatures = [];
102
+
92
103
  constructor() {
93
104
  super();
94
105
 
@@ -128,12 +139,6 @@ export class EOxDrawTools extends LitElement {
128
139
  */
129
140
  this.layerId = "";
130
141
 
131
- /**
132
- * The array of drawn native OpenLayers features. Normally includes only one feature, until multiple feature drawing is enabled.
133
- * @type Array<import("ol").Feature>
134
- */
135
- this.drawnFeatures = [];
136
-
137
142
  /**
138
143
  * The display name of drawn features, shown e.g. in the feature list.
139
144
  */
@@ -165,6 +170,14 @@ export class EOxDrawTools extends LitElement {
165
170
  */
166
171
  this.multipleFeatures = false;
167
172
 
173
+ /**
174
+ * Display area/line measurement for the drawn features.
175
+ * When enabled, a "measure" property is added to each drawn feature's properties,
176
+ * containing the calculated area (for Polygons and Circles) or length (for LineStrings).
177
+ * This measurement is also displayed as a text label on the map using OpenLayers flat styles.
178
+ */
179
+ this.measure = false;
180
+
168
181
  /**
169
182
  * Allow import features using drag-drop and upload button
170
183
  */
@@ -230,6 +243,52 @@ export class EOxDrawTools extends LitElement {
230
243
  return this.#continuous;
231
244
  }
232
245
 
246
+ /**
247
+ * Used internally to update the drawnFeatures state without overwriting the map layer source.
248
+ * @param {Array<import("ol").Feature>} features
249
+ */
250
+ setDrawnFeaturesInternal(features) {
251
+ this.#internalUpdate = true;
252
+ this.drawnFeatures = features;
253
+ this.#internalUpdate = false;
254
+ }
255
+
256
+ /**
257
+ * The array of drawn native OpenLayers features. Normally includes only one feature, until multiple feature drawing is enabled.
258
+ * Pass features to be drawn on the map by setting this property. The features should be in the same projection as the map, or a projection should be specified via the `projection` property for proper transformation.
259
+ * @type {Array<import("ol").Feature>}
260
+ */
261
+ set drawnFeatures(features) {
262
+ const oldValue = this.#drawnFeatures;
263
+ this.#drawnFeatures = features;
264
+ if (this.drawLayer && !this.#internalUpdate) {
265
+ this.drawLayer.getSource().clear();
266
+ if (features?.length) {
267
+ const source = this.eoxMap?.projection || "EPSG:3857";
268
+ const destination = this.projection || "EPSG:4326";
269
+
270
+ let featuresToAdd = features;
271
+ if (source && destination && source !== destination) {
272
+ featuresToAdd = features.map((feat) => {
273
+ feat = feat.clone();
274
+ const transformed = feat
275
+ .getGeometry()
276
+ .transform(destination, source);
277
+ feat.setGeometry(transformed);
278
+ return feat;
279
+ });
280
+ }
281
+ this.drawLayer.getSource().addFeatures(featuresToAdd);
282
+ }
283
+ this.updateGeoJSON();
284
+ }
285
+ this.requestUpdate("drawnFeatures", oldValue);
286
+ }
287
+
288
+ get drawnFeatures() {
289
+ return this.#drawnFeatures;
290
+ }
291
+
233
292
  /**
234
293
  * Enables selection mode for the passed layer
235
294
  * @type {string}
@@ -326,9 +385,11 @@ export class EOxDrawTools extends LitElement {
326
385
  /**
327
386
  * initializes the EOxMap and OlMap instances
328
387
  * And stores them in the private properties #eoxMap and #olMap, respectively.
329
- * It then calls requestUpdate to trigger a re-render.
330
388
  */
331
- firstUpdated() {
389
+ updateLayer() {
390
+ if (this.resetLayer) {
391
+ this.resetLayer(this);
392
+ }
332
393
  const { EoxMap, OlMap, reset } = initLayerMethod(
333
394
  this,
334
395
  this.multipleFeatures,
@@ -336,26 +397,39 @@ export class EOxDrawTools extends LitElement {
336
397
  this.resetLayer = reset;
337
398
  this.eoxMap = EoxMap;
338
399
  this.#olMap = OlMap;
400
+ }
401
+
402
+ /**
403
+ * initializes the EOxMap and OlMap instances
404
+ * And stores them in the private properties #eoxMap and #olMap, respectively.
405
+ * It then calls requestUpdate to trigger a re-render.
406
+ */
407
+ firstUpdated() {
408
+ this.updateLayer();
339
409
  this.selectionEvents = createSelectHandler(this);
340
410
 
341
411
  if (this.importFeatures) initMapDragDropImport(this, this.eoxMap);
342
412
 
343
- this.updateGeoJSON();
413
+ if (this.drawnFeatures?.length > 0) {
414
+ this.drawnFeatures = [...this.drawnFeatures];
415
+ } else {
416
+ this.updateGeoJSON();
417
+ }
344
418
  this.requestUpdate();
345
419
  }
346
420
 
347
421
  updated(changedProperties) {
348
- if (changedProperties.has("for")) {
349
- const { EoxMap, OlMap } = initLayerMethod(this, this.multipleFeatures);
350
- this.eoxMap = EoxMap;
351
- this.#olMap = OlMap;
352
- }
422
+ const hasOldValue = (prop) =>
423
+ changedProperties.has(prop) && changedProperties.get(prop) !== undefined;
424
+
353
425
  if (
354
- changedProperties.get("type") &&
355
- changedProperties.get("type") !== this.type
426
+ hasOldValue("for") ||
427
+ (changedProperties.has("type") &&
428
+ changedProperties.get("type") !== this.type) ||
429
+ (changedProperties.has("measure") &&
430
+ changedProperties.get("measure") !== this.measure)
356
431
  ) {
357
- this.resetLayer(this);
358
- this.firstUpdated();
432
+ this.updateLayer();
359
433
  this.currentlyDrawing = false;
360
434
  }
361
435
  }
@@ -22,7 +22,7 @@ const emitDrawnFeaturesMethod = (EoxDrawTool, drawUpdateEvent) => {
22
22
  // has a default value of EPSG:4326
23
23
  const destination = EoxDrawTool.projection;
24
24
  // Update drawnFeatures with transformed features if the destination is defined
25
- EoxDrawTool.drawnFeatures = destination
25
+ const newFeatures = destination
26
26
  ? drawnFeatures.map((feat) => {
27
27
  feat = feat.clone();
28
28
  const transformed = feat.getGeometry().transform(source, destination);
@@ -31,6 +31,12 @@ const emitDrawnFeaturesMethod = (EoxDrawTool, drawUpdateEvent) => {
31
31
  })
32
32
  : drawnFeatures;
33
33
 
34
+ if (EoxDrawTool.setDrawnFeaturesInternal) {
35
+ EoxDrawTool.setDrawnFeaturesInternal(newFeatures);
36
+ } else {
37
+ EoxDrawTool.drawnFeatures = newFeatures;
38
+ }
39
+
34
40
  // Emit features based on the format provided
35
41
  let value;
36
42
  switch (EoxDrawTool.format) {
@@ -8,3 +8,4 @@ export { default as emitDrawnFeaturesMethod } from "./emit-drawn-features"; // E
8
8
  export { default as createSelectHandler } from "./create-select-handler"; // Factory function to create select event handler
9
9
  export { default as initSelection } from "./init-selection"; // Initializes selection interactions
10
10
  export { default as handleLayerId } from "./handle-layer-id"; // handle switching between selection and drawing
11
+ export { default as initMeasuring, updateMeasure } from "./init-measuring"; // Initializes measuring logic
@@ -1,4 +1,6 @@
1
- import { onDrawEndMethod, initSelection } from "./";
1
+ import onDrawEndMethod from "./on-draw-end";
2
+ import initSelection from "./init-selection";
3
+ import initMeasuring, { updateMeasure } from "./init-measuring";
2
4
 
3
5
  import { getElement } from "@eox/elements-utils";
4
6
 
@@ -35,6 +37,14 @@ const initLayerMethod = (EoxDrawTool, multipleFeatures) => {
35
37
  "stroke-width": 2,
36
38
  "circle-radius": 5,
37
39
  "circle-fill-color": `rgba(${primaryColor}, 1)`,
40
+ ...(EoxDrawTool.measure && {
41
+ "text-value": ["coalesce", ["get", "measure"], ""],
42
+ "text-fill-color": `rgba(${primaryColor}, 1)`,
43
+ "text-stroke-color": "white",
44
+ "text-stroke-width": 3,
45
+ "text-font": "bold 14px sans-serif",
46
+ "text-overflow": true,
47
+ }),
38
48
  },
39
49
  interactions: [
40
50
  {
@@ -52,35 +62,47 @@ const initLayerMethod = (EoxDrawTool, multipleFeatures) => {
52
62
  "stroke-line-dash": [7, 3],
53
63
  "circle-radius": 5,
54
64
  "circle-fill-color": `rgba(${primaryColor}, 1)`,
65
+ ...(EoxDrawTool.measure && {
66
+ "text-value": ["coalesce", ["get", "measure"], ""],
67
+ "text-fill-color": `rgba(${primaryColor}, 1)`,
68
+ "text-stroke-color": "white",
69
+ "text-stroke-width": 3,
70
+ "text-font": "bold 14px sans-serif",
71
+ "text-overflow": true,
72
+ }),
55
73
  },
56
74
  },
57
75
  },
58
- {
59
- type: "select",
60
- options: {
61
- id: "SelectLayerHoverInteraction",
62
- condition: "pointermove",
63
- style: EoxDrawTool.featureStyles?.["hover"] || {
64
- "fill-color": `rgba(${primaryColor}, 0.2)`,
65
- "stroke-color": `rgba(${primaryColor}, 1)`,
66
- "stroke-width": 2,
67
- },
68
- tooltip: false,
69
- },
70
- },
71
- {
72
- type: "select",
73
- options: {
74
- id: "SelectLayerClickInteraction",
75
- condition: "click",
76
- panIn: true,
77
- style: EoxDrawTool.featureStyles?.["click"] || {
78
- "fill-color": `rgba(${primaryColor}, 0.2)`,
79
- "stroke-color": `rgba(${primaryColor}, 1)`,
80
- "stroke-width": 2,
81
- },
82
- },
83
- },
76
+ ...(!EoxDrawTool.layerId
77
+ ? /** @type {import("@eox/map/src/types").EOxInteraction[]} */ ([
78
+ {
79
+ type: "select",
80
+ options: {
81
+ id: "SelectLayerHoverInteraction",
82
+ condition: "pointermove",
83
+ style: EoxDrawTool.featureStyles?.["hover"] || {
84
+ "fill-color": `rgba(${primaryColor}, 0.2)`,
85
+ "stroke-color": `rgba(${primaryColor}, 1)`,
86
+ "stroke-width": 2,
87
+ },
88
+ tooltip: false,
89
+ },
90
+ },
91
+ {
92
+ type: "select",
93
+ options: {
94
+ id: "SelectLayerClickInteraction",
95
+ condition: "click",
96
+ panIn: true,
97
+ style: EoxDrawTool.featureStyles?.["click"] || {
98
+ "fill-color": `rgba(${primaryColor}, 0.2)`,
99
+ "stroke-color": `rgba(${primaryColor}, 1)`,
100
+ "stroke-width": 2,
101
+ },
102
+ },
103
+ },
104
+ ])
105
+ : []),
84
106
  ],
85
107
  });
86
108
 
@@ -89,22 +111,33 @@ const initLayerMethod = (EoxDrawTool, multipleFeatures) => {
89
111
  );
90
112
 
91
113
  EoxDrawTool.modify = /** @type {import("ol/interaction").Modify} */ (
92
- /** @type {unknown} */ (EoxMap.interactions["drawInteractionmodify"])
114
+ /** @type {unknown} */ (EoxMap.interactions["drawInteraction_modify"])
93
115
  );
94
116
 
95
117
  // Initialize selection interactions
96
118
  initSelection(EoxDrawTool, EoxMap, EoxDrawTool.layerId);
119
+
120
+ if (EoxDrawTool.measure) {
121
+ initMeasuring(EoxDrawTool);
122
+ }
123
+
97
124
  const onModifyEnd = () => EoxDrawTool.onModifyEnd();
98
125
  const onAddFeatures = () => onDrawEndMethod(EoxDrawTool);
99
126
 
100
127
  EoxDrawTool.modify?.on("modifyend", onModifyEnd);
101
128
 
102
- EoxMap.addEventListener("addfeatures", onAddFeatures);
103
-
104
- if (EoxDrawTool.drawnFeatures) {
105
- EoxDrawTool.drawLayer.getSource().addFeatures(EoxDrawTool.drawnFeatures);
129
+ if (EoxDrawTool.measure) {
130
+ if (EoxDrawTool.draw && typeof EoxDrawTool.draw.on === "function") {
131
+ EoxDrawTool.draw.on("drawstart", (evt) => {
132
+ const feature = evt.feature;
133
+ updateMeasure(feature);
134
+ feature.getGeometry().on("change", () => updateMeasure(feature));
135
+ });
136
+ }
106
137
  }
107
138
 
139
+ EoxMap.addEventListener("addfeatures", onAddFeatures);
140
+
108
141
  /**
109
142
  * Resets the draw layer, cleaning up interactions and listeners.
110
143
  *
@@ -0,0 +1,69 @@
1
+ import { getArea, getLength } from "ol/sphere";
2
+
3
+ /**
4
+ * @param {import("ol").Feature} feature
5
+ */
6
+ export const updateMeasure = (feature) => {
7
+ const geom = feature.getGeometry();
8
+ if (!geom) return;
9
+ let measure = "";
10
+ if (geom.getType() === "Polygon" || geom.getType() === "MultiPolygon") {
11
+ const area = getArea(geom);
12
+ if (area > 1000000) {
13
+ measure = (area / 1000000).toFixed(2) + " km²";
14
+ } else {
15
+ measure = area.toFixed(2) + " m²";
16
+ }
17
+ } else if (
18
+ geom.getType() === "LineString" ||
19
+ geom.getType() === "MultiLineString"
20
+ ) {
21
+ const length = getLength(geom);
22
+ if (length > 1000) {
23
+ measure = (length / 1000).toFixed(2) + " km";
24
+ } else {
25
+ measure = length.toFixed(2) + " m";
26
+ }
27
+ } else if (geom.getType() === "Circle") {
28
+ // @ts-expect-error getRadius
29
+ const radius = geom.getRadius();
30
+ const area = Math.PI * Math.pow(radius, 2);
31
+ if (area > 1000000) {
32
+ measure = (area / 1000000).toFixed(2) + " km²";
33
+ } else {
34
+ measure = area.toFixed(2) + " m²";
35
+ }
36
+ }
37
+ if (measure && feature.get("measure") !== measure) {
38
+ feature.set("measure", measure);
39
+ }
40
+ };
41
+
42
+ /**
43
+ * Initializes measuring on the draw layer.
44
+ * Updates the feature property "measure" on geometry change.
45
+ *
46
+ * @param {import("../../main").EOxDrawTools} EoxDrawTool
47
+ */
48
+ const initMeasuring = (EoxDrawTool) => {
49
+ const source = EoxDrawTool.drawLayer.getSource();
50
+
51
+ /**
52
+ * @param {import("ol/source/Vector").VectorSourceEvent} evt
53
+ */
54
+ const handleFeature = (evt) => {
55
+ const feature = evt.feature;
56
+ if (feature) {
57
+ updateMeasure(feature);
58
+ feature.getGeometry().on("change", () => updateMeasure(feature));
59
+ }
60
+ };
61
+
62
+ source.on("addfeature", handleFeature);
63
+ source.getFeatures().forEach((feature) => {
64
+ updateMeasure(feature);
65
+ feature.getGeometry().on("change", () => updateMeasure(feature));
66
+ });
67
+ };
68
+
69
+ export default initMeasuring;
@@ -72,6 +72,9 @@ export class EOxDrawTools extends LitElement {
72
72
  attribute: string;
73
73
  type: BooleanConstructor;
74
74
  };
75
+ measure: {
76
+ type: BooleanConstructor;
77
+ };
75
78
  importFeatures: {
76
79
  attribute: string;
77
80
  type: BooleanConstructor;
@@ -132,11 +135,6 @@ export class EOxDrawTools extends LitElement {
132
135
  */
133
136
  set layerId(value: string);
134
137
  get layerId(): string;
135
- /**
136
- * The array of drawn native OpenLayers features. Normally includes only one feature, until multiple feature drawing is enabled.
137
- * @type Array<import("ol").Feature>
138
- */
139
- drawnFeatures: Array<import("ol").Feature>;
140
138
  /**
141
139
  * The display name of drawn features, shown e.g. in the feature list.
142
140
  */
@@ -167,6 +165,13 @@ export class EOxDrawTools extends LitElement {
167
165
  * Allow adding more than one feature at a time
168
166
  */
169
167
  multipleFeatures: boolean;
168
+ /**
169
+ * Display area/line measurement for the drawn features.
170
+ * When enabled, a "measure" property is added to each drawn feature's properties,
171
+ * containing the calculated area (for Polygons and Circles) or length (for LineStrings).
172
+ * This measurement is also displayed as a text label on the map using OpenLayers flat styles.
173
+ */
174
+ measure: boolean;
170
175
  /**
171
176
  * Allow import features using drag-drop and upload button
172
177
  */
@@ -216,6 +221,22 @@ export class EOxDrawTools extends LitElement {
216
221
  */
217
222
  set continuous(value: boolean);
218
223
  get continuous(): boolean;
224
+ /**
225
+ * Used internally to update the drawnFeatures state without overwriting the map layer source.
226
+ * @param {Array<import("ol").Feature>} features
227
+ */
228
+ setDrawnFeaturesInternal(features: Array<import("ol").Feature>): void;
229
+ /**
230
+ * The array of drawn native OpenLayers features. Normally includes only one feature, until multiple feature drawing is enabled.
231
+ * Pass features to be drawn on the map by setting this property. The features should be in the same projection as the map, or a projection should be specified via the `projection` property for proper transformation.
232
+ * @type {Array<import("ol").Feature>}
233
+ */
234
+ set drawnFeatures(features: import("ol").Feature<import("ol/geom").Geometry, {
235
+ [x: string]: any;
236
+ }>[]);
237
+ get drawnFeatures(): import("ol").Feature<import("ol/geom").Geometry, {
238
+ [x: string]: any;
239
+ }>[];
219
240
  /**
220
241
  * @onClick Event handler triggered to start drawing on the map.
221
242
  */
@@ -252,9 +273,8 @@ export class EOxDrawTools extends LitElement {
252
273
  /**
253
274
  * initializes the EOxMap and OlMap instances
254
275
  * And stores them in the private properties #eoxMap and #olMap, respectively.
255
- * It then calls requestUpdate to trigger a re-render.
256
276
  */
257
- firstUpdated(): void;
277
+ updateLayer(): void;
258
278
  resetLayer: (EoxDrawTool: import("./main").EOxDrawTools) => void;
259
279
  set eoxMap(value: import("@eox/map").EOxMap);
260
280
  /**
@@ -262,6 +282,12 @@ export class EOxDrawTools extends LitElement {
262
282
  * @type {import("@eox/map").EOxMap}
263
283
  */
264
284
  get eoxMap(): import("@eox/map").EOxMap;
285
+ /**
286
+ * initializes the EOxMap and OlMap instances
287
+ * And stores them in the private properties #eoxMap and #olMap, respectively.
288
+ * It then calls requestUpdate to trigger a re-render.
289
+ */
290
+ firstUpdated(): void;
265
291
  updated(changedProperties: any): void;
266
292
  render(): import("lit-html").TemplateResult<1>;
267
293
  #private;
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/main.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IAEE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAwBC;IA6BC;;OAEG;IACH,qBAAwB;IAExB;;;;;OAKG;IACH,KAFU,SAAO,WAAW,CAER;IAEpB;;OAEG;IACH,0BAA6B;IAE7B;;;OAGG;IACH,MAFS,OAAO,gBAAgB,EAAE,IAAI,GAAG,OAAO,UAAU,EAAE,MAAM,CAAC,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAEhF;IAEhB;;;OAGG;IAEH,WAHS,OAAO,iBAAiB,EAAE,OAAO,CAGrB;IA6GvB;;;OAGG;IACH,2BAGC;IAED,sBAEC;IAjHC;;;OAGG;IACH,eAFS,KAAK,CAAC,OAAO,IAAI,EAAE,OAAO,CAAC,CAEb;IAEvB;;OAEG;IACH,oBAA4B;IAE5B;;OAEG;IACH,oBAA0B;IAE1B;;;;;;;OAOG;IACH,eANU;QACP,KAAK,CAAC,EAAE,OAAO,eAAe,EAAE,aAAa,CAAA;QAC7C,KAAK,CAAC,EAAE,OAAO,eAAe,EAAE,aAAa,CAAA;QAC7C,KAAK,CAAC,EAAE,OAAO,eAAe,EAAE,a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CAAC,OAAO,IAAI,EAAE,OAAO,CAAC,QAMrC;IAED;;;;OAIG;IACH;;UAyBC;IAED;;SAEC;IAeD;;OAEG;IACH,qBAEC;IAED;;;OAGG;IACH,uBAEC;IAED;;;;OAIG;IACH,0BAJW,MAAM,oBACN,OAAO,YACP,OAAO,QAUjB;IAED;;OAEG;IACH,uBAFW,SAAS,IAAG,UAAU,GAAG;QAAE,MAAM,EAAE,gBAAgB,CAAA;KAAE,CAAA,QAI/D;IAED;;OAEG;IACH,oBAEC;IAED;;OAEG;IACH,sBAMC;IAED;;OAEG;IACH,0BAaC;IASD;;;OAGG;IACH,oBAWC;IAHC,iEAAuB;IAgDzB,kBANU,OAAO,UAAU,EAAE,MAAM,EAUlC;IAZD;;;OAGG;IACH,cAFU,OAAO,UAAU,EAAE,MAAM,CAIlC;IAzCD;;;;OAIG;IACH,qBAYC;IAED,sCAcC;IA6BD,+CAqDC;;CACF;2BArgByC,KAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"emit-drawn-features.d.ts","sourceRoot":"","sources":["../../../../../src/methods/draw/emit-drawn-features.js"],"names":[],"mappings":";;;;yBAGa,OAAO,IAAI,EAAE,OAAO,EAAE,GAC9B,UAAU,CAAC,OAAO,iBAAiB,CAAC,GACpC,UAAU,CAAC,OAAO,aAAa,CAAC;AAHrC;;;;GAIG;AAEH;;;;;GAKG;AACH,sDAHW,OAAO,YAAY,EAAE,YAAY,mBACjC,CAAC,KAAK,EAAC,UAAU,KAAK,IAAI,QA+CpC;kCA3DgD,eAAe;8BAAf,eAAe"}
1
+ {"version":3,"file":"emit-drawn-features.d.ts","sourceRoot":"","sources":["../../../../../src/methods/draw/emit-drawn-features.js"],"names":[],"mappings":";;;;yBAGa,OAAO,IAAI,EAAE,OAAO,EAAE,GAC9B,UAAU,CAAC,OAAO,iBAAiB,CAAC,GACpC,UAAU,CAAC,OAAO,aAAa,CAAC;AAHrC;;;;GAIG;AAEH;;;;;GAKG;AACH,sDAHW,OAAO,YAAY,EAAE,YAAY,mBACjC,CAAC,KAAK,EAAC,UAAU,KAAK,IAAI,QAqDpC;kCAjEgD,eAAe;8BAAf,eAAe"}
@@ -6,4 +6,5 @@ export { default as emitDrawnFeaturesMethod } from "./emit-drawn-features";
6
6
  export { default as createSelectHandler } from "./create-select-handler";
7
7
  export { default as initSelection } from "./init-selection";
8
8
  export { default as handleLayerId } from "./handle-layer-id";
9
+ export { default as initMeasuring, updateMeasure } from "./init-measuring";
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"init-layer.d.ts","sourceRoot":"","sources":["../../../../../src/methods/draw/init-layer.js"],"names":[],"mappings":";AAIA;;;;;GAKG;AACH,8CAHW,OAAO,YAAY,EAAE,YAAY;;;yBAuG/B,OAAO,YAAY,EAAE,YAAY;EAqB7C"}
1
+ {"version":3,"file":"init-layer.d.ts","sourceRoot":"","sources":["../../../../../src/methods/draw/init-layer.js"],"names":[],"mappings":";AAMA;;;;;GAKG;AACH,8CAHW,OAAO,YAAY,EAAE,YAAY;;;yBAsI/B,OAAO,YAAY,EAAE,YAAY;EAqB7C"}
@@ -0,0 +1,10 @@
1
+ export function updateMeasure(feature: import("ol").Feature): void;
2
+ export default initMeasuring;
3
+ /**
4
+ * Initializes measuring on the draw layer.
5
+ * Updates the feature property "measure" on geometry change.
6
+ *
7
+ * @param {import("../../main").EOxDrawTools} EoxDrawTool
8
+ */
9
+ declare function initMeasuring(EoxDrawTool: import("../../main").EOxDrawTools): void;
10
+ //# sourceMappingURL=init-measuring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-measuring.d.ts","sourceRoot":"","sources":["../../../../../src/methods/draw/init-measuring.js"],"names":[],"mappings":"AAKO,uCAFI,OAAO,IAAI,EAAE,OAAO,QAoC9B;;AAED;;;;;GAKG;AACH,4CAFW,OAAO,YAAY,EAAE,YAAY,QAqB3C"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * A control to switch between 2D and 3D views.
3
+ * @param {Object} [opt_options] Control options.
4
+ * @param {import("../main").EOxMap} opt_options.eoxMap
5
+ */
6
+ export class GlobeSwitcher extends Control {
7
+ /**
8
+ * @param {Object} [options] Control options.
9
+ * @param {import("../main").EOxMap} options.eoxMap
10
+ */
11
+ constructor(options?: {
12
+ eoxMap: import("../main").EOxMap;
13
+ });
14
+ eoxMap: import("../main").EOxMap;
15
+ button: HTMLButtonElement;
16
+ handleClick(): void;
17
+ }
18
+ import Control from "ol/control/Control";
19
+ //# sourceMappingURL=GlobeSwitcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GlobeSwitcher.d.ts","sourceRoot":"","sources":["../../../../../map/src/controls/GlobeSwitcher.js"],"names":[],"mappings":"AAMA;;;;GAIG;AACH;IACE;;;OAGG;IACH,sBAFG;QAA0C,MAAM,EAAxC,OAAO,SAAS,EAAE,MAAM;KAClC,EAoBA;IAJC,iCAA4B;IAC5B,0BAAoB;IAKtB,oBASC;CACF;oBA/CmB,oBAAoB"}
@@ -4,10 +4,9 @@
4
4
  *
5
5
  * @param {import("../main").EOxMap} EOxMap - The map instance.
6
6
  * @param {ControlDictionary} existingControls - Dictionary of existing controls.
7
- * @param {ControlType} type - The type of control to add or update.
8
7
  * @param {object} options - Options for the control.
9
8
  */
10
- export function addOrUpdateControl(EOxMap: import("../main").EOxMap, existingControls: ControlDictionary, type: ControlType, options: object): void;
9
+ export function addOrUpdateControl(EOxMap: import("../main").EOxMap, existingControls: ControlDictionary, type: any, options: object): void;
11
10
  /**
12
11
  * Adds a control to the map.
13
12
  *
@@ -1 +1 @@
1
- {"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../../../../../map/src/controls/controls.js"],"names":[],"mappings":"AAkCA;;;;;;;;GAQG;AACH,2CALW,OAAO,SAAS,EAAE,MAAM,oBACxB,iBAAiB,QACjB,WAAW,WACX,MAAM,QAiBhB;AAED;;;;;;GAMG;AACH,mCAJW,OAAO,SAAS,EAAE,MAAM,QACxB,WAAW,WACX,MAAM,QAiBhB;gCApEY,OAAO,UAAU,EAAE,iBAAiB;0BACpC,OAAO,UAAU,EAAE,WAAW"}
1
+ {"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../../../../../map/src/controls/controls.js"],"names":[],"mappings":"AAqCA;;;;;;;GAOG;AACH,2CAJW,OAAO,SAAS,EAAE,MAAM,oBACxB,iBAAiB,sBACjB,MAAM,QAiBhB;AAED;;;;;;GAMG;AACH,mCAJW,OAAO,SAAS,EAAE,MAAM,QACxB,WAAW,WACX,MAAM,QAqBhB;gCAxEY,OAAO,UAAU,EAAE,iBAAiB;0BACpC,OAAO,UAAU,EAAE,WAAW"}