@eox/drawtools 0.14.0 → 0.14.1-dev.1740731700.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.
- package/dist/eox-drawtools.js +288 -289
- package/dist/eox-drawtools.umd.cjs +20 -20
- package/package.json +1 -1
- package/src/main.js +3 -2
- package/src/methods/draw/create-select-handler.js +4 -4
- package/src/methods/draw/emit-drawn-features.js +9 -2
- package/src/methods/draw/on-draw-end.js +12 -6
- package/types/drawtools/src/main.d.ts +2 -1
- package/types/drawtools/src/main.d.ts.map +1 -1
- package/types/drawtools/src/methods/draw/create-select-handler.d.ts.map +1 -1
- package/types/drawtools/src/methods/draw/emit-drawn-features.d.ts +2 -1
- package/types/drawtools/src/methods/draw/emit-drawn-features.d.ts.map +1 -1
- package/types/drawtools/src/methods/draw/on-draw-end.d.ts +2 -1
- package/types/drawtools/src/methods/draw/on-draw-end.d.ts.map +1 -1
package/src/main.js
CHANGED
|
@@ -277,8 +277,9 @@ export class EOxDrawTools extends LitElement {
|
|
|
277
277
|
|
|
278
278
|
/**
|
|
279
279
|
* Triggers different events when the drawing of a shape is completed.
|
|
280
|
+
* @param {import("ol/Feature").default} [selectedFeature] - The feature that was selected by the user.
|
|
280
281
|
*/
|
|
281
|
-
emitDrawnFeatures() {
|
|
282
|
+
emitDrawnFeatures(selectedFeature) {
|
|
282
283
|
/**
|
|
283
284
|
* @param {import("./methods/draw/emit-drawn-features").EmitFormat} value
|
|
284
285
|
*/
|
|
@@ -290,7 +291,7 @@ export class EOxDrawTools extends LitElement {
|
|
|
290
291
|
*/
|
|
291
292
|
this.dispatchEvent(new CustomEvent("drawupdate", { detail: value }));
|
|
292
293
|
};
|
|
293
|
-
emitDrawnFeaturesMethod(this, drawUpdateEvent);
|
|
294
|
+
emitDrawnFeaturesMethod(this, drawUpdateEvent, selectedFeature);
|
|
294
295
|
}
|
|
295
296
|
|
|
296
297
|
/**
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { onDrawEndMethod } from "./";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Factory function to create a select event handler
|
|
3
5
|
* @param {import("../../main").EOxDrawTools} EoxDrawTool - The drawing tool instance.
|
|
@@ -13,10 +15,8 @@ const createSelectHandler = (EoxDrawTool) => {
|
|
|
13
15
|
if (e?.detail.id !== "SelectLayerClickInteraction" || !e.detail.feature) {
|
|
14
16
|
return;
|
|
15
17
|
}
|
|
16
|
-
EoxDrawTool.
|
|
17
|
-
EoxDrawTool.
|
|
18
|
-
new CustomEvent("addfeatures", { detail: e.detail }),
|
|
19
|
-
);
|
|
18
|
+
EoxDrawTool.drawnFeatures.push(e.detail.feature);
|
|
19
|
+
onDrawEndMethod(EoxDrawTool, e.detail.feature);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -11,12 +11,19 @@ import { featuresToGeoJson, featuresToWKT } from "../../helpers";
|
|
|
11
11
|
*
|
|
12
12
|
* @param {import("../../main").EOxDrawTools} EoxDrawTool - The drawing tool instance.
|
|
13
13
|
* @param {(value:EmitFormat) => void} drawUpdateEvent - event to be triggered after drawFeature is updated
|
|
14
|
+
* @param {import("ol").Feature} [selectedFeature] - The feature that was selected by the user.
|
|
14
15
|
*/
|
|
15
|
-
const emitDrawnFeaturesMethod = (
|
|
16
|
+
const emitDrawnFeaturesMethod = (
|
|
17
|
+
EoxDrawTool,
|
|
18
|
+
drawUpdateEvent,
|
|
19
|
+
selectedFeature,
|
|
20
|
+
) => {
|
|
16
21
|
// Function to emit features after a timeout (ensures update)
|
|
17
22
|
const emitFeatures = () => {
|
|
18
23
|
// Update drawnFeatures with features from drawLayer's source
|
|
19
|
-
const drawnFeatures =
|
|
24
|
+
const drawnFeatures = selectedFeature
|
|
25
|
+
? EoxDrawTool.drawnFeatures
|
|
26
|
+
: EoxDrawTool.drawLayer.getSource().getFeatures();
|
|
20
27
|
// Transform drawn features to the desired projection
|
|
21
28
|
const source = EoxDrawTool.eoxMap.projection || "EPSG:3857";
|
|
22
29
|
// has a default value of EPSG:4326
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
* emits drawn features, deactivates drawing, and requests an update.
|
|
4
4
|
*
|
|
5
5
|
* @param {import("../../main").EOxDrawTools} EoxDrawTool - The drawing tool instance.
|
|
6
|
+
* @param {import("ol/Feature").default} [selectedFeature] - The feature that was selected by the user.
|
|
6
7
|
*/
|
|
7
|
-
const onDrawEndMethod = (EoxDrawTool) => {
|
|
8
|
+
const onDrawEndMethod = (EoxDrawTool, selectedFeature) => {
|
|
8
9
|
// Function to handle actions when drawing ends
|
|
9
10
|
const handleDrawEnd = () => {
|
|
10
|
-
EoxDrawTool.emitDrawnFeatures(); // Emit drawn features
|
|
11
|
+
EoxDrawTool.emitDrawnFeatures(selectedFeature); // Emit drawn features
|
|
11
12
|
if (!EoxDrawTool.multipleFeatures) {
|
|
12
13
|
EoxDrawTool.draw.setActive(false); // Deactivate drawing
|
|
13
14
|
EoxDrawTool.selectionEvents.removeSelectionEvent();
|
|
@@ -19,10 +20,15 @@ const onDrawEndMethod = (EoxDrawTool) => {
|
|
|
19
20
|
EoxDrawTool.drawLayer.getSource().clear(true);
|
|
20
21
|
EoxDrawTool.drawnFeatures = [];
|
|
21
22
|
} else {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
let latest;
|
|
24
|
+
if (selectedFeature) {
|
|
25
|
+
latest = EoxDrawTool.drawnFeatures.at(-1);
|
|
26
|
+
} else {
|
|
27
|
+
const features = EoxDrawTool.drawLayer.getSource().getFeatures();
|
|
28
|
+
latest = features.at(-1);
|
|
29
|
+
EoxDrawTool.drawLayer.getSource().clear(true);
|
|
30
|
+
EoxDrawTool.drawLayer.getSource().addFeature(latest);
|
|
31
|
+
}
|
|
26
32
|
EoxDrawTool.drawnFeatures = [latest];
|
|
27
33
|
}
|
|
28
34
|
}
|
|
@@ -219,8 +219,9 @@ export class EOxDrawTools extends LitElement {
|
|
|
219
219
|
updateGeoJSON(): void;
|
|
220
220
|
/**
|
|
221
221
|
* Triggers different events when the drawing of a shape is completed.
|
|
222
|
+
* @param {import("ol/Feature").default} [selectedFeature] - The feature that was selected by the user.
|
|
222
223
|
*/
|
|
223
|
-
emitDrawnFeatures(): void;
|
|
224
|
+
emitDrawnFeatures(selectedFeature?: import("ol/Feature").default): void;
|
|
224
225
|
/**
|
|
225
226
|
* initializes the EOxMap and OlMap instances
|
|
226
227
|
* And stores them in the private properties #eoxMap and #olMap, respectively.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/main.js"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH;IAEE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAuBC;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;IAwGvB;;;OAGG;IACH,2BAGC;IAED,sBAEC;IA5GC;;;OAGG;IACH,eAFS,KAAK,CAAC,OAAO,IAAI,EAAE,OAAO,CAAC,CAEb;IAEvB;;OAEG;IACH,oBAA4B;IAE5B;;;;;;;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,aAAa,CAAA;KAC5C,GAAG,IAAI,CAEc;IAEzB;;;OAGG;IACH,QAFS,OAAO,gBA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sources":["../../../../../src/methods/draw/create-select-handler.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"create-select-handler.d.ts","sourceRoot":"","sources":["../../../../../src/methods/draw/create-select-handler.js"],"names":[],"mappings":";AAEA;;;GAGG;AACH,kDAFW,OAAO,YAAY,EAAE,YAAY;;;EA2C3C"}
|
|
@@ -13,8 +13,9 @@ export type EmitFormat = import("ol").Feature[] | ReturnType<typeof featuresToGe
|
|
|
13
13
|
*
|
|
14
14
|
* @param {import("../../main").EOxDrawTools} EoxDrawTool - The drawing tool instance.
|
|
15
15
|
* @param {(value:EmitFormat) => void} drawUpdateEvent - event to be triggered after drawFeature is updated
|
|
16
|
+
* @param {import("ol").Feature} [selectedFeature] - The feature that was selected by the user.
|
|
16
17
|
*/
|
|
17
|
-
declare function emitDrawnFeaturesMethod(EoxDrawTool: import("../../main").EOxDrawTools, drawUpdateEvent: (value: EmitFormat) => void): void;
|
|
18
|
+
declare function emitDrawnFeaturesMethod(EoxDrawTool: import("../../main").EOxDrawTools, drawUpdateEvent: (value: EmitFormat) => void, selectedFeature?: import("ol").Feature): void;
|
|
18
19
|
import { featuresToGeoJson } from "../../helpers";
|
|
19
20
|
import { featuresToWKT } from "../../helpers";
|
|
20
21
|
//# sourceMappingURL=emit-drawn-features.d.ts.map
|
|
@@ -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
|
|
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;;;;;;GAMG;AACH,sDAJW,OAAO,YAAY,EAAE,YAAY,mBACjC,CAAC,KAAK,EAAC,UAAU,KAAK,IAAI,oBAC1B,OAAO,IAAI,EAAE,OAAO,QAqD9B;kCAlEgD,eAAe;8BAAf,eAAe"}
|
|
@@ -4,6 +4,7 @@ export default onDrawEndMethod;
|
|
|
4
4
|
* emits drawn features, deactivates drawing, and requests an update.
|
|
5
5
|
*
|
|
6
6
|
* @param {import("../../main").EOxDrawTools} EoxDrawTool - The drawing tool instance.
|
|
7
|
+
* @param {import("ol/Feature").default} [selectedFeature] - The feature that was selected by the user.
|
|
7
8
|
*/
|
|
8
|
-
declare function onDrawEndMethod(EoxDrawTool: import("../../main").EOxDrawTools): void;
|
|
9
|
+
declare function onDrawEndMethod(EoxDrawTool: import("../../main").EOxDrawTools, selectedFeature?: import("ol/Feature").default): void;
|
|
9
10
|
//# sourceMappingURL=on-draw-end.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on-draw-end.d.ts","sourceRoot":"","sources":["../../../../../src/methods/draw/on-draw-end.js"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"on-draw-end.d.ts","sourceRoot":"","sources":["../../../../../src/methods/draw/on-draw-end.js"],"names":[],"mappings":";AAAA;;;;;;GAMG;AACH,8CAHW,OAAO,YAAY,EAAE,YAAY,oBACjC,OAAO,YAAY,EAAE,OAAO,QAmCtC"}
|