leaflet-anvil 0.2.1 → 0.2.2
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/README.md +82 -0
- package/dist/index.d.mts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +493 -247
- package/dist/index.mjs +513 -247
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -73,6 +73,49 @@ var ModeManager = class {
|
|
|
73
73
|
// src/modes/draw-polygon-mode.ts
|
|
74
74
|
import * as L3 from "leaflet";
|
|
75
75
|
|
|
76
|
+
// src/utils/mode-styles.ts
|
|
77
|
+
function getModePathOptions(options, mode, defaults = {}) {
|
|
78
|
+
return {
|
|
79
|
+
...defaults,
|
|
80
|
+
...options.pathOptions || {},
|
|
81
|
+
...options.modeStyles?.[mode]?.pathOptions || {}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function getModeGhostPathOptions(options, mode, defaults = {}) {
|
|
85
|
+
return {
|
|
86
|
+
...getModePathOptions(options, mode),
|
|
87
|
+
...defaults,
|
|
88
|
+
...options.ghostPathOptions || {},
|
|
89
|
+
...options.modeStyles?.[mode]?.ghostPathOptions || {}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function getModeVertexOptions(options, mode, defaults = {}) {
|
|
93
|
+
return {
|
|
94
|
+
...defaults,
|
|
95
|
+
...options.vertexOptions || {},
|
|
96
|
+
...options.modeStyles?.[mode]?.vertexOptions || {}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function getModeHandleOptions(options, mode, defaults = {}) {
|
|
100
|
+
const pathOptions = getModePathOptions(options, mode);
|
|
101
|
+
return {
|
|
102
|
+
radius: 5,
|
|
103
|
+
color: pathOptions.color || "#3388ff",
|
|
104
|
+
weight: 2,
|
|
105
|
+
fillColor: "#fff",
|
|
106
|
+
fillOpacity: 1,
|
|
107
|
+
...defaults,
|
|
108
|
+
...options.modeStyles?.[mode]?.handleOptions || {}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function getModeSelectionPathOptions(options, mode, base = {}, defaults = {}) {
|
|
112
|
+
return {
|
|
113
|
+
...base,
|
|
114
|
+
...defaults,
|
|
115
|
+
...options.modeStyles?.[mode]?.selectionPathOptions || {}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
76
119
|
// src/utils/snapping.ts
|
|
77
120
|
import * as L from "leaflet";
|
|
78
121
|
function getSnapLatLng(map, latlng, store, options, additionalPoints = [], skipLayer) {
|
|
@@ -233,11 +276,14 @@ var DrawPolygonMode = class {
|
|
|
233
276
|
const snapLatLng = this.store ? getSnapLatLng(this.map, e.latlng, this.store, this.options, this.points) : e.latlng;
|
|
234
277
|
const lastPoint = this.points[this.points.length - 1];
|
|
235
278
|
if (!this.ghostLine) {
|
|
236
|
-
this.ghostLine = L3.polyline(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
279
|
+
this.ghostLine = L3.polyline(
|
|
280
|
+
[lastPoint, snapLatLng],
|
|
281
|
+
getModeGhostPathOptions(this.options, "polygon" /* Polygon */, {
|
|
282
|
+
dashArray: "5, 5",
|
|
283
|
+
color: "#3388ff",
|
|
284
|
+
weight: 2
|
|
285
|
+
})
|
|
286
|
+
).addTo(this.map);
|
|
241
287
|
} else {
|
|
242
288
|
this.ghostLine.setLatLngs([lastPoint, snapLatLng]);
|
|
243
289
|
}
|
|
@@ -251,26 +297,32 @@ var DrawPolygonMode = class {
|
|
|
251
297
|
if (this.polyline) {
|
|
252
298
|
this.polyline.setLatLngs(this.points);
|
|
253
299
|
} else {
|
|
254
|
-
this.polyline = L3.polyline(
|
|
300
|
+
this.polyline = L3.polyline(
|
|
301
|
+
this.points,
|
|
302
|
+
getModePathOptions(this.options, "polygon" /* Polygon */, { color: "#3388ff" })
|
|
303
|
+
).addTo(this.map);
|
|
255
304
|
}
|
|
256
305
|
if (this.points.length === 1 && this.markers.length === 0) {
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
306
|
+
const marker3 = L3.circleMarker(
|
|
307
|
+
this.points[0],
|
|
308
|
+
getModeHandleOptions(this.options, "polygon" /* Polygon */, {
|
|
309
|
+
radius: 5,
|
|
310
|
+
color: "#3388ff"
|
|
311
|
+
})
|
|
312
|
+
).addTo(this.map);
|
|
313
|
+
marker3.on("click", (e) => {
|
|
265
314
|
L3.DomEvent.stopPropagation(e);
|
|
266
315
|
this.finish();
|
|
267
316
|
});
|
|
268
|
-
this.markers.push(
|
|
317
|
+
this.markers.push(marker3);
|
|
269
318
|
}
|
|
270
319
|
}
|
|
271
320
|
finish() {
|
|
272
321
|
if (this.points.length < 3) return;
|
|
273
|
-
const polygon7 = L3.polygon(
|
|
322
|
+
const polygon7 = L3.polygon(
|
|
323
|
+
this.points,
|
|
324
|
+
getModePathOptions(this.options, "polygon" /* Polygon */)
|
|
325
|
+
).addTo(this.map);
|
|
274
326
|
this.map.fire(ANVIL_EVENTS.CREATED, { layer: polygon7 });
|
|
275
327
|
this.reset();
|
|
276
328
|
}
|
|
@@ -326,11 +378,14 @@ var DrawPolylineMode = class {
|
|
|
326
378
|
const snapLatLng = this.store ? getSnapLatLng(this.map, e.latlng, this.store, this.options, this.points) : e.latlng;
|
|
327
379
|
const lastPoint = this.points[this.points.length - 1];
|
|
328
380
|
if (!this.ghostLine) {
|
|
329
|
-
this.ghostLine = L4.polyline(
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
381
|
+
this.ghostLine = L4.polyline(
|
|
382
|
+
[lastPoint, e.latlng],
|
|
383
|
+
getModeGhostPathOptions(this.options, "polyline" /* Polyline */, {
|
|
384
|
+
dashArray: "5, 5",
|
|
385
|
+
color: "#3388ff",
|
|
386
|
+
weight: 2
|
|
387
|
+
})
|
|
388
|
+
).addTo(this.map);
|
|
334
389
|
} else {
|
|
335
390
|
this.ghostLine.setLatLngs([lastPoint, snapLatLng]);
|
|
336
391
|
}
|
|
@@ -350,12 +405,18 @@ var DrawPolylineMode = class {
|
|
|
350
405
|
if (this.polyline) {
|
|
351
406
|
this.polyline.setLatLngs(this.points);
|
|
352
407
|
} else {
|
|
353
|
-
this.polyline = L4.polyline(
|
|
408
|
+
this.polyline = L4.polyline(
|
|
409
|
+
this.points,
|
|
410
|
+
getModePathOptions(this.options, "polyline" /* Polyline */, { color: "#3388ff" })
|
|
411
|
+
).addTo(this.map);
|
|
354
412
|
}
|
|
355
413
|
}
|
|
356
414
|
finish() {
|
|
357
415
|
if (this.points.length < 2) return;
|
|
358
|
-
const polyline6 = L4.polyline(
|
|
416
|
+
const polyline6 = L4.polyline(
|
|
417
|
+
this.points,
|
|
418
|
+
getModePathOptions(this.options, "polyline" /* Polyline */)
|
|
419
|
+
).addTo(this.map);
|
|
359
420
|
this.map.fire(ANVIL_EVENTS.CREATED, { layer: polyline6 });
|
|
360
421
|
this.reset();
|
|
361
422
|
}
|
|
@@ -386,8 +447,8 @@ var DrawMarkerMode = class {
|
|
|
386
447
|
}
|
|
387
448
|
onClick(e) {
|
|
388
449
|
const latlng = this.store ? getSnapLatLng(this.map, e.latlng, this.store, this.options) : e.latlng;
|
|
389
|
-
const
|
|
390
|
-
this.map.fire(ANVIL_EVENTS.CREATED, { layer:
|
|
450
|
+
const marker3 = L5.marker(latlng, getModeVertexOptions(this.options, "marker" /* Marker */)).addTo(this.map);
|
|
451
|
+
this.map.fire(ANVIL_EVENTS.CREATED, { layer: marker3 });
|
|
391
452
|
}
|
|
392
453
|
};
|
|
393
454
|
|
|
@@ -424,7 +485,13 @@ var DrawRectangleMode = class {
|
|
|
424
485
|
const currentLatLng = this.store ? getSnapLatLng(this.map, e.latlng, this.store, this.options) : e.latlng;
|
|
425
486
|
const bounds = L6.latLngBounds(this.startLatLng, currentLatLng);
|
|
426
487
|
if (!this.rectangle) {
|
|
427
|
-
this.rectangle = L6.rectangle(
|
|
488
|
+
this.rectangle = L6.rectangle(
|
|
489
|
+
bounds,
|
|
490
|
+
getModeGhostPathOptions(this.options, "rectangle" /* Rectangle */, {
|
|
491
|
+
color: "#3388ff",
|
|
492
|
+
weight: 2
|
|
493
|
+
})
|
|
494
|
+
).addTo(this.map);
|
|
428
495
|
} else {
|
|
429
496
|
this.rectangle.setBounds(bounds);
|
|
430
497
|
}
|
|
@@ -433,7 +500,10 @@ var DrawRectangleMode = class {
|
|
|
433
500
|
if (!this.startLatLng) return;
|
|
434
501
|
const currentLatLng = this.store ? getSnapLatLng(this.map, e.latlng, this.store, this.options) : e.latlng;
|
|
435
502
|
const bounds = L6.latLngBounds(this.startLatLng, currentLatLng);
|
|
436
|
-
const rectangle3 = L6.rectangle(
|
|
503
|
+
const rectangle3 = L6.rectangle(
|
|
504
|
+
bounds,
|
|
505
|
+
getModePathOptions(this.options, "rectangle" /* Rectangle */)
|
|
506
|
+
).addTo(this.map);
|
|
437
507
|
this.map.fire(ANVIL_EVENTS.CREATED, { layer: rectangle3 });
|
|
438
508
|
this.reset();
|
|
439
509
|
}
|
|
@@ -477,7 +547,13 @@ var DrawSquareMode = class {
|
|
|
477
547
|
const currentLatLng = this.store ? getSnapLatLng(this.map, e.latlng, this.store, this.options) : e.latlng;
|
|
478
548
|
const squareBounds = this.getSquareBounds(this.startLatLng, currentLatLng);
|
|
479
549
|
if (!this.rectangle) {
|
|
480
|
-
this.rectangle = L7.rectangle(
|
|
550
|
+
this.rectangle = L7.rectangle(
|
|
551
|
+
squareBounds,
|
|
552
|
+
getModeGhostPathOptions(this.options, "square" /* Square */, {
|
|
553
|
+
color: "#3388ff",
|
|
554
|
+
weight: 2
|
|
555
|
+
})
|
|
556
|
+
).addTo(this.map);
|
|
481
557
|
} else {
|
|
482
558
|
this.rectangle.setBounds(squareBounds);
|
|
483
559
|
}
|
|
@@ -486,12 +562,15 @@ var DrawSquareMode = class {
|
|
|
486
562
|
if (!this.startLatLng) return;
|
|
487
563
|
const currentLatLng = this.store ? getSnapLatLng(this.map, e.latlng, this.store, this.options) : e.latlng;
|
|
488
564
|
const squareBounds = this.getSquareBounds(this.startLatLng, currentLatLng);
|
|
489
|
-
const polygon7 = L7.polygon(
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
565
|
+
const polygon7 = L7.polygon(
|
|
566
|
+
[
|
|
567
|
+
squareBounds.getNorthWest(),
|
|
568
|
+
squareBounds.getNorthEast(),
|
|
569
|
+
squareBounds.getSouthEast(),
|
|
570
|
+
squareBounds.getSouthWest()
|
|
571
|
+
],
|
|
572
|
+
getModePathOptions(this.options, "square" /* Square */)
|
|
573
|
+
).addTo(this.map);
|
|
495
574
|
this.map.fire(ANVIL_EVENTS.CREATED, { layer: polygon7 });
|
|
496
575
|
this.reset();
|
|
497
576
|
}
|
|
@@ -547,7 +626,13 @@ var DrawTriangleMode = class {
|
|
|
547
626
|
const currentLatLng = this.store ? getSnapLatLng(this.map, e.latlng, this.store, this.options) : e.latlng;
|
|
548
627
|
const trianglePoints = this.getTrianglePoints(this.startLatLng, currentLatLng);
|
|
549
628
|
if (!this.ghostTriangle) {
|
|
550
|
-
this.ghostTriangle = L8.polygon(
|
|
629
|
+
this.ghostTriangle = L8.polygon(
|
|
630
|
+
trianglePoints,
|
|
631
|
+
getModeGhostPathOptions(this.options, "triangle" /* Triangle */, {
|
|
632
|
+
color: "#3388ff",
|
|
633
|
+
weight: 2
|
|
634
|
+
})
|
|
635
|
+
).addTo(this.map);
|
|
551
636
|
} else {
|
|
552
637
|
this.ghostTriangle.setLatLngs(trianglePoints);
|
|
553
638
|
}
|
|
@@ -556,7 +641,10 @@ var DrawTriangleMode = class {
|
|
|
556
641
|
if (!this.startLatLng) return;
|
|
557
642
|
const currentLatLng = this.store ? getSnapLatLng(this.map, e.latlng, this.store, this.options) : e.latlng;
|
|
558
643
|
const trianglePoints = this.getTrianglePoints(this.startLatLng, currentLatLng);
|
|
559
|
-
const polygon7 = L8.polygon(
|
|
644
|
+
const polygon7 = L8.polygon(
|
|
645
|
+
trianglePoints,
|
|
646
|
+
getModePathOptions(this.options, "triangle" /* Triangle */)
|
|
647
|
+
).addTo(this.map);
|
|
560
648
|
this.map.fire(ANVIL_EVENTS.CREATED, { layer: polygon7 });
|
|
561
649
|
this.reset();
|
|
562
650
|
}
|
|
@@ -611,7 +699,13 @@ var DrawCircleMode = class {
|
|
|
611
699
|
const currentLatLng = this.store ? getSnapLatLng(this.map, e.latlng, this.store, this.options) : e.latlng;
|
|
612
700
|
const radius = this.map.distance(this.centerLatLng, currentLatLng);
|
|
613
701
|
if (!this.circle) {
|
|
614
|
-
this.circle = L9.circle(this.centerLatLng, {
|
|
702
|
+
this.circle = L9.circle(this.centerLatLng, {
|
|
703
|
+
radius,
|
|
704
|
+
...getModeGhostPathOptions(this.options, "circle" /* Circle */, {
|
|
705
|
+
color: "#3388ff",
|
|
706
|
+
weight: 2
|
|
707
|
+
})
|
|
708
|
+
}).addTo(this.map);
|
|
615
709
|
} else {
|
|
616
710
|
this.circle.setRadius(radius);
|
|
617
711
|
}
|
|
@@ -620,7 +714,10 @@ var DrawCircleMode = class {
|
|
|
620
714
|
if (!this.centerLatLng) return;
|
|
621
715
|
const currentLatLng = this.store ? getSnapLatLng(this.map, e.latlng, this.store, this.options) : e.latlng;
|
|
622
716
|
const radius = this.map.distance(this.centerLatLng, currentLatLng);
|
|
623
|
-
const circle2 = L9.circle(this.centerLatLng, {
|
|
717
|
+
const circle2 = L9.circle(this.centerLatLng, {
|
|
718
|
+
radius,
|
|
719
|
+
...getModePathOptions(this.options, "circle" /* Circle */)
|
|
720
|
+
}).addTo(this.map);
|
|
624
721
|
this.map.fire(ANVIL_EVENTS.CREATED, { layer: circle2 });
|
|
625
722
|
this.reset();
|
|
626
723
|
}
|
|
@@ -685,12 +782,15 @@ var FreehandMode = class {
|
|
|
685
782
|
if (this.polyline) {
|
|
686
783
|
this.polyline.setLatLngs(this.points);
|
|
687
784
|
} else {
|
|
688
|
-
this.polyline = L10.polyline(
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
785
|
+
this.polyline = L10.polyline(
|
|
786
|
+
this.points,
|
|
787
|
+
getModeGhostPathOptions(this.options, "freehand" /* Freehand */, {
|
|
788
|
+
color: "#3388ff",
|
|
789
|
+
weight: 3,
|
|
790
|
+
opacity: 0.8,
|
|
791
|
+
dashArray: "5, 5"
|
|
792
|
+
})
|
|
793
|
+
).addTo(this.map);
|
|
694
794
|
}
|
|
695
795
|
}
|
|
696
796
|
finish() {
|
|
@@ -705,7 +805,10 @@ var FreehandMode = class {
|
|
|
705
805
|
if (finalCoords.length > 0 && (finalCoords[0][0] !== finalCoords[finalCoords.length - 1][0] || finalCoords[0][1] !== finalCoords[finalCoords.length - 1][1])) {
|
|
706
806
|
finalCoords.push(finalCoords[0]);
|
|
707
807
|
}
|
|
708
|
-
const finalPolygon = L10.polygon(
|
|
808
|
+
const finalPolygon = L10.polygon(
|
|
809
|
+
finalCoords.map((c) => [c[1], c[0]]),
|
|
810
|
+
getModePathOptions(this.options, "freehand" /* Freehand */)
|
|
811
|
+
).addTo(this.map);
|
|
709
812
|
this.map.fire(ANVIL_EVENTS.CREATED, { layer: finalPolygon });
|
|
710
813
|
this.resetDrawing();
|
|
711
814
|
}
|
|
@@ -764,11 +867,14 @@ var CutMode = class {
|
|
|
764
867
|
const snapLatLng = getSnapLatLng(this.map, e.latlng, this.store, this.options, this.points);
|
|
765
868
|
const lastPoint = this.points[this.points.length - 1];
|
|
766
869
|
if (!this.ghostLine) {
|
|
767
|
-
this.ghostLine = L11.polyline(
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
870
|
+
this.ghostLine = L11.polyline(
|
|
871
|
+
[lastPoint, snapLatLng],
|
|
872
|
+
getModeGhostPathOptions(this.options, "cut" /* Cut */, {
|
|
873
|
+
dashArray: "5, 5",
|
|
874
|
+
color: "#ff0000",
|
|
875
|
+
weight: 2
|
|
876
|
+
})
|
|
877
|
+
).addTo(this.map);
|
|
772
878
|
} else {
|
|
773
879
|
this.ghostLine.setLatLngs([lastPoint, snapLatLng]);
|
|
774
880
|
}
|
|
@@ -782,21 +888,24 @@ var CutMode = class {
|
|
|
782
888
|
if (this.polyline) {
|
|
783
889
|
this.polyline.setLatLngs(this.points);
|
|
784
890
|
} else {
|
|
785
|
-
this.polyline = L11.polyline(
|
|
891
|
+
this.polyline = L11.polyline(
|
|
892
|
+
this.points,
|
|
893
|
+
getModePathOptions(this.options, "cut" /* Cut */, { color: "#ff0000" })
|
|
894
|
+
).addTo(this.map);
|
|
786
895
|
}
|
|
787
896
|
if (this.points.length === 1 && this.markers.length === 0) {
|
|
788
|
-
const
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
897
|
+
const marker3 = L11.circleMarker(
|
|
898
|
+
this.points[0],
|
|
899
|
+
getModeHandleOptions(this.options, "cut" /* Cut */, {
|
|
900
|
+
radius: 6,
|
|
901
|
+
color: "#ff0000"
|
|
902
|
+
})
|
|
903
|
+
).addTo(this.map);
|
|
904
|
+
marker3.on("click", (e) => {
|
|
796
905
|
L11.DomEvent.stopPropagation(e);
|
|
797
906
|
if (this.points.length >= 3) this.finish();
|
|
798
907
|
});
|
|
799
|
-
this.markers.push(
|
|
908
|
+
this.markers.push(marker3);
|
|
800
909
|
}
|
|
801
910
|
}
|
|
802
911
|
finish() {
|
|
@@ -823,7 +932,9 @@ var CutMode = class {
|
|
|
823
932
|
this.map.removeLayer(polygon7);
|
|
824
933
|
const flattened = turf2.flatten(result);
|
|
825
934
|
flattened.features.forEach((f) => {
|
|
826
|
-
const l = L11.geoJSON(f
|
|
935
|
+
const l = L11.geoJSON(f, {
|
|
936
|
+
style: getModePathOptions(this.options, "cut" /* Cut */)
|
|
937
|
+
}).getLayers()[0];
|
|
827
938
|
l.addTo(this.map);
|
|
828
939
|
this.map.fire(ANVIL_EVENTS.CREATED, { layer: l });
|
|
829
940
|
});
|
|
@@ -887,11 +998,14 @@ var SplitMode = class {
|
|
|
887
998
|
const snapLatLng = getSnapLatLng(this.map, e.latlng, this.store, this.options, this.points);
|
|
888
999
|
const lastPoint = this.points[this.points.length - 1];
|
|
889
1000
|
if (!this.ghostLine) {
|
|
890
|
-
this.ghostLine = L12.polyline(
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
1001
|
+
this.ghostLine = L12.polyline(
|
|
1002
|
+
[lastPoint, snapLatLng],
|
|
1003
|
+
getModeGhostPathOptions(this.options, "split" /* Split */, {
|
|
1004
|
+
dashArray: "5, 5",
|
|
1005
|
+
color: "#ff3300",
|
|
1006
|
+
weight: 2
|
|
1007
|
+
})
|
|
1008
|
+
).addTo(this.map);
|
|
895
1009
|
} else {
|
|
896
1010
|
this.ghostLine.setLatLngs([lastPoint, snapLatLng]);
|
|
897
1011
|
}
|
|
@@ -905,23 +1019,28 @@ var SplitMode = class {
|
|
|
905
1019
|
if (this.polyline) {
|
|
906
1020
|
this.polyline.setLatLngs(this.points);
|
|
907
1021
|
} else {
|
|
908
|
-
this.polyline = L12.polyline(
|
|
1022
|
+
this.polyline = L12.polyline(
|
|
1023
|
+
this.points,
|
|
1024
|
+
getModePathOptions(this.options, "split" /* Split */, {
|
|
1025
|
+
color: "#ff3300",
|
|
1026
|
+
weight: 3
|
|
1027
|
+
})
|
|
1028
|
+
).addTo(this.map);
|
|
909
1029
|
}
|
|
910
1030
|
const lastPoint = this.points[this.points.length - 1];
|
|
911
1031
|
if (this.markers.length === 0) {
|
|
912
|
-
const
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
iconAnchor: [5, 5]
|
|
1032
|
+
const marker3 = L12.circleMarker(
|
|
1033
|
+
lastPoint,
|
|
1034
|
+
getModeHandleOptions(this.options, "split" /* Split */, {
|
|
1035
|
+
radius: 5,
|
|
1036
|
+
color: "#ff3300"
|
|
918
1037
|
})
|
|
919
|
-
|
|
920
|
-
|
|
1038
|
+
).addTo(this.map);
|
|
1039
|
+
marker3.on("click", (e) => {
|
|
921
1040
|
L12.DomEvent.stopPropagation(e);
|
|
922
1041
|
this.finish();
|
|
923
1042
|
});
|
|
924
|
-
this.markers.push(
|
|
1043
|
+
this.markers.push(marker3);
|
|
925
1044
|
} else {
|
|
926
1045
|
this.markers[0].setLatLng(lastPoint);
|
|
927
1046
|
}
|
|
@@ -976,7 +1095,9 @@ var SplitMode = class {
|
|
|
976
1095
|
const processResult = (result) => {
|
|
977
1096
|
const flattened = turf3.flatten(result);
|
|
978
1097
|
flattened.features.forEach((f) => {
|
|
979
|
-
const l = L12.geoJSON(f
|
|
1098
|
+
const l = L12.geoJSON(f, {
|
|
1099
|
+
style: getModePathOptions(this.options, "split" /* Split */)
|
|
1100
|
+
}).getLayers()[0];
|
|
980
1101
|
l.addTo(this.map);
|
|
981
1102
|
this.map.fire(ANVIL_EVENTS.CREATED, { layer: l });
|
|
982
1103
|
});
|
|
@@ -1057,6 +1178,7 @@ var DragMode = class {
|
|
|
1057
1178
|
__publicField(this, "draggingLayer", null);
|
|
1058
1179
|
__publicField(this, "startLatLng", null);
|
|
1059
1180
|
__publicField(this, "initialLatLngs", null);
|
|
1181
|
+
__publicField(this, "originalPathStyle", null);
|
|
1060
1182
|
this.store.getGroup().on("layeradd", (e) => {
|
|
1061
1183
|
if (this.isEnabled) {
|
|
1062
1184
|
this.addLayerListener(e.layer);
|
|
@@ -1104,7 +1226,13 @@ var DragMode = class {
|
|
|
1104
1226
|
} else if (this.draggingLayer instanceof L13.Polyline) {
|
|
1105
1227
|
this.initialLatLngs = JSON.parse(JSON.stringify(this.draggingLayer.getLatLngs()));
|
|
1106
1228
|
}
|
|
1107
|
-
this.
|
|
1229
|
+
this.originalPathStyle = { ...this.draggingLayer.options };
|
|
1230
|
+
this.draggingLayer.setStyle(
|
|
1231
|
+
getModeSelectionPathOptions(this.options, "drag" /* Drag */, this.originalPathStyle, {
|
|
1232
|
+
weight: 4,
|
|
1233
|
+
color: "#ffcc00"
|
|
1234
|
+
})
|
|
1235
|
+
);
|
|
1108
1236
|
}
|
|
1109
1237
|
this.map.on("mousemove", this.onMouseMove, this);
|
|
1110
1238
|
this.map.on("mouseup", this.onMouseUp, this);
|
|
@@ -1139,7 +1267,7 @@ var DragMode = class {
|
|
|
1139
1267
|
onMouseUp() {
|
|
1140
1268
|
if (this.draggingLayer) {
|
|
1141
1269
|
if (this.draggingLayer instanceof L13.Path) {
|
|
1142
|
-
this.draggingLayer.setStyle(
|
|
1270
|
+
this.draggingLayer.setStyle(this.originalPathStyle || {});
|
|
1143
1271
|
}
|
|
1144
1272
|
this.map.fire(ANVIL_EVENTS.EDITED, { layer: this.draggingLayer });
|
|
1145
1273
|
}
|
|
@@ -1149,16 +1277,20 @@ var DragMode = class {
|
|
|
1149
1277
|
this.map.off("mousemove", this.onMouseMove, this);
|
|
1150
1278
|
this.map.off("mouseup", this.onMouseUp, this);
|
|
1151
1279
|
this.map.dragging.enable();
|
|
1280
|
+
if (this.draggingLayer instanceof L13.Path && this.originalPathStyle) {
|
|
1281
|
+
this.draggingLayer.setStyle(this.originalPathStyle);
|
|
1282
|
+
}
|
|
1152
1283
|
this.draggingLayer = null;
|
|
1153
1284
|
this.startLatLng = null;
|
|
1154
1285
|
this.initialLatLngs = null;
|
|
1286
|
+
this.originalPathStyle = null;
|
|
1155
1287
|
}
|
|
1156
1288
|
};
|
|
1157
1289
|
|
|
1158
1290
|
// src/modes/scale-mode.ts
|
|
1159
1291
|
import * as L14 from "leaflet";
|
|
1160
1292
|
var ScaleMode = class {
|
|
1161
|
-
constructor(map, store, options) {
|
|
1293
|
+
constructor(map, store, options = {}) {
|
|
1162
1294
|
this.map = map;
|
|
1163
1295
|
this.store = store;
|
|
1164
1296
|
this.options = options;
|
|
@@ -1167,6 +1299,7 @@ var ScaleMode = class {
|
|
|
1167
1299
|
__publicField(this, "initialLatLngs", null);
|
|
1168
1300
|
__publicField(this, "initialRadius", 0);
|
|
1169
1301
|
__publicField(this, "initialDistance", 0);
|
|
1302
|
+
__publicField(this, "originalPathStyle", null);
|
|
1170
1303
|
}
|
|
1171
1304
|
enable() {
|
|
1172
1305
|
this.store.getGroup().eachLayer((layer) => {
|
|
@@ -1195,11 +1328,20 @@ var ScaleMode = class {
|
|
|
1195
1328
|
if (this.selectedLayer instanceof L14.Circle) {
|
|
1196
1329
|
this.centerLatLng = this.selectedLayer.getLatLng();
|
|
1197
1330
|
this.initialRadius = this.selectedLayer.getRadius();
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
this.
|
|
1201
|
-
this.
|
|
1202
|
-
|
|
1331
|
+
}
|
|
1332
|
+
if (this.selectedLayer instanceof L14.Path) {
|
|
1333
|
+
this.originalPathStyle = { ...this.selectedLayer.options };
|
|
1334
|
+
this.selectedLayer.setStyle(
|
|
1335
|
+
getModeSelectionPathOptions(this.options, "scale" /* Scale */, this.originalPathStyle, {
|
|
1336
|
+
weight: 4,
|
|
1337
|
+
color: "#ffcc00"
|
|
1338
|
+
})
|
|
1339
|
+
);
|
|
1340
|
+
if (!(this.selectedLayer instanceof L14.Circle)) {
|
|
1341
|
+
const bounds = this.selectedLayer.getBounds();
|
|
1342
|
+
this.centerLatLng = bounds.getCenter();
|
|
1343
|
+
this.initialLatLngs = JSON.parse(JSON.stringify(this.selectedLayer.getLatLngs()));
|
|
1344
|
+
}
|
|
1203
1345
|
}
|
|
1204
1346
|
if (this.centerLatLng) {
|
|
1205
1347
|
this.initialDistance = this.map.distance(this.centerLatLng, e.latlng);
|
|
@@ -1230,7 +1372,7 @@ var ScaleMode = class {
|
|
|
1230
1372
|
onMouseUp() {
|
|
1231
1373
|
if (this.selectedLayer) {
|
|
1232
1374
|
if (this.selectedLayer instanceof L14.Path) {
|
|
1233
|
-
this.selectedLayer.setStyle(
|
|
1375
|
+
this.selectedLayer.setStyle(this.originalPathStyle || {});
|
|
1234
1376
|
}
|
|
1235
1377
|
this.map.fire(ANVIL_EVENTS.EDITED, { layer: this.selectedLayer });
|
|
1236
1378
|
}
|
|
@@ -1240,16 +1382,20 @@ var ScaleMode = class {
|
|
|
1240
1382
|
this.map.off("mousemove", this.onMouseMove, this);
|
|
1241
1383
|
this.map.off("mouseup", this.onMouseUp, this);
|
|
1242
1384
|
this.map.dragging.enable();
|
|
1385
|
+
if (this.selectedLayer instanceof L14.Path && this.originalPathStyle) {
|
|
1386
|
+
this.selectedLayer.setStyle(this.originalPathStyle);
|
|
1387
|
+
}
|
|
1243
1388
|
this.selectedLayer = null;
|
|
1244
1389
|
this.centerLatLng = null;
|
|
1245
1390
|
this.initialLatLngs = null;
|
|
1391
|
+
this.originalPathStyle = null;
|
|
1246
1392
|
}
|
|
1247
1393
|
};
|
|
1248
1394
|
|
|
1249
1395
|
// src/modes/rotate-mode.ts
|
|
1250
1396
|
import * as L15 from "leaflet";
|
|
1251
1397
|
var RotateMode = class {
|
|
1252
|
-
constructor(map, store, options) {
|
|
1398
|
+
constructor(map, store, options = {}) {
|
|
1253
1399
|
this.map = map;
|
|
1254
1400
|
this.store = store;
|
|
1255
1401
|
this.options = options;
|
|
@@ -1257,6 +1403,7 @@ var RotateMode = class {
|
|
|
1257
1403
|
__publicField(this, "centerLatLng", null);
|
|
1258
1404
|
__publicField(this, "initialLatLngs", null);
|
|
1259
1405
|
__publicField(this, "startAngle", 0);
|
|
1406
|
+
__publicField(this, "originalPathStyle", null);
|
|
1260
1407
|
}
|
|
1261
1408
|
enable() {
|
|
1262
1409
|
this.store.getGroup().eachLayer((layer) => {
|
|
@@ -1286,10 +1433,16 @@ var RotateMode = class {
|
|
|
1286
1433
|
const bounds = pathLayer.getBounds();
|
|
1287
1434
|
this.centerLatLng = bounds.getCenter();
|
|
1288
1435
|
this.initialLatLngs = JSON.parse(JSON.stringify(pathLayer.getLatLngs()));
|
|
1436
|
+
this.originalPathStyle = { ...pathLayer.options };
|
|
1289
1437
|
const point2 = this.map.latLngToContainerPoint(e.latlng);
|
|
1290
1438
|
const centerPoint = this.map.latLngToContainerPoint(this.centerLatLng);
|
|
1291
1439
|
this.startAngle = Math.atan2(point2.y - centerPoint.y, point2.x - centerPoint.x);
|
|
1292
|
-
pathLayer.setStyle(
|
|
1440
|
+
pathLayer.setStyle(
|
|
1441
|
+
getModeSelectionPathOptions(this.options, "rotate" /* Rotate */, this.originalPathStyle, {
|
|
1442
|
+
weight: 4,
|
|
1443
|
+
color: "#ffcc00"
|
|
1444
|
+
})
|
|
1445
|
+
);
|
|
1293
1446
|
this.map.on("mousemove", this.onMouseMove, this);
|
|
1294
1447
|
this.map.on("mouseup", this.onMouseUp, this);
|
|
1295
1448
|
this.map.dragging.disable();
|
|
@@ -1319,7 +1472,7 @@ var RotateMode = class {
|
|
|
1319
1472
|
}
|
|
1320
1473
|
onMouseUp() {
|
|
1321
1474
|
if (this.selectedLayer) {
|
|
1322
|
-
this.selectedLayer.setStyle(
|
|
1475
|
+
this.selectedLayer.setStyle(this.originalPathStyle || {});
|
|
1323
1476
|
this.map.fire(ANVIL_EVENTS.EDITED, { layer: this.selectedLayer });
|
|
1324
1477
|
}
|
|
1325
1478
|
this.stopRotating();
|
|
@@ -1328,9 +1481,13 @@ var RotateMode = class {
|
|
|
1328
1481
|
this.map.off("mousemove", this.onMouseMove, this);
|
|
1329
1482
|
this.map.off("mouseup", this.onMouseUp, this);
|
|
1330
1483
|
this.map.dragging.enable();
|
|
1484
|
+
if (this.selectedLayer && this.originalPathStyle) {
|
|
1485
|
+
this.selectedLayer.setStyle(this.originalPathStyle);
|
|
1486
|
+
}
|
|
1331
1487
|
this.selectedLayer = null;
|
|
1332
1488
|
this.centerLatLng = null;
|
|
1333
1489
|
this.initialLatLngs = null;
|
|
1490
|
+
this.originalPathStyle = null;
|
|
1334
1491
|
}
|
|
1335
1492
|
};
|
|
1336
1493
|
|
|
@@ -1343,6 +1500,7 @@ var UnionMode = class {
|
|
|
1343
1500
|
this.store = store;
|
|
1344
1501
|
this.options = options;
|
|
1345
1502
|
__publicField(this, "firstLayer", null);
|
|
1503
|
+
__publicField(this, "firstLayerStyle", null);
|
|
1346
1504
|
}
|
|
1347
1505
|
enable() {
|
|
1348
1506
|
this.store.getGroup().eachLayer((layer) => {
|
|
@@ -1366,7 +1524,13 @@ var UnionMode = class {
|
|
|
1366
1524
|
const layer = e.target;
|
|
1367
1525
|
if (!this.firstLayer) {
|
|
1368
1526
|
this.firstLayer = layer;
|
|
1369
|
-
this.
|
|
1527
|
+
this.firstLayerStyle = { ...layer.options };
|
|
1528
|
+
this.firstLayer.setStyle(
|
|
1529
|
+
getModeSelectionPathOptions(this.options, "union" /* Union */, this.firstLayerStyle, {
|
|
1530
|
+
color: "#ff00ff",
|
|
1531
|
+
weight: 4
|
|
1532
|
+
})
|
|
1533
|
+
);
|
|
1370
1534
|
return;
|
|
1371
1535
|
}
|
|
1372
1536
|
if (this.firstLayer === layer) {
|
|
@@ -1388,18 +1552,20 @@ var UnionMode = class {
|
|
|
1388
1552
|
const flattened = turf4.flatten(united);
|
|
1389
1553
|
flattened.features.forEach((f) => {
|
|
1390
1554
|
const newLayerGroup = L16.geoJSON(f, {
|
|
1391
|
-
style: this.options
|
|
1555
|
+
style: getModePathOptions(this.options, "union" /* Union */)
|
|
1392
1556
|
});
|
|
1393
1557
|
const l = newLayerGroup.getLayers()[0];
|
|
1394
1558
|
l.addTo(this.map);
|
|
1395
1559
|
this.map.fire(ANVIL_EVENTS.CREATED, { layer: l });
|
|
1396
1560
|
});
|
|
1397
1561
|
this.firstLayer = null;
|
|
1562
|
+
this.firstLayerStyle = null;
|
|
1398
1563
|
}
|
|
1399
1564
|
reset() {
|
|
1400
1565
|
if (this.firstLayer) {
|
|
1401
|
-
this.firstLayer.setStyle(
|
|
1566
|
+
this.firstLayer.setStyle(this.firstLayerStyle || {});
|
|
1402
1567
|
this.firstLayer = null;
|
|
1568
|
+
this.firstLayerStyle = null;
|
|
1403
1569
|
}
|
|
1404
1570
|
}
|
|
1405
1571
|
};
|
|
@@ -1413,6 +1579,7 @@ var SubtractMode = class {
|
|
|
1413
1579
|
this.store = store;
|
|
1414
1580
|
this.options = options;
|
|
1415
1581
|
__publicField(this, "baseLayer", null);
|
|
1582
|
+
__publicField(this, "baseLayerStyle", null);
|
|
1416
1583
|
}
|
|
1417
1584
|
enable() {
|
|
1418
1585
|
this.store.getGroup().eachLayer((layer) => {
|
|
@@ -1436,7 +1603,13 @@ var SubtractMode = class {
|
|
|
1436
1603
|
const layer = e.target;
|
|
1437
1604
|
if (!this.baseLayer) {
|
|
1438
1605
|
this.baseLayer = layer;
|
|
1439
|
-
this.
|
|
1606
|
+
this.baseLayerStyle = { ...layer.options };
|
|
1607
|
+
this.baseLayer.setStyle(
|
|
1608
|
+
getModeSelectionPathOptions(this.options, "subtract" /* Subtract */, this.baseLayerStyle, {
|
|
1609
|
+
color: "#ff0000",
|
|
1610
|
+
weight: 4
|
|
1611
|
+
})
|
|
1612
|
+
);
|
|
1440
1613
|
return;
|
|
1441
1614
|
}
|
|
1442
1615
|
if (this.baseLayer === layer) {
|
|
@@ -1453,18 +1626,22 @@ var SubtractMode = class {
|
|
|
1453
1626
|
if (diff) {
|
|
1454
1627
|
const flattened = turf5.flatten(diff);
|
|
1455
1628
|
flattened.features.forEach((f) => {
|
|
1456
|
-
const newLayerGroup = L17.geoJSON(f
|
|
1629
|
+
const newLayerGroup = L17.geoJSON(f, {
|
|
1630
|
+
style: getModePathOptions(this.options, "subtract" /* Subtract */)
|
|
1631
|
+
});
|
|
1457
1632
|
const l = newLayerGroup.getLayers()[0];
|
|
1458
1633
|
l.addTo(this.map);
|
|
1459
1634
|
this.map.fire(ANVIL_EVENTS.CREATED, { layer: l });
|
|
1460
1635
|
});
|
|
1461
1636
|
}
|
|
1462
1637
|
this.baseLayer = null;
|
|
1638
|
+
this.baseLayerStyle = null;
|
|
1463
1639
|
}
|
|
1464
1640
|
reset() {
|
|
1465
1641
|
if (this.baseLayer) {
|
|
1466
|
-
this.baseLayer.setStyle(
|
|
1642
|
+
this.baseLayer.setStyle(this.baseLayerStyle || {});
|
|
1467
1643
|
this.baseLayer = null;
|
|
1644
|
+
this.baseLayerStyle = null;
|
|
1468
1645
|
}
|
|
1469
1646
|
}
|
|
1470
1647
|
};
|
|
@@ -1481,6 +1658,7 @@ var EditMode = class {
|
|
|
1481
1658
|
__publicField(this, "ghostMarker", null);
|
|
1482
1659
|
__publicField(this, "segments", []);
|
|
1483
1660
|
__publicField(this, "_isDragging", false);
|
|
1661
|
+
__publicField(this, "originalLayerStyles", /* @__PURE__ */ new Map());
|
|
1484
1662
|
}
|
|
1485
1663
|
enable() {
|
|
1486
1664
|
this.store.getGroup().eachLayer((layer) => {
|
|
@@ -1499,13 +1677,11 @@ var EditMode = class {
|
|
|
1499
1677
|
layer.off("click", this.onLayerClick, this);
|
|
1500
1678
|
layer.off("mousemove", this.onMouseMove, this);
|
|
1501
1679
|
layer.getElement()?.style.setProperty("cursor", "");
|
|
1502
|
-
if (layer instanceof L18.Path) {
|
|
1503
|
-
layer.setStyle({ color: "#3388ff", weight: 3, fillOpacity: 0.2 });
|
|
1504
|
-
}
|
|
1505
1680
|
}
|
|
1506
1681
|
});
|
|
1507
1682
|
this.map.off("click", this.onMapClick, this);
|
|
1508
1683
|
this.map.off("mousemove", this.onMouseMove, this);
|
|
1684
|
+
this.restoreAllPathStyles();
|
|
1509
1685
|
this.clearMarkers();
|
|
1510
1686
|
this.activeLayers.clear();
|
|
1511
1687
|
}
|
|
@@ -1515,27 +1691,26 @@ var EditMode = class {
|
|
|
1515
1691
|
const isMultiSelect = e.originalEvent.shiftKey || this.options.magnetic;
|
|
1516
1692
|
if (!isMultiSelect) {
|
|
1517
1693
|
if (this.activeLayers.has(layer) && this.activeLayers.size === 1) return;
|
|
1518
|
-
this.
|
|
1519
|
-
if (l instanceof L18.Path) l.setStyle({ color: "#3388ff", weight: 3 });
|
|
1520
|
-
});
|
|
1694
|
+
this.restoreAllPathStyles();
|
|
1521
1695
|
this.clearMarkers();
|
|
1522
1696
|
this.activeLayers.clear();
|
|
1523
1697
|
this.activeLayers.add(layer);
|
|
1524
1698
|
} else {
|
|
1525
1699
|
if (this.activeLayers.has(layer)) {
|
|
1526
1700
|
this.activeLayers.delete(layer);
|
|
1527
|
-
if (layer instanceof L18.Path)
|
|
1701
|
+
if (layer instanceof L18.Path) this.restorePathStyle(layer);
|
|
1528
1702
|
} else {
|
|
1529
1703
|
this.activeLayers.add(layer);
|
|
1530
1704
|
}
|
|
1531
1705
|
this.clearMarkers();
|
|
1532
1706
|
}
|
|
1533
1707
|
this.activeLayers.forEach((l) => {
|
|
1534
|
-
if (l instanceof L18.Path)
|
|
1708
|
+
if (l instanceof L18.Path) this.applySelectionStyle(l);
|
|
1535
1709
|
});
|
|
1536
1710
|
this.createMarkers();
|
|
1537
1711
|
}
|
|
1538
1712
|
onMapClick() {
|
|
1713
|
+
this.restoreAllPathStyles();
|
|
1539
1714
|
this.clearMarkers();
|
|
1540
1715
|
this.activeLayers.clear();
|
|
1541
1716
|
}
|
|
@@ -1590,17 +1765,17 @@ var EditMode = class {
|
|
|
1590
1765
|
});
|
|
1591
1766
|
this.segments = Array.from(segmentMap.values());
|
|
1592
1767
|
vertexMap.forEach((group) => {
|
|
1593
|
-
const
|
|
1594
|
-
group.marker =
|
|
1595
|
-
this.markers.push(
|
|
1596
|
-
|
|
1768
|
+
const marker3 = this.createEditMarker(group.latlng);
|
|
1769
|
+
group.marker = marker3;
|
|
1770
|
+
this.markers.push(marker3);
|
|
1771
|
+
marker3.on("dragstart", () => {
|
|
1597
1772
|
this._isDragging = true;
|
|
1598
1773
|
});
|
|
1599
|
-
|
|
1774
|
+
marker3.on("drag", (e) => {
|
|
1600
1775
|
const mouseEvent = e;
|
|
1601
1776
|
const skipLayersArray = Array.from(this.activeLayers);
|
|
1602
1777
|
const additionalPoints = [
|
|
1603
|
-
...this.markers.filter((m) => m !==
|
|
1778
|
+
...this.markers.filter((m) => m !== marker3).map((m) => m.getLatLng()),
|
|
1604
1779
|
...Array.from(this.activeLayers).filter((l) => l instanceof L18.Marker).map((l) => l.getLatLng())
|
|
1605
1780
|
];
|
|
1606
1781
|
const snapped = getSnapLatLng(this.map, mouseEvent.latlng, this.store, this.options, additionalPoints, skipLayersArray);
|
|
@@ -1621,7 +1796,7 @@ var EditMode = class {
|
|
|
1621
1796
|
});
|
|
1622
1797
|
if (wouldIntersect) return;
|
|
1623
1798
|
}
|
|
1624
|
-
|
|
1799
|
+
marker3.setLatLng(snapped);
|
|
1625
1800
|
group.latlng = snapped;
|
|
1626
1801
|
group.refs.forEach((ref) => {
|
|
1627
1802
|
const fullStructure = ref.layer.getLatLngs();
|
|
@@ -1634,12 +1809,12 @@ var EditMode = class {
|
|
|
1634
1809
|
ref.layer.redraw();
|
|
1635
1810
|
});
|
|
1636
1811
|
});
|
|
1637
|
-
|
|
1812
|
+
marker3.on("dragend", () => {
|
|
1638
1813
|
this._isDragging = false;
|
|
1639
1814
|
this.activeLayers.forEach((l) => this.map.fire(ANVIL_EVENTS.EDITED, { layer: l }));
|
|
1640
1815
|
this.refreshMarkers();
|
|
1641
1816
|
});
|
|
1642
|
-
|
|
1817
|
+
marker3.on("contextmenu", (e) => {
|
|
1643
1818
|
const mouseEvent = e;
|
|
1644
1819
|
L18.DomEvent.stopPropagation(mouseEvent);
|
|
1645
1820
|
this.deleteVertex(group);
|
|
@@ -1668,6 +1843,9 @@ var EditMode = class {
|
|
|
1668
1843
|
});
|
|
1669
1844
|
layersToDelete.forEach((layer) => {
|
|
1670
1845
|
this.activeLayers.delete(layer);
|
|
1846
|
+
if (layer instanceof L18.Path) {
|
|
1847
|
+
this.originalLayerStyles.delete(layer);
|
|
1848
|
+
}
|
|
1671
1849
|
this.map.removeLayer(layer);
|
|
1672
1850
|
this.map.fire(ANVIL_EVENTS.DELETED, { layer });
|
|
1673
1851
|
});
|
|
@@ -1709,14 +1887,15 @@ var EditMode = class {
|
|
|
1709
1887
|
}
|
|
1710
1888
|
}
|
|
1711
1889
|
createEditMarker(latlng) {
|
|
1890
|
+
const visuals = this.getEditHandleVisuals();
|
|
1712
1891
|
return L18.marker(latlng, {
|
|
1713
1892
|
draggable: true,
|
|
1714
1893
|
zIndexOffset: 2e3,
|
|
1715
1894
|
icon: L18.divIcon({
|
|
1716
1895
|
className: "anvil-edit-marker",
|
|
1717
|
-
html:
|
|
1718
|
-
iconSize: [
|
|
1719
|
-
iconAnchor: [
|
|
1896
|
+
html: this.createHandleHtml(visuals.size, visuals.fillColor, visuals.borderColor, visuals.borderWidth),
|
|
1897
|
+
iconSize: [visuals.size, visuals.size],
|
|
1898
|
+
iconAnchor: [visuals.size / 2, visuals.size / 2]
|
|
1720
1899
|
})
|
|
1721
1900
|
}).addTo(this.map);
|
|
1722
1901
|
}
|
|
@@ -1728,15 +1907,16 @@ var EditMode = class {
|
|
|
1728
1907
|
}
|
|
1729
1908
|
return;
|
|
1730
1909
|
}
|
|
1910
|
+
const visuals = this.getGhostHandleVisuals();
|
|
1731
1911
|
this.ghostMarker = L18.marker(latlng, {
|
|
1732
1912
|
draggable: true,
|
|
1733
1913
|
opacity: 0.7,
|
|
1734
1914
|
zIndexOffset: 3e3,
|
|
1735
1915
|
icon: L18.divIcon({
|
|
1736
1916
|
className: "anvil-ghost-marker",
|
|
1737
|
-
html:
|
|
1738
|
-
iconSize: [
|
|
1739
|
-
iconAnchor: [
|
|
1917
|
+
html: this.createHandleHtml(visuals.size, visuals.fillColor, visuals.borderColor, visuals.borderWidth),
|
|
1918
|
+
iconSize: [visuals.size, visuals.size],
|
|
1919
|
+
iconAnchor: [visuals.size / 2, visuals.size / 2]
|
|
1740
1920
|
})
|
|
1741
1921
|
}).addTo(this.map);
|
|
1742
1922
|
this.ghostMarker.on("dragstart", () => {
|
|
@@ -1805,47 +1985,48 @@ var EditMode = class {
|
|
|
1805
1985
|
this.ghostMarker = null;
|
|
1806
1986
|
}
|
|
1807
1987
|
}
|
|
1808
|
-
handleMarkerEdit(
|
|
1809
|
-
|
|
1810
|
-
|
|
1988
|
+
handleMarkerEdit(marker3) {
|
|
1989
|
+
marker3.dragging?.enable();
|
|
1990
|
+
marker3.on("drag", (e) => {
|
|
1811
1991
|
const mouseEvent = e;
|
|
1812
1992
|
const additionalPoints = this.markers.map((m) => m.getLatLng());
|
|
1813
|
-
const snapped = getSnapLatLng(this.map, mouseEvent.latlng, this.store, this.options, additionalPoints,
|
|
1814
|
-
|
|
1993
|
+
const snapped = getSnapLatLng(this.map, mouseEvent.latlng, this.store, this.options, additionalPoints, marker3);
|
|
1994
|
+
marker3.setLatLng(snapped);
|
|
1815
1995
|
});
|
|
1816
|
-
|
|
1817
|
-
this.map.fire(ANVIL_EVENTS.EDITED, { layer:
|
|
1996
|
+
marker3.on("dragend", () => {
|
|
1997
|
+
this.map.fire(ANVIL_EVENTS.EDITED, { layer: marker3 });
|
|
1818
1998
|
});
|
|
1819
|
-
|
|
1999
|
+
marker3.on("contextmenu", (e) => {
|
|
1820
2000
|
const mouseEvent = e;
|
|
1821
2001
|
L18.DomEvent.stopPropagation(mouseEvent);
|
|
1822
|
-
this.activeLayers.delete(
|
|
1823
|
-
this.map.removeLayer(
|
|
1824
|
-
this.map.fire(ANVIL_EVENTS.DELETED, { layer:
|
|
2002
|
+
this.activeLayers.delete(marker3);
|
|
2003
|
+
this.map.removeLayer(marker3);
|
|
2004
|
+
this.map.fire(ANVIL_EVENTS.DELETED, { layer: marker3 });
|
|
1825
2005
|
this.refreshMarkers();
|
|
1826
2006
|
});
|
|
1827
2007
|
}
|
|
1828
2008
|
handleCircleEdit(circle2) {
|
|
1829
|
-
const
|
|
1830
|
-
|
|
2009
|
+
const marker3 = this.createEditMarker(circle2.getLatLng());
|
|
2010
|
+
marker3.on("drag", (e) => {
|
|
1831
2011
|
const mouseEvent = e;
|
|
1832
|
-
const additionalPoints = this.markers.filter((m) => m !==
|
|
2012
|
+
const additionalPoints = this.markers.filter((m) => m !== marker3).map((m) => m.getLatLng());
|
|
1833
2013
|
const snapped = getSnapLatLng(this.map, mouseEvent.latlng, this.store, this.options, additionalPoints, circle2);
|
|
1834
|
-
|
|
2014
|
+
marker3.setLatLng(snapped);
|
|
1835
2015
|
circle2.setLatLng(snapped);
|
|
1836
2016
|
});
|
|
1837
|
-
|
|
2017
|
+
marker3.on("dragend", () => {
|
|
1838
2018
|
this.map.fire(ANVIL_EVENTS.EDITED, { layer: circle2 });
|
|
1839
2019
|
});
|
|
1840
|
-
|
|
2020
|
+
marker3.on("contextmenu", (e) => {
|
|
1841
2021
|
const mouseEvent = e;
|
|
1842
2022
|
L18.DomEvent.stopPropagation(mouseEvent);
|
|
1843
2023
|
this.activeLayers.delete(circle2);
|
|
2024
|
+
this.originalLayerStyles.delete(circle2);
|
|
1844
2025
|
this.map.removeLayer(circle2);
|
|
1845
2026
|
this.map.fire(ANVIL_EVENTS.DELETED, { layer: circle2 });
|
|
1846
2027
|
this.refreshMarkers();
|
|
1847
2028
|
});
|
|
1848
|
-
this.markers.push(
|
|
2029
|
+
this.markers.push(marker3);
|
|
1849
2030
|
}
|
|
1850
2031
|
clearMarkers() {
|
|
1851
2032
|
this.activeLayers.forEach((layer) => {
|
|
@@ -1864,6 +2045,64 @@ var EditMode = class {
|
|
|
1864
2045
|
this.clearMarkers();
|
|
1865
2046
|
this.createMarkers();
|
|
1866
2047
|
}
|
|
2048
|
+
applySelectionStyle(layer) {
|
|
2049
|
+
if (!this.originalLayerStyles.has(layer)) {
|
|
2050
|
+
this.originalLayerStyles.set(layer, { ...layer.options });
|
|
2051
|
+
}
|
|
2052
|
+
layer.setStyle(
|
|
2053
|
+
getModeSelectionPathOptions(this.options, "edit" /* Edit */, this.originalLayerStyles.get(layer) || {}, {
|
|
2054
|
+
color: "#ff00ff",
|
|
2055
|
+
weight: 4
|
|
2056
|
+
})
|
|
2057
|
+
);
|
|
2058
|
+
}
|
|
2059
|
+
restorePathStyle(layer) {
|
|
2060
|
+
const original = this.originalLayerStyles.get(layer);
|
|
2061
|
+
if (!original) return;
|
|
2062
|
+
layer.setStyle(original);
|
|
2063
|
+
this.originalLayerStyles.delete(layer);
|
|
2064
|
+
}
|
|
2065
|
+
restoreAllPathStyles() {
|
|
2066
|
+
this.originalLayerStyles.forEach((style, layer) => {
|
|
2067
|
+
layer.setStyle(style);
|
|
2068
|
+
});
|
|
2069
|
+
this.originalLayerStyles.clear();
|
|
2070
|
+
}
|
|
2071
|
+
getEditHandleVisuals() {
|
|
2072
|
+
const selection = getModeSelectionPathOptions(this.options, "edit" /* Edit */, {}, { color: "#ff00ff" });
|
|
2073
|
+
const handle = getModeHandleOptions(this.options, "edit" /* Edit */, {
|
|
2074
|
+
radius: 6,
|
|
2075
|
+
color: selection.color || "#ff00ff",
|
|
2076
|
+
fillColor: "#fff",
|
|
2077
|
+
fillOpacity: 1,
|
|
2078
|
+
weight: 2
|
|
2079
|
+
});
|
|
2080
|
+
return {
|
|
2081
|
+
size: (handle.radius || 6) * 2,
|
|
2082
|
+
fillColor: handle.fillColor || "#fff",
|
|
2083
|
+
borderColor: handle.color || (selection.color || "#ff00ff"),
|
|
2084
|
+
borderWidth: handle.weight || 2
|
|
2085
|
+
};
|
|
2086
|
+
}
|
|
2087
|
+
getGhostHandleVisuals() {
|
|
2088
|
+
const selection = getModeSelectionPathOptions(this.options, "edit" /* Edit */, {}, { color: "#ff00ff" });
|
|
2089
|
+
const handle = getModeHandleOptions(this.options, "edit" /* Edit */, {
|
|
2090
|
+
radius: 5,
|
|
2091
|
+
color: "#fff",
|
|
2092
|
+
fillColor: selection.color || "#ff00ff",
|
|
2093
|
+
fillOpacity: 1,
|
|
2094
|
+
weight: 2
|
|
2095
|
+
});
|
|
2096
|
+
return {
|
|
2097
|
+
size: (handle.radius || 5) * 2,
|
|
2098
|
+
fillColor: handle.fillColor || (selection.color || "#ff00ff"),
|
|
2099
|
+
borderColor: handle.color || "#fff",
|
|
2100
|
+
borderWidth: handle.weight || 2
|
|
2101
|
+
};
|
|
2102
|
+
}
|
|
2103
|
+
createHandleHtml(size, fillColor, borderColor, borderWidth) {
|
|
2104
|
+
return `<div style="width: ${size}px; height: ${size}px; background: ${fillColor}; border: ${borderWidth}px solid ${borderColor}; border-radius: 50%; box-sizing: border-box; box-shadow: 0 0 4px rgba(0,0,0,0.3);"></div>`;
|
|
2105
|
+
}
|
|
1867
2106
|
};
|
|
1868
2107
|
|
|
1869
2108
|
// src/modes/delete-mode.ts
|
|
@@ -1938,45 +2177,117 @@ var LayerStore = class {
|
|
|
1938
2177
|
|
|
1939
2178
|
// src/controls/anvil-control.ts
|
|
1940
2179
|
import * as L21 from "leaflet";
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
}
|
|
2180
|
+
import {
|
|
2181
|
+
Circle as Circle6,
|
|
2182
|
+
Hand,
|
|
2183
|
+
MapPin,
|
|
2184
|
+
Move,
|
|
2185
|
+
Pentagon,
|
|
2186
|
+
Power,
|
|
2187
|
+
RectangleHorizontal,
|
|
2188
|
+
RotateCw,
|
|
2189
|
+
Scaling,
|
|
2190
|
+
Scissors,
|
|
2191
|
+
Split,
|
|
2192
|
+
Square,
|
|
2193
|
+
SquarePen,
|
|
2194
|
+
SquaresSubtract,
|
|
2195
|
+
SquaresUnite,
|
|
2196
|
+
Trash2,
|
|
2197
|
+
Triangle,
|
|
2198
|
+
Waypoints,
|
|
2199
|
+
createElement
|
|
2200
|
+
} from "lucide";
|
|
2201
|
+
var ANVIL_TOOLBAR_STYLE_ID = "anvil-toolbar-styles";
|
|
2202
|
+
var MODE_CONFIGS = [
|
|
2203
|
+
{ id: "marker" /* Marker */, title: "Marker", icon: MapPin },
|
|
2204
|
+
{ id: "polyline" /* Polyline */, title: "Line", icon: Waypoints },
|
|
2205
|
+
{ id: "polygon" /* Polygon */, title: "Polygon", icon: Pentagon },
|
|
2206
|
+
{ id: "rectangle" /* Rectangle */, title: "Rectangle", icon: RectangleHorizontal },
|
|
2207
|
+
{ id: "square" /* Square */, title: "Square", icon: Square },
|
|
2208
|
+
{ id: "triangle" /* Triangle */, title: "Triangle", icon: Triangle },
|
|
2209
|
+
{ id: "circle" /* Circle */, title: "Circle", icon: Circle6 },
|
|
2210
|
+
{ id: "freehand" /* Freehand */, title: "Freehand", icon: Hand },
|
|
2211
|
+
{ id: "cut" /* Cut */, title: "Cut", icon: Scissors },
|
|
2212
|
+
{ id: "split" /* Split */, title: "Split", icon: Split },
|
|
2213
|
+
{ id: "union" /* Union */, title: "Union", icon: SquaresUnite },
|
|
2214
|
+
{ id: "subtract" /* Subtract */, title: "Subtract", icon: SquaresSubtract },
|
|
2215
|
+
{ id: "drag" /* Drag */, title: "Drag", icon: Move },
|
|
2216
|
+
{ id: "scale" /* Scale */, title: "Scale", icon: Scaling },
|
|
2217
|
+
{ id: "rotate" /* Rotate */, title: "Rotate", icon: RotateCw },
|
|
2218
|
+
{ id: "edit" /* Edit */, title: "Edit", icon: SquarePen },
|
|
2219
|
+
{ id: "delete" /* Delete */, title: "Delete", icon: Trash2 },
|
|
2220
|
+
{ id: "off" /* Off */, title: "Turn Off", icon: Power }
|
|
2221
|
+
];
|
|
2222
|
+
function ensureToolbarStyles() {
|
|
2223
|
+
if (typeof document === "undefined" || document.getElementById(ANVIL_TOOLBAR_STYLE_ID)) return;
|
|
2224
|
+
const style = document.createElement("style");
|
|
2225
|
+
style.id = ANVIL_TOOLBAR_STYLE_ID;
|
|
2226
|
+
style.textContent = `
|
|
2227
|
+
.anvil-toolbar-container {
|
|
2228
|
+
display: flex;
|
|
2229
|
+
flex-direction: column;
|
|
2230
|
+
gap: 8px;
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2233
|
+
.anvil-toolbar-group {
|
|
2234
|
+
overflow: hidden;
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
.anvil-toolbar-group .anvil-control-btn {
|
|
2238
|
+
display: flex;
|
|
2239
|
+
align-items: center;
|
|
2240
|
+
justify-content: center;
|
|
2241
|
+
width: 30px;
|
|
2242
|
+
height: 30px;
|
|
2243
|
+
color: #2f3b52;
|
|
2244
|
+
transition: background-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2247
|
+
.anvil-toolbar-group .anvil-control-btn svg {
|
|
2248
|
+
width: 16px;
|
|
2249
|
+
height: 16px;
|
|
2250
|
+
stroke-width: 2.1;
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
.anvil-toolbar-group .anvil-control-btn:hover,
|
|
2254
|
+
.anvil-toolbar-group .anvil-control-btn:focus-visible {
|
|
2255
|
+
background-color: #f3f6fb;
|
|
2256
|
+
color: #0f172a;
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
.anvil-toolbar-group .anvil-control-btn:focus-visible {
|
|
2260
|
+
outline: none;
|
|
2261
|
+
box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.35);
|
|
2262
|
+
}
|
|
2263
|
+
|
|
2264
|
+
.anvil-toolbar-group .anvil-control-btn.is-active {
|
|
2265
|
+
background-color: #2563eb;
|
|
2266
|
+
color: #fff;
|
|
2267
|
+
box-shadow: inset 0 0 0 1px rgba(29, 78, 216, 0.45), 0 1px 3px rgba(37, 99, 235, 0.25);
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
.anvil-toolbar-group .anvil-control-btn.is-active:hover,
|
|
2271
|
+
.anvil-toolbar-group .anvil-control-btn.is-active:focus-visible {
|
|
2272
|
+
background-color: #1d4ed8;
|
|
2273
|
+
color: #fff;
|
|
2274
|
+
}
|
|
2275
|
+
`;
|
|
2276
|
+
document.head.appendChild(style);
|
|
2277
|
+
}
|
|
2278
|
+
function setButtonState(button, active) {
|
|
2279
|
+
button.classList.toggle("is-active", active);
|
|
2280
|
+
button.setAttribute("aria-pressed", active ? "true" : "false");
|
|
2281
|
+
}
|
|
2282
|
+
function buildIcon(iconNode) {
|
|
2283
|
+
return createElement(iconNode, {
|
|
2284
|
+
width: 16,
|
|
2285
|
+
height: 16,
|
|
2286
|
+
"stroke-width": 2.1,
|
|
2287
|
+
"aria-hidden": "true",
|
|
2288
|
+
focusable: "false"
|
|
2289
|
+
});
|
|
2290
|
+
}
|
|
1980
2291
|
var AnvilControl = class extends L21.Control {
|
|
1981
2292
|
constructor(anvil, options) {
|
|
1982
2293
|
super(L21.Util.extend({ position: "topleft" }, options));
|
|
@@ -1987,88 +2298,43 @@ var AnvilControl = class extends L21.Control {
|
|
|
1987
2298
|
this._options = { ...options };
|
|
1988
2299
|
}
|
|
1989
2300
|
onAdd(map) {
|
|
1990
|
-
|
|
2301
|
+
ensureToolbarStyles();
|
|
1991
2302
|
const container = L21.DomUtil.create("div", "anvil-toolbar-container");
|
|
1992
|
-
|
|
1993
|
-
container.style.flexDirection = "column";
|
|
1994
|
-
container.style.gap = "10px";
|
|
1995
|
-
const allModeConfigs = [
|
|
1996
|
-
{ id: "marker" /* Marker */, title: "Marker" },
|
|
1997
|
-
{ id: "polyline" /* Polyline */, title: "Line" },
|
|
1998
|
-
{ id: "polygon" /* Polygon */, title: "Polygon" },
|
|
1999
|
-
{ id: "rectangle" /* Rectangle */, title: "Rectangle" },
|
|
2000
|
-
{ id: "square" /* Square */, title: "Square" },
|
|
2001
|
-
{ id: "triangle" /* Triangle */, title: "Triangle" },
|
|
2002
|
-
{ id: "circle" /* Circle */, title: "Circle" },
|
|
2003
|
-
{ id: "freehand" /* Freehand */, title: "Freehand" },
|
|
2004
|
-
{ id: "cut" /* Cut */, title: "Cut" },
|
|
2005
|
-
{ id: "split" /* Split */, title: "Split" },
|
|
2006
|
-
{ id: "union" /* Union */, title: "Union" },
|
|
2007
|
-
{ id: "subtract" /* Subtract */, title: "Subtract" },
|
|
2008
|
-
{ id: "drag" /* Drag */, title: "Drag" },
|
|
2009
|
-
{ id: "scale" /* Scale */, title: "Scale" },
|
|
2010
|
-
{ id: "rotate" /* Rotate */, title: "Rotate" },
|
|
2011
|
-
{ id: "edit" /* Edit */, title: "Edit" },
|
|
2012
|
-
{ id: "delete" /* Delete */, title: "Delete" }
|
|
2013
|
-
];
|
|
2014
|
-
const modesInput = this._options.modes || allModeConfigs.map((m) => m.id);
|
|
2303
|
+
const modesInput = this._options.modes || MODE_CONFIGS.filter(({ id }) => id !== "off" /* Off */).map(({ id }) => id);
|
|
2015
2304
|
const blocks = Array.isArray(modesInput[0]) ? modesInput : [modesInput];
|
|
2305
|
+
const createButton = (group, config) => {
|
|
2306
|
+
const btn = L21.DomUtil.create("a", "anvil-control-btn", group);
|
|
2307
|
+
btn.href = "#";
|
|
2308
|
+
btn.title = config.title;
|
|
2309
|
+
btn.setAttribute("role", "button");
|
|
2310
|
+
btn.setAttribute("aria-label", config.title);
|
|
2311
|
+
btn.appendChild(buildIcon(config.icon));
|
|
2312
|
+
L21.DomEvent.disableClickPropagation(btn);
|
|
2313
|
+
L21.DomEvent.on(btn, "click", (e) => {
|
|
2314
|
+
L21.DomEvent.preventDefault(e);
|
|
2315
|
+
if (config.id === "off" /* Off */) {
|
|
2316
|
+
this._anvil.disable();
|
|
2317
|
+
} else {
|
|
2318
|
+
this._anvil.enable(config.id);
|
|
2319
|
+
}
|
|
2320
|
+
});
|
|
2321
|
+
this._btns[config.id] = btn;
|
|
2322
|
+
};
|
|
2016
2323
|
blocks.forEach((block, index) => {
|
|
2017
2324
|
const group = L21.DomUtil.create("div", "leaflet-bar anvil-toolbar-group", container);
|
|
2018
|
-
group.style.display = "flex";
|
|
2019
|
-
group.style.flexDirection = "column";
|
|
2020
|
-
group.style.backgroundColor = "white";
|
|
2021
2325
|
block.forEach((modeId) => {
|
|
2022
|
-
const config =
|
|
2023
|
-
if (!config
|
|
2024
|
-
|
|
2025
|
-
const title = config ? config.title : "Turn Off";
|
|
2026
|
-
const btn = L21.DomUtil.create("a", "anvil-control-btn", group);
|
|
2027
|
-
btn.innerHTML = ICONS[id] || title;
|
|
2028
|
-
btn.href = "#";
|
|
2029
|
-
btn.title = title;
|
|
2030
|
-
btn.style.display = "flex";
|
|
2031
|
-
btn.style.alignItems = "center";
|
|
2032
|
-
btn.style.justifyContent = "center";
|
|
2033
|
-
btn.style.width = "30px";
|
|
2034
|
-
btn.style.height = "30px";
|
|
2035
|
-
btn.style.color = "#333";
|
|
2036
|
-
btn.style.cursor = "pointer";
|
|
2037
|
-
L21.DomEvent.disableClickPropagation(btn);
|
|
2038
|
-
L21.DomEvent.on(btn, "click", (e) => {
|
|
2039
|
-
L21.DomEvent.preventDefault(e);
|
|
2040
|
-
if (id === "off" /* Off */) {
|
|
2041
|
-
this._anvil.disable();
|
|
2042
|
-
} else {
|
|
2043
|
-
this._anvil.enable(id);
|
|
2044
|
-
}
|
|
2045
|
-
});
|
|
2046
|
-
this._btns[id] = btn;
|
|
2326
|
+
const config = MODE_CONFIGS.find(({ id }) => id === modeId);
|
|
2327
|
+
if (!config) return;
|
|
2328
|
+
createButton(group, config);
|
|
2047
2329
|
});
|
|
2048
2330
|
if (index === blocks.length - 1 && !this._btns["off" /* Off */]) {
|
|
2049
|
-
|
|
2050
|
-
offBtn.innerHTML = ICONS["off" /* Off */];
|
|
2051
|
-
offBtn.href = "#";
|
|
2052
|
-
offBtn.title = "Turn Off";
|
|
2053
|
-
offBtn.style.display = "flex";
|
|
2054
|
-
offBtn.style.alignItems = "center";
|
|
2055
|
-
offBtn.style.justifyContent = "center";
|
|
2056
|
-
offBtn.style.width = "30px";
|
|
2057
|
-
offBtn.style.height = "30px";
|
|
2058
|
-
offBtn.style.color = "#333";
|
|
2059
|
-
offBtn.style.cursor = "pointer";
|
|
2060
|
-
L21.DomEvent.disableClickPropagation(offBtn);
|
|
2061
|
-
L21.DomEvent.on(offBtn, "click", (e) => {
|
|
2062
|
-
L21.DomEvent.preventDefault(e);
|
|
2063
|
-
this._anvil.disable();
|
|
2064
|
-
});
|
|
2065
|
-
this._btns["off" /* Off */] = offBtn;
|
|
2331
|
+
createButton(group, MODE_CONFIGS.find(({ id }) => id === "off" /* Off */));
|
|
2066
2332
|
}
|
|
2067
2333
|
});
|
|
2068
|
-
const updateFn = (
|
|
2334
|
+
const updateFn = (mode) => {
|
|
2069
2335
|
for (const id in this._btns) {
|
|
2070
|
-
const active = id ===
|
|
2071
|
-
this._btns[id]
|
|
2336
|
+
const active = id === mode || id === "off" /* Off */ && !mode;
|
|
2337
|
+
setButtonState(this._btns[id], active);
|
|
2072
2338
|
}
|
|
2073
2339
|
};
|
|
2074
2340
|
updateFn(null);
|