bbl-mapbox-react 0.0.16 → 0.0.18
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/components/BaseRenderer.d.ts +40 -1
- package/dist/components/CanvasCircleRenderer.d.ts +16 -1
- package/dist/components/CanvasImageRenderer.d.ts +17 -1
- package/dist/components/CanvasRadarRenderer.d.ts +13 -1
- package/dist/components/CircleRenderer.d.ts +21 -1
- package/dist/components/MarkerRenderer.d.ts +10 -1
- package/dist/components/MeasureControl.d.ts +3 -1
- package/dist/components/PolygonRenderer.d.ts +54 -1
- package/dist/components/PolylineRenderer.d.ts +18 -1
- package/dist/components/RectangleRenderer.d.ts +26 -1
- package/dist/components/RoutePlanningControl.d.ts +19 -0
- package/dist/components/SquareRenderer.d.ts +20 -1
- package/dist/index.cjs +5 -5
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +2197 -713
- package/dist/types.d.ts +67 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -408,7 +408,34 @@ var BaseCanvasRenderer = class {
|
|
|
408
408
|
destroy() {
|
|
409
409
|
this.isDestroyed = !0, this.map.getLayer(this.areaLayerId) && this.map.removeLayer(this.areaLayerId), this.map.getSource(this.areaSourceId) && this.map.removeSource(this.areaSourceId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getSource(this.labelSourceId) && this.map.removeSource(this.labelSourceId), this.map.getLayer(this.layerId) && this.map.removeLayer(this.layerId), this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId);
|
|
410
410
|
}
|
|
411
|
-
};
|
|
411
|
+
}, move_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1775030039452'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='24839'%20data-spm-anchor-id='a313x.search_index.0.i1.78953a81FCkAe0'%20width='64'%20height='64'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cpath%20d='M512%20938.666667l-170.666667-170.666667h341.333334l-170.666667%20170.666667z%20m0-853.333334l170.666667%20170.666667H341.333333l170.666667-170.666667z%20m0%20512a85.333333%2085.333333%200%201%201%200-170.666666%2085.333333%2085.333333%200%200%201%200%20170.666666zM85.333333%20512l170.666667-170.666667v341.333334l-170.666667-170.666667z%20m853.333334%200l-170.666667%20170.666667V341.333333l170.666667%20170.666667z'%20fill='%23ffffff'%20p-id='24840'%3e%3c/path%3e%3c/svg%3e";
|
|
412
|
+
const MOVE_ICON_ID = "__edit-move-icon__";
|
|
413
|
+
var _moveIconLoading = !1;
|
|
414
|
+
function ensureMoveIcon(e) {
|
|
415
|
+
if (e.hasImage("__edit-move-icon__") || _moveIconLoading) return;
|
|
416
|
+
_moveIconLoading = !0;
|
|
417
|
+
let t = new Image();
|
|
418
|
+
t.onload = () => {
|
|
419
|
+
if (e.hasImage("__edit-move-icon__")) {
|
|
420
|
+
_moveIconLoading = !1;
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
let n = document.createElement("canvas");
|
|
424
|
+
n.width = 28, n.height = 28;
|
|
425
|
+
let r = n.getContext("2d");
|
|
426
|
+
r.beginPath(), r.arc(28 / 2, 28 / 2, 28 / 2, 0, Math.PI * 2), r.fillStyle = "rgba(51,136,255,0.9)", r.fill();
|
|
427
|
+
let i = 28 * .6, a = (28 - i) / 2;
|
|
428
|
+
r.drawImage(t, a, a, i, i);
|
|
429
|
+
let o = r.getImageData(0, 0, 28, 28);
|
|
430
|
+
e.addImage(MOVE_ICON_ID, {
|
|
431
|
+
width: 28,
|
|
432
|
+
height: 28,
|
|
433
|
+
data: new Uint8Array(o.data.buffer)
|
|
434
|
+
}), _moveIconLoading = !1;
|
|
435
|
+
}, t.onerror = () => {
|
|
436
|
+
_moveIconLoading = !1;
|
|
437
|
+
}, t.src = move_default;
|
|
438
|
+
}
|
|
412
439
|
function calculateRadarBounds(e, t) {
|
|
413
440
|
let n = destinationPoint(e, t, 0), r = destinationPoint(e, t, 90), i = destinationPoint(e, t, 180), a = destinationPoint(e, t, 270)[0], o = r[0], s = i[1], c = n[1];
|
|
414
441
|
return [
|
|
@@ -420,7 +447,7 @@ function calculateRadarBounds(e, t) {
|
|
|
420
447
|
}
|
|
421
448
|
var CanvasRadarRenderer = class extends BaseCanvasRenderer {
|
|
422
449
|
constructor(e, t, n, r) {
|
|
423
|
-
super(e, t, "radar", n, r), this.animationFrameId = null, this.currentRotation = t.initialRotation ?? RADAR_DEFAULTS.initialRotation;
|
|
450
|
+
super(e, t, "radar", n, r), this.animationFrameId = null, this.isEditing = !1, this.editSourceId = "", this.editMoveLayerId = "", this.editSourceId = `radar-edit-source-${t.id}`, this.editMoveLayerId = `radar-edit-move-${t.id}`, this.currentRotation = t.initialRotation ?? RADAR_DEFAULTS.initialRotation;
|
|
424
451
|
let i = calculateRadarBounds(t.center, t.radius);
|
|
425
452
|
this.init(i), t.isAnimating && this.startAnimation();
|
|
426
453
|
}
|
|
@@ -480,7 +507,84 @@ var CanvasRadarRenderer = class extends BaseCanvasRenderer {
|
|
|
480
507
|
return Math.sqrt((r * a) ** 2 + (i * 110540) ** 2) <= n;
|
|
481
508
|
}
|
|
482
509
|
destroy() {
|
|
483
|
-
this.stopAnimation(), super.destroy();
|
|
510
|
+
this.removeEditLayers(), this.stopAnimation(), super.destroy();
|
|
511
|
+
}
|
|
512
|
+
getEditHandleGeoJSON(e) {
|
|
513
|
+
return {
|
|
514
|
+
type: "FeatureCollection",
|
|
515
|
+
features: [{
|
|
516
|
+
type: "Feature",
|
|
517
|
+
geometry: {
|
|
518
|
+
type: "Point",
|
|
519
|
+
coordinates: e ?? this.entity.center
|
|
520
|
+
},
|
|
521
|
+
properties: {
|
|
522
|
+
handleType: "move",
|
|
523
|
+
index: 0
|
|
524
|
+
}
|
|
525
|
+
}]
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
createEditLayers() {
|
|
529
|
+
this.map.getSource(this.editSourceId) || (ensureMoveIcon(this.map), this.map.addSource(this.editSourceId, {
|
|
530
|
+
type: "geojson",
|
|
531
|
+
data: this.getEditHandleGeoJSON()
|
|
532
|
+
}), this.map.addLayer({
|
|
533
|
+
id: this.editMoveLayerId,
|
|
534
|
+
type: "symbol",
|
|
535
|
+
source: this.editSourceId,
|
|
536
|
+
filter: [
|
|
537
|
+
"==",
|
|
538
|
+
["get", "handleType"],
|
|
539
|
+
"move"
|
|
540
|
+
],
|
|
541
|
+
layout: {
|
|
542
|
+
"icon-image": MOVE_ICON_ID,
|
|
543
|
+
"icon-allow-overlap": !0,
|
|
544
|
+
"icon-ignore-placement": !0
|
|
545
|
+
}
|
|
546
|
+
}));
|
|
547
|
+
}
|
|
548
|
+
removeEditLayers() {
|
|
549
|
+
this.map.getLayer(this.editMoveLayerId) && this.map.removeLayer(this.editMoveLayerId), this.map.getSource(this.editSourceId) && this.map.removeSource(this.editSourceId);
|
|
550
|
+
}
|
|
551
|
+
refreshEditHandles(e) {
|
|
552
|
+
let t = this.map.getSource(this.editSourceId);
|
|
553
|
+
t && t.setData(this.getEditHandleGeoJSON(e));
|
|
554
|
+
}
|
|
555
|
+
setEditing(e) {
|
|
556
|
+
this.isEditing !== e && (this.isEditing = e, e ? this.createEditLayers() : this.removeEditLayers());
|
|
557
|
+
}
|
|
558
|
+
getEditHandleAt(e, t) {
|
|
559
|
+
if (!this.isEditing) return null;
|
|
560
|
+
let n = this.entity.center, r = this.map.project(e), i = this.map.project(n), a = r.x - i.x, o = r.y - i.y;
|
|
561
|
+
return a * a + o * o <= 144 ? {
|
|
562
|
+
type: "move",
|
|
563
|
+
index: 0,
|
|
564
|
+
position: n
|
|
565
|
+
} : null;
|
|
566
|
+
}
|
|
567
|
+
applyHandleMove(e, t) {
|
|
568
|
+
let n = t[0] - e.position[0], r = t[1] - e.position[1], i = [this.entity.center[0] + n, this.entity.center[1] + r], a = {
|
|
569
|
+
...this.entity,
|
|
570
|
+
center: i
|
|
571
|
+
};
|
|
572
|
+
this.entity = a;
|
|
573
|
+
let o = calculateRadarBounds(i, this.entity.radius);
|
|
574
|
+
return this.updateSourceCoordinates(o), this.updateLabel(), this.refreshEditHandles(), a;
|
|
575
|
+
}
|
|
576
|
+
updateEditPreview(e, t) {
|
|
577
|
+
let n = t[0] - e.position[0], r = t[1] - e.position[1], i = [this.entity.center[0] + n, this.entity.center[1] + r], a = calculateRadarBounds(i, this.entity.radius);
|
|
578
|
+
this.updateSourceCoordinates(a);
|
|
579
|
+
let o = this.entity;
|
|
580
|
+
this.entity = {
|
|
581
|
+
...this.entity,
|
|
582
|
+
center: i
|
|
583
|
+
}, this.updateLabel(), this.entity = o, this.refreshEditHandles(i);
|
|
584
|
+
}
|
|
585
|
+
cancelEditPreview() {
|
|
586
|
+
let e = calculateRadarBounds(this.entity.center, this.entity.radius);
|
|
587
|
+
this.updateSourceCoordinates(e), this.updateLabel(), this.refreshEditHandles();
|
|
484
588
|
}
|
|
485
589
|
};
|
|
486
590
|
function calculateImageBounds(e, t, n) {
|
|
@@ -494,7 +598,7 @@ function calculateImageBounds(e, t, n) {
|
|
|
494
598
|
}
|
|
495
599
|
var CanvasImageRenderer = class extends BaseCanvasRenderer {
|
|
496
600
|
constructor(e, t, n, r) {
|
|
497
|
-
super(e, t, "image", n, r), this.loadedImage = null, this.imageLoaded = !1, this.currentSrc = "", this.imageAspectRatio = 1, this.loadImage(t.src, !0);
|
|
601
|
+
super(e, t, "image", n, r), this.loadedImage = null, this.imageLoaded = !1, this.currentSrc = "", this.imageAspectRatio = 1, this.isEditing = !1, this.editSourceId = "", this.editMoveLayerId = "", this.editSourceId = `image-edit-source-${t.id}`, this.editMoveLayerId = `image-edit-move-${t.id}`, this.loadImage(t.src, !0);
|
|
498
602
|
}
|
|
499
603
|
getSize() {
|
|
500
604
|
let { width: e } = this.entity, t = e / this.imageAspectRatio;
|
|
@@ -600,9 +704,89 @@ var CanvasImageRenderer = class extends BaseCanvasRenderer {
|
|
|
600
704
|
let { center: t } = this.entity, [n, r] = this.getSize(), i = e[0] - t[0], a = e[1] - t[1], o = 111320 * Math.cos(t[1] * Math.PI / 180), s = Math.abs(i * o), c = Math.abs(a * 110540);
|
|
601
705
|
return s <= n / 2 && c <= r / 2;
|
|
602
706
|
}
|
|
707
|
+
getEditHandleGeoJSON(e) {
|
|
708
|
+
return {
|
|
709
|
+
type: "FeatureCollection",
|
|
710
|
+
features: [{
|
|
711
|
+
type: "Feature",
|
|
712
|
+
geometry: {
|
|
713
|
+
type: "Point",
|
|
714
|
+
coordinates: e ?? this.entity.center
|
|
715
|
+
},
|
|
716
|
+
properties: {
|
|
717
|
+
handleType: "move",
|
|
718
|
+
index: 0
|
|
719
|
+
}
|
|
720
|
+
}]
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
createEditLayers() {
|
|
724
|
+
this.map.getSource(this.editSourceId) || (ensureMoveIcon(this.map), this.map.addSource(this.editSourceId, {
|
|
725
|
+
type: "geojson",
|
|
726
|
+
data: this.getEditHandleGeoJSON()
|
|
727
|
+
}), this.map.addLayer({
|
|
728
|
+
id: this.editMoveLayerId,
|
|
729
|
+
type: "symbol",
|
|
730
|
+
source: this.editSourceId,
|
|
731
|
+
filter: [
|
|
732
|
+
"==",
|
|
733
|
+
["get", "handleType"],
|
|
734
|
+
"move"
|
|
735
|
+
],
|
|
736
|
+
layout: {
|
|
737
|
+
"icon-image": MOVE_ICON_ID,
|
|
738
|
+
"icon-allow-overlap": !0,
|
|
739
|
+
"icon-ignore-placement": !0
|
|
740
|
+
}
|
|
741
|
+
}));
|
|
742
|
+
}
|
|
743
|
+
removeEditLayers() {
|
|
744
|
+
this.map.getLayer(this.editMoveLayerId) && this.map.removeLayer(this.editMoveLayerId), this.map.getSource(this.editSourceId) && this.map.removeSource(this.editSourceId);
|
|
745
|
+
}
|
|
746
|
+
refreshEditHandles(e) {
|
|
747
|
+
let t = this.map.getSource(this.editSourceId);
|
|
748
|
+
t && t.setData(this.getEditHandleGeoJSON(e));
|
|
749
|
+
}
|
|
750
|
+
setEditing(e) {
|
|
751
|
+
this.isEditing !== e && (this.isEditing = e, e ? this.createEditLayers() : this.removeEditLayers());
|
|
752
|
+
}
|
|
753
|
+
getEditHandleAt(e, t) {
|
|
754
|
+
if (!this.isEditing) return null;
|
|
755
|
+
let n = this.entity.center, r = this.map.project(e), i = this.map.project(n), a = r.x - i.x, o = r.y - i.y;
|
|
756
|
+
return a * a + o * o <= 144 ? {
|
|
757
|
+
type: "move",
|
|
758
|
+
index: 0,
|
|
759
|
+
position: n
|
|
760
|
+
} : null;
|
|
761
|
+
}
|
|
762
|
+
applyHandleMove(e, t) {
|
|
763
|
+
let n = t[0] - e.position[0], r = t[1] - e.position[1], i = [this.entity.center[0] + n, this.entity.center[1] + r], a = {
|
|
764
|
+
...this.entity,
|
|
765
|
+
center: i
|
|
766
|
+
};
|
|
767
|
+
this.entity = a;
|
|
768
|
+
let [o, s] = this.getSize(), c = calculateImageBounds(i, o, s);
|
|
769
|
+
return this.updateSourceCoordinates(c), this.updateLabel(), this.refreshEditHandles(), a;
|
|
770
|
+
}
|
|
771
|
+
updateEditPreview(e, t) {
|
|
772
|
+
let n = t[0] - e.position[0], r = t[1] - e.position[1], i = [this.entity.center[0] + n, this.entity.center[1] + r], [a, o] = this.getSize(), s = calculateImageBounds(i, a, o);
|
|
773
|
+
this.updateSourceCoordinates(s);
|
|
774
|
+
let c = this.entity;
|
|
775
|
+
this.entity = {
|
|
776
|
+
...this.entity,
|
|
777
|
+
center: i
|
|
778
|
+
}, this.updateLabel(), this.entity = c, this.refreshEditHandles(i);
|
|
779
|
+
}
|
|
780
|
+
cancelEditPreview() {
|
|
781
|
+
let [e, t] = this.getSize(), n = calculateImageBounds(this.entity.center, e, t);
|
|
782
|
+
this.updateSourceCoordinates(n), this.updateLabel(), this.refreshEditHandles();
|
|
783
|
+
}
|
|
784
|
+
destroy() {
|
|
785
|
+
this.removeEditLayers(), super.destroy();
|
|
786
|
+
}
|
|
603
787
|
}, MarkerRenderer = class {
|
|
604
788
|
constructor(e, t, n, r) {
|
|
605
|
-
this.marker = null, this.markerElement = null, this.imageElement = null, this.labelElement = null, this.placeholderElement = null, this.isSelected = !1, this.imageAspectRatio = 1, this.imageLoaded = !1, this.destroyed = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.loadImageAndCreateMarker(t.src);
|
|
789
|
+
this.marker = null, this.markerElement = null, this.imageElement = null, this.labelElement = null, this.placeholderElement = null, this.isSelected = !1, this.imageAspectRatio = 1, this.imageLoaded = !1, this.destroyed = !1, this.isEditing = !1, this.moveIconElement = null, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.loadImageAndCreateMarker(t.src);
|
|
606
790
|
}
|
|
607
791
|
loadImageAndCreateMarker(e) {
|
|
608
792
|
if (!e) {
|
|
@@ -674,7 +858,47 @@ var CanvasImageRenderer = class extends BaseCanvasRenderer {
|
|
|
674
858
|
(t.width !== e.width || t.rotation !== e.rotation || t.confidence !== e.confidence) && (this.imageElement.style.width = `${e.width}px`, this.imageElement.style.height = `${n}px`, this.imageElement.style.transform = `rotate(${r}deg)`, this.imageElement.style.opacity = `${i}`), t.name !== e.name && (e.name && !this.labelElement ? (this.labelElement = document.createElement("div"), this.labelElement.className = "mapbox-marker-label", this.labelElement.textContent = e.name, this.updateLabelStyle(), this.markerElement?.appendChild(this.labelElement), this.placeholderElement = document.createElement("div"), this.placeholderElement.className = "mapbox-marker-placeholder", this.placeholderElement.textContent = e.name, this.markerElement?.insertBefore(this.placeholderElement, this.markerElement.firstChild)) : !e.name && this.labelElement ? (this.labelElement.remove(), this.labelElement = null, this.placeholderElement?.remove(), this.placeholderElement = null) : this.labelElement && (this.labelElement.textContent = e.name || "", this.placeholderElement && (this.placeholderElement.textContent = e.name || ""))), t.confidence !== e.confidence && this.updateLabelStyle();
|
|
675
859
|
}
|
|
676
860
|
destroy() {
|
|
677
|
-
this.destroyed = !0, this.marker &&= (this.marker.remove(), null), this.markerElement = null, this.imageElement = null, this.labelElement = null, this.placeholderElement = null;
|
|
861
|
+
this.removeMoveIcon(), this.destroyed = !0, this.marker &&= (this.marker.remove(), null), this.markerElement = null, this.imageElement = null, this.labelElement = null, this.placeholderElement = null;
|
|
862
|
+
}
|
|
863
|
+
createMoveIcon() {
|
|
864
|
+
if (this.moveIconElement || !this.markerElement) return;
|
|
865
|
+
let e = document.createElement("div");
|
|
866
|
+
e.className = "mapbox-marker-move-icon", e.style.cssText = "width:28px;height:28px;border-radius:50%;background:rgba(51,136,255,0.9);display:flex;align-items:center;justify-content:center;cursor:move;position:absolute;left:50%;bottom:0;transform:translate(-50%,100%);pointer-events:none;";
|
|
867
|
+
let t = document.createElement("img");
|
|
868
|
+
t.src = move_default, t.style.cssText = "width:60%;height:60%;", e.appendChild(t), this.markerElement.appendChild(e), this.moveIconElement = e;
|
|
869
|
+
}
|
|
870
|
+
removeMoveIcon() {
|
|
871
|
+
this.moveIconElement &&= (this.moveIconElement.remove(), null);
|
|
872
|
+
}
|
|
873
|
+
setEditing(e) {
|
|
874
|
+
this.isEditing !== e && (this.isEditing = e, e ? this.createMoveIcon() : this.removeMoveIcon());
|
|
875
|
+
}
|
|
876
|
+
getEditHandleAt(e, t) {
|
|
877
|
+
if (!this.isEditing) return null;
|
|
878
|
+
let n = this.map.project(e);
|
|
879
|
+
if (this.moveIconElement) {
|
|
880
|
+
let t = this.moveIconElement.getBoundingClientRect(), r = this.map.getContainer().getBoundingClientRect(), i = t.left + t.width / 2 - r.left, a = t.top + t.height / 2 - r.top, o = n.x - i, s = n.y - a;
|
|
881
|
+
if (o * o + s * s <= 256) return {
|
|
882
|
+
type: "move",
|
|
883
|
+
index: 0,
|
|
884
|
+
position: e
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
return null;
|
|
888
|
+
}
|
|
889
|
+
applyHandleMove(e, t) {
|
|
890
|
+
let n = t[0] - e.position[0], r = t[1] - e.position[1], i = [this.entity.center[0] + n, this.entity.center[1] + r], a = {
|
|
891
|
+
...this.entity,
|
|
892
|
+
center: i
|
|
893
|
+
};
|
|
894
|
+
return this.entity = a, this.marker && this.marker.setLngLat(i), a;
|
|
895
|
+
}
|
|
896
|
+
updateEditPreview(e, t) {
|
|
897
|
+
let n = t[0] - e.position[0], r = t[1] - e.position[1], i = [this.entity.center[0] + n, this.entity.center[1] + r];
|
|
898
|
+
this.marker && this.marker.setLngLat(i);
|
|
899
|
+
}
|
|
900
|
+
cancelEditPreview() {
|
|
901
|
+
this.marker && this.marker.setLngLat(this.entity.center);
|
|
678
902
|
}
|
|
679
903
|
}, UnitRenderer = class extends MarkerRenderer {
|
|
680
904
|
constructor(e, t, n, r) {
|
|
@@ -840,7 +1064,7 @@ var CanvasImageRenderer = class extends BaseCanvasRenderer {
|
|
|
840
1064
|
};
|
|
841
1065
|
}
|
|
842
1066
|
constructor(e, t, n, r, i, a) {
|
|
843
|
-
this.isSelected = !1, this.initialized = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalAreaConfig = i, this.globalLengthConfig = a, this.sourceId = `polygon-source-${t.id}`, this.fillLayerId = `polygon-fill-${t.id}`, this.strokeLayerId = `polygon-stroke-${t.id}`, this.labelLayerId = `polygon-label-${t.id}`, this.areaLayerId = `polygon-area-${t.id}`, this.lengthLayerId = `polygon-length-${t.id}`, this.initLayers();
|
|
1067
|
+
this.isSelected = !1, this.initialized = !1, this.isEditing = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalAreaConfig = i, this.globalLengthConfig = a, this.sourceId = `polygon-source-${t.id}`, this.fillLayerId = `polygon-fill-${t.id}`, this.strokeLayerId = `polygon-stroke-${t.id}`, this.labelLayerId = `polygon-label-${t.id}`, this.areaLayerId = `polygon-area-${t.id}`, this.lengthLayerId = `polygon-length-${t.id}`, this.editSourceId = `polygon-edit-source-${t.id}`, this.editHandleLayerId = `polygon-edit-handles-${t.id}`, this.editMidpointLayerId = `polygon-edit-midpoints-${t.id}`, this.editMoveLayerId = `polygon-edit-move-${t.id}`, this.initLayers();
|
|
844
1068
|
}
|
|
845
1069
|
get nameStyle() {
|
|
846
1070
|
return resolveNameConfig(this.entity.nameConfig, this.globalNameConfig, DEFAULT_NAME_CONFIG);
|
|
@@ -1162,8 +1386,201 @@ var CanvasImageRenderer = class extends BaseCanvasRenderer {
|
|
|
1162
1386
|
}
|
|
1163
1387
|
(n.fillColor !== t.fillColor || n.fillOpacity !== t.fillOpacity || n.confidence !== t.confidence) && this.map.getLayer(this.fillLayerId) && (this.map.setPaintProperty(this.fillLayerId, "fill-color", t.fillColor ?? e.DEFAULTS.fillColor), this.map.setPaintProperty(this.fillLayerId, "fill-opacity", (t.fillOpacity ?? e.DEFAULTS.fillOpacity) * i)), (n.strokeColor !== t.strokeColor || n.strokeWidth !== t.strokeWidth || n.strokeOpacity !== t.strokeOpacity || n.confidence !== t.confidence) && this.map.getLayer(this.strokeLayerId) && (this.isSelected || this.map.setPaintProperty(this.strokeLayerId, "line-color", t.strokeColor ?? e.DEFAULTS.strokeColor), this.map.setPaintProperty(this.strokeLayerId, "line-width", t.strokeWidth ?? e.DEFAULTS.strokeWidth), this.map.setPaintProperty(this.strokeLayerId, "line-opacity", (t.strokeOpacity ?? e.DEFAULTS.strokeOpacity) * i)), n.confidence !== t.confidence && (this.map.getLayer(this.labelLayerId) && this.map.setPaintProperty(this.labelLayerId, "text-opacity", i), this.map.getLayer(this.areaLayerId) && this.map.setPaintProperty(this.areaLayerId, "text-opacity", i), this.map.getLayer(this.lengthLayerId) && this.map.setPaintProperty(this.lengthLayerId, "text-opacity", i));
|
|
1164
1388
|
}
|
|
1389
|
+
getEditHandleGeoJSON(e) {
|
|
1390
|
+
let t = e ?? this.entity.coordinates;
|
|
1391
|
+
if (!t || t.length < 3) return {
|
|
1392
|
+
type: "FeatureCollection",
|
|
1393
|
+
features: []
|
|
1394
|
+
};
|
|
1395
|
+
let n = [];
|
|
1396
|
+
for (let e = 0; e < t.length; e++) n.push({
|
|
1397
|
+
type: "Feature",
|
|
1398
|
+
geometry: {
|
|
1399
|
+
type: "Point",
|
|
1400
|
+
coordinates: t[e]
|
|
1401
|
+
},
|
|
1402
|
+
properties: {
|
|
1403
|
+
handleType: "vertex",
|
|
1404
|
+
index: e
|
|
1405
|
+
}
|
|
1406
|
+
});
|
|
1407
|
+
for (let e = 0; e < t.length; e++) {
|
|
1408
|
+
let r = t[e], i = t[(e + 1) % t.length];
|
|
1409
|
+
n.push({
|
|
1410
|
+
type: "Feature",
|
|
1411
|
+
geometry: {
|
|
1412
|
+
type: "Point",
|
|
1413
|
+
coordinates: [(r[0] + i[0]) / 2, (r[1] + i[1]) / 2]
|
|
1414
|
+
},
|
|
1415
|
+
properties: {
|
|
1416
|
+
handleType: "midpoint",
|
|
1417
|
+
index: e
|
|
1418
|
+
}
|
|
1419
|
+
});
|
|
1420
|
+
}
|
|
1421
|
+
let r = 0, i = 0;
|
|
1422
|
+
for (let e of t) r += e[0], i += e[1];
|
|
1423
|
+
return r /= t.length, i /= t.length, n.push({
|
|
1424
|
+
type: "Feature",
|
|
1425
|
+
geometry: {
|
|
1426
|
+
type: "Point",
|
|
1427
|
+
coordinates: [r, i]
|
|
1428
|
+
},
|
|
1429
|
+
properties: {
|
|
1430
|
+
handleType: "move",
|
|
1431
|
+
index: 0
|
|
1432
|
+
}
|
|
1433
|
+
}), {
|
|
1434
|
+
type: "FeatureCollection",
|
|
1435
|
+
features: n
|
|
1436
|
+
};
|
|
1437
|
+
}
|
|
1438
|
+
createEditLayers() {
|
|
1439
|
+
this.map.getSource(this.editSourceId) || (ensureMoveIcon(this.map), this.map.addSource(this.editSourceId, {
|
|
1440
|
+
type: "geojson",
|
|
1441
|
+
data: this.getEditHandleGeoJSON()
|
|
1442
|
+
}), this.map.addLayer({
|
|
1443
|
+
id: this.editMidpointLayerId,
|
|
1444
|
+
type: "circle",
|
|
1445
|
+
source: this.editSourceId,
|
|
1446
|
+
filter: [
|
|
1447
|
+
"==",
|
|
1448
|
+
["get", "handleType"],
|
|
1449
|
+
"midpoint"
|
|
1450
|
+
],
|
|
1451
|
+
paint: {
|
|
1452
|
+
"circle-radius": 4,
|
|
1453
|
+
"circle-color": "#3388ff",
|
|
1454
|
+
"circle-opacity": .5,
|
|
1455
|
+
"circle-stroke-color": "#3388ff",
|
|
1456
|
+
"circle-stroke-width": 1
|
|
1457
|
+
}
|
|
1458
|
+
}), this.map.addLayer({
|
|
1459
|
+
id: this.editHandleLayerId,
|
|
1460
|
+
type: "circle",
|
|
1461
|
+
source: this.editSourceId,
|
|
1462
|
+
filter: [
|
|
1463
|
+
"==",
|
|
1464
|
+
["get", "handleType"],
|
|
1465
|
+
"vertex"
|
|
1466
|
+
],
|
|
1467
|
+
paint: {
|
|
1468
|
+
"circle-radius": 6,
|
|
1469
|
+
"circle-color": "#ffffff",
|
|
1470
|
+
"circle-stroke-color": "#3388ff",
|
|
1471
|
+
"circle-stroke-width": 2
|
|
1472
|
+
}
|
|
1473
|
+
}), this.map.addLayer({
|
|
1474
|
+
id: this.editMoveLayerId,
|
|
1475
|
+
type: "symbol",
|
|
1476
|
+
source: this.editSourceId,
|
|
1477
|
+
filter: [
|
|
1478
|
+
"==",
|
|
1479
|
+
["get", "handleType"],
|
|
1480
|
+
"move"
|
|
1481
|
+
],
|
|
1482
|
+
layout: {
|
|
1483
|
+
"icon-image": MOVE_ICON_ID,
|
|
1484
|
+
"icon-allow-overlap": !0,
|
|
1485
|
+
"icon-ignore-placement": !0
|
|
1486
|
+
}
|
|
1487
|
+
}));
|
|
1488
|
+
}
|
|
1489
|
+
removeEditLayers() {
|
|
1490
|
+
this.map.getLayer(this.editMoveLayerId) && this.map.removeLayer(this.editMoveLayerId), this.map.getLayer(this.editHandleLayerId) && this.map.removeLayer(this.editHandleLayerId), this.map.getLayer(this.editMidpointLayerId) && this.map.removeLayer(this.editMidpointLayerId), this.map.getSource(this.editSourceId) && this.map.removeSource(this.editSourceId);
|
|
1491
|
+
}
|
|
1492
|
+
refreshEditHandles(e) {
|
|
1493
|
+
let t = this.map.getSource(this.editSourceId);
|
|
1494
|
+
t && t.setData(this.getEditHandleGeoJSON(e));
|
|
1495
|
+
}
|
|
1496
|
+
setEditing(e) {
|
|
1497
|
+
this.isEditing !== e && (this.isEditing = e, this.initialized && (e ? this.createEditLayers() : this.removeEditLayers()));
|
|
1498
|
+
}
|
|
1499
|
+
getEditHandleAt(e, t) {
|
|
1500
|
+
if (!this.isEditing) return null;
|
|
1501
|
+
let n = this.entity.coordinates;
|
|
1502
|
+
if (!n || n.length < 3) return null;
|
|
1503
|
+
let r = this.map.project(e), i = 0, a = 0;
|
|
1504
|
+
for (let e of n) i += e[0], a += e[1];
|
|
1505
|
+
i /= n.length, a /= n.length;
|
|
1506
|
+
let o = this.map.project([i, a]), s = r.x - o.x, c = r.y - o.y;
|
|
1507
|
+
if (s * s + c * c <= 144) return {
|
|
1508
|
+
type: "move",
|
|
1509
|
+
index: 0,
|
|
1510
|
+
position: [i, a]
|
|
1511
|
+
};
|
|
1512
|
+
for (let e = 0; e < n.length; e++) {
|
|
1513
|
+
let t = this.map.project(n[e]), i = r.x - t.x, a = r.y - t.y;
|
|
1514
|
+
if (i * i + a * a <= 100) return {
|
|
1515
|
+
type: "vertex",
|
|
1516
|
+
index: e,
|
|
1517
|
+
position: n[e]
|
|
1518
|
+
};
|
|
1519
|
+
}
|
|
1520
|
+
for (let e = 0; e < n.length; e++) {
|
|
1521
|
+
let t = n[e], i = n[(e + 1) % n.length], a = [(t[0] + i[0]) / 2, (t[1] + i[1]) / 2], o = this.map.project(a), s = r.x - o.x, c = r.y - o.y;
|
|
1522
|
+
if (s * s + c * c <= 100) return {
|
|
1523
|
+
type: "midpoint",
|
|
1524
|
+
index: e,
|
|
1525
|
+
position: a
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
1528
|
+
return null;
|
|
1529
|
+
}
|
|
1530
|
+
offsetCoordinates(e, t, n) {
|
|
1531
|
+
let r = n[0] - t[0], i = n[1] - t[1];
|
|
1532
|
+
return e.map((e) => [e[0] + r, e[1] + i]);
|
|
1533
|
+
}
|
|
1534
|
+
applyHandleMove(e, t) {
|
|
1535
|
+
let n;
|
|
1536
|
+
e.type === "move" ? n = this.offsetCoordinates(this.entity.coordinates, e.position, t) : (n = [...this.entity.coordinates], n[e.index] = t);
|
|
1537
|
+
let r = {
|
|
1538
|
+
...this.entity,
|
|
1539
|
+
coordinates: n
|
|
1540
|
+
};
|
|
1541
|
+
this.entity = r;
|
|
1542
|
+
let i = this.map.getSource(this.sourceId);
|
|
1543
|
+
return i && i.setData(this.getGeoJSON()), this.refreshEditHandles(), r;
|
|
1544
|
+
}
|
|
1545
|
+
updateEditPreview(e, t) {
|
|
1546
|
+
let n;
|
|
1547
|
+
e.type === "move" ? n = this.offsetCoordinates(this.entity.coordinates, e.position, t) : (n = [...this.entity.coordinates], n[e.index] = t);
|
|
1548
|
+
let r = this.entity;
|
|
1549
|
+
this.entity = {
|
|
1550
|
+
...this.entity,
|
|
1551
|
+
coordinates: n
|
|
1552
|
+
};
|
|
1553
|
+
let i = this.map.getSource(this.sourceId);
|
|
1554
|
+
i && i.setData(this.getGeoJSON()), this.entity = r, this.refreshEditHandles(n);
|
|
1555
|
+
}
|
|
1556
|
+
cancelEditPreview() {
|
|
1557
|
+
let e = this.map.getSource(this.sourceId);
|
|
1558
|
+
e && e.setData(this.getGeoJSON()), this.refreshEditHandles();
|
|
1559
|
+
}
|
|
1560
|
+
deleteVertex(e) {
|
|
1561
|
+
let t = this.entity.coordinates;
|
|
1562
|
+
if (!t || t.length <= 3) return null;
|
|
1563
|
+
let n = t.filter((t, n) => n !== e), r = {
|
|
1564
|
+
...this.entity,
|
|
1565
|
+
coordinates: n
|
|
1566
|
+
};
|
|
1567
|
+
this.entity = r;
|
|
1568
|
+
let i = this.map.getSource(this.sourceId);
|
|
1569
|
+
return i && i.setData(this.getGeoJSON()), this.refreshEditHandles(), r;
|
|
1570
|
+
}
|
|
1571
|
+
addVertex(e, t) {
|
|
1572
|
+
let n = [...this.entity.coordinates];
|
|
1573
|
+
n.splice(e + 1, 0, t);
|
|
1574
|
+
let r = {
|
|
1575
|
+
...this.entity,
|
|
1576
|
+
coordinates: n
|
|
1577
|
+
};
|
|
1578
|
+
this.entity = r;
|
|
1579
|
+
let i = this.map.getSource(this.sourceId);
|
|
1580
|
+
return i && i.setData(this.getGeoJSON()), this.refreshEditHandles(), r;
|
|
1581
|
+
}
|
|
1165
1582
|
destroy() {
|
|
1166
|
-
this.initialized &&= (this.map.getLayer(this.lengthLayerId) && this.map.removeLayer(this.lengthLayerId), this.map.getLayer(this.areaLayerId) && this.map.removeLayer(this.areaLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.strokeLayerId) && this.map.removeLayer(this.strokeLayerId), this.map.getLayer(this.fillLayerId) && this.map.removeLayer(this.fillLayerId), this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId), !1);
|
|
1583
|
+
this.initialized &&= (this.removeEditLayers(), this.map.getLayer(this.lengthLayerId) && this.map.removeLayer(this.lengthLayerId), this.map.getLayer(this.areaLayerId) && this.map.removeLayer(this.areaLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.strokeLayerId) && this.map.removeLayer(this.strokeLayerId), this.map.getLayer(this.fillLayerId) && this.map.removeLayer(this.fillLayerId), this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId), !1);
|
|
1167
1584
|
}
|
|
1168
1585
|
}, PolylineRenderer = class e {
|
|
1169
1586
|
static {
|
|
@@ -1176,7 +1593,7 @@ var CanvasImageRenderer = class extends BaseCanvasRenderer {
|
|
|
1176
1593
|
};
|
|
1177
1594
|
}
|
|
1178
1595
|
constructor(e, t, n, r, i) {
|
|
1179
|
-
this.isSelected = !1, this.initialized = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalLengthConfig = i, this.sourceId = `polyline-source-${t.id}`, this.lineLayerId = `polyline-stroke-${t.id}`, this.labelLayerId = `polyline-label-${t.id}`, this.lengthLayerId = `polyline-length-${t.id}`, this.initLayers();
|
|
1596
|
+
this.isSelected = !1, this.initialized = !1, this.isEditing = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalLengthConfig = i, this.sourceId = `polyline-source-${t.id}`, this.lineLayerId = `polyline-stroke-${t.id}`, this.labelLayerId = `polyline-label-${t.id}`, this.lengthLayerId = `polyline-length-${t.id}`, this.editSourceId = `polyline-edit-source-${t.id}`, this.editHandleLayerId = `polyline-edit-handles-${t.id}`, this.editMidpointLayerId = `polyline-edit-midpoints-${t.id}`, this.editMoveLayerId = `polyline-edit-move-${t.id}`, this.initLayers();
|
|
1180
1597
|
}
|
|
1181
1598
|
get nameStyle() {
|
|
1182
1599
|
return resolveNameConfig(this.entity.nameConfig, this.globalNameConfig, DEFAULT_NAME_CONFIG);
|
|
@@ -1423,8 +1840,201 @@ var CanvasImageRenderer = class extends BaseCanvasRenderer {
|
|
|
1423
1840
|
}
|
|
1424
1841
|
(n.strokeColor !== t.strokeColor || n.strokeWidth !== t.strokeWidth || n.strokeOpacity !== t.strokeOpacity || n.confidence !== t.confidence || n.dashArray !== t.dashArray) && this.map.getLayer(this.lineLayerId) && (this.isSelected || this.map.setPaintProperty(this.lineLayerId, "line-color", t.strokeColor ?? e.DEFAULTS.strokeColor), this.map.setPaintProperty(this.lineLayerId, "line-width", t.strokeWidth ?? e.DEFAULTS.strokeWidth), this.map.setPaintProperty(this.lineLayerId, "line-opacity", (t.strokeOpacity ?? e.DEFAULTS.strokeOpacity) * i), t.dashArray && this.map.setPaintProperty(this.lineLayerId, "line-dasharray", t.dashArray)), (n.lineCap !== t.lineCap || n.lineJoin !== t.lineJoin) && this.map.getLayer(this.lineLayerId) && (this.map.setLayoutProperty(this.lineLayerId, "line-cap", t.lineCap ?? e.DEFAULTS.lineCap), this.map.setLayoutProperty(this.lineLayerId, "line-join", t.lineJoin ?? e.DEFAULTS.lineJoin)), n.confidence !== t.confidence && this.map.getLayer(this.labelLayerId) && this.map.setPaintProperty(this.labelLayerId, "text-opacity", i), n.confidence !== t.confidence && this.map.getLayer(this.lengthLayerId) && this.map.setPaintProperty(this.lengthLayerId, "text-opacity", i);
|
|
1425
1842
|
}
|
|
1843
|
+
getEditHandleGeoJSON(e) {
|
|
1844
|
+
let t = e ?? this.entity.coordinates;
|
|
1845
|
+
if (!t || t.length < 2) return {
|
|
1846
|
+
type: "FeatureCollection",
|
|
1847
|
+
features: []
|
|
1848
|
+
};
|
|
1849
|
+
let n = [];
|
|
1850
|
+
for (let e = 0; e < t.length; e++) n.push({
|
|
1851
|
+
type: "Feature",
|
|
1852
|
+
geometry: {
|
|
1853
|
+
type: "Point",
|
|
1854
|
+
coordinates: t[e]
|
|
1855
|
+
},
|
|
1856
|
+
properties: {
|
|
1857
|
+
handleType: "vertex",
|
|
1858
|
+
index: e
|
|
1859
|
+
}
|
|
1860
|
+
});
|
|
1861
|
+
for (let e = 0; e < t.length - 1; e++) {
|
|
1862
|
+
let r = t[e], i = t[e + 1];
|
|
1863
|
+
n.push({
|
|
1864
|
+
type: "Feature",
|
|
1865
|
+
geometry: {
|
|
1866
|
+
type: "Point",
|
|
1867
|
+
coordinates: [(r[0] + i[0]) / 2, (r[1] + i[1]) / 2]
|
|
1868
|
+
},
|
|
1869
|
+
properties: {
|
|
1870
|
+
handleType: "midpoint",
|
|
1871
|
+
index: e
|
|
1872
|
+
}
|
|
1873
|
+
});
|
|
1874
|
+
}
|
|
1875
|
+
let r = 0, i = 0;
|
|
1876
|
+
for (let e of t) r += e[0], i += e[1];
|
|
1877
|
+
return r /= t.length, i /= t.length, n.push({
|
|
1878
|
+
type: "Feature",
|
|
1879
|
+
geometry: {
|
|
1880
|
+
type: "Point",
|
|
1881
|
+
coordinates: [r, i]
|
|
1882
|
+
},
|
|
1883
|
+
properties: {
|
|
1884
|
+
handleType: "move",
|
|
1885
|
+
index: 0
|
|
1886
|
+
}
|
|
1887
|
+
}), {
|
|
1888
|
+
type: "FeatureCollection",
|
|
1889
|
+
features: n
|
|
1890
|
+
};
|
|
1891
|
+
}
|
|
1892
|
+
createEditLayers() {
|
|
1893
|
+
this.map.getSource(this.editSourceId) || (ensureMoveIcon(this.map), this.map.addSource(this.editSourceId, {
|
|
1894
|
+
type: "geojson",
|
|
1895
|
+
data: this.getEditHandleGeoJSON()
|
|
1896
|
+
}), this.map.addLayer({
|
|
1897
|
+
id: this.editMidpointLayerId,
|
|
1898
|
+
type: "circle",
|
|
1899
|
+
source: this.editSourceId,
|
|
1900
|
+
filter: [
|
|
1901
|
+
"==",
|
|
1902
|
+
["get", "handleType"],
|
|
1903
|
+
"midpoint"
|
|
1904
|
+
],
|
|
1905
|
+
paint: {
|
|
1906
|
+
"circle-radius": 4,
|
|
1907
|
+
"circle-color": "#3388ff",
|
|
1908
|
+
"circle-opacity": .5,
|
|
1909
|
+
"circle-stroke-color": "#3388ff",
|
|
1910
|
+
"circle-stroke-width": 1
|
|
1911
|
+
}
|
|
1912
|
+
}), this.map.addLayer({
|
|
1913
|
+
id: this.editHandleLayerId,
|
|
1914
|
+
type: "circle",
|
|
1915
|
+
source: this.editSourceId,
|
|
1916
|
+
filter: [
|
|
1917
|
+
"==",
|
|
1918
|
+
["get", "handleType"],
|
|
1919
|
+
"vertex"
|
|
1920
|
+
],
|
|
1921
|
+
paint: {
|
|
1922
|
+
"circle-radius": 6,
|
|
1923
|
+
"circle-color": "#ffffff",
|
|
1924
|
+
"circle-stroke-color": "#3388ff",
|
|
1925
|
+
"circle-stroke-width": 2
|
|
1926
|
+
}
|
|
1927
|
+
}), this.map.addLayer({
|
|
1928
|
+
id: this.editMoveLayerId,
|
|
1929
|
+
type: "symbol",
|
|
1930
|
+
source: this.editSourceId,
|
|
1931
|
+
filter: [
|
|
1932
|
+
"==",
|
|
1933
|
+
["get", "handleType"],
|
|
1934
|
+
"move"
|
|
1935
|
+
],
|
|
1936
|
+
layout: {
|
|
1937
|
+
"icon-image": MOVE_ICON_ID,
|
|
1938
|
+
"icon-allow-overlap": !0,
|
|
1939
|
+
"icon-ignore-placement": !0
|
|
1940
|
+
}
|
|
1941
|
+
}));
|
|
1942
|
+
}
|
|
1943
|
+
removeEditLayers() {
|
|
1944
|
+
this.map.getLayer(this.editMoveLayerId) && this.map.removeLayer(this.editMoveLayerId), this.map.getLayer(this.editHandleLayerId) && this.map.removeLayer(this.editHandleLayerId), this.map.getLayer(this.editMidpointLayerId) && this.map.removeLayer(this.editMidpointLayerId), this.map.getSource(this.editSourceId) && this.map.removeSource(this.editSourceId);
|
|
1945
|
+
}
|
|
1946
|
+
refreshEditHandles(e) {
|
|
1947
|
+
let t = this.map.getSource(this.editSourceId);
|
|
1948
|
+
t && t.setData(this.getEditHandleGeoJSON(e));
|
|
1949
|
+
}
|
|
1950
|
+
setEditing(e) {
|
|
1951
|
+
this.isEditing !== e && (this.isEditing = e, this.initialized && (e ? this.createEditLayers() : this.removeEditLayers()));
|
|
1952
|
+
}
|
|
1953
|
+
getEditHandleAt(e, t) {
|
|
1954
|
+
if (!this.isEditing) return null;
|
|
1955
|
+
let n = this.entity.coordinates;
|
|
1956
|
+
if (!n || n.length < 2) return null;
|
|
1957
|
+
let r = this.map.project(e), i = 0, a = 0;
|
|
1958
|
+
for (let e of n) i += e[0], a += e[1];
|
|
1959
|
+
i /= n.length, a /= n.length;
|
|
1960
|
+
let o = this.map.project([i, a]), s = r.x - o.x, c = r.y - o.y;
|
|
1961
|
+
if (s * s + c * c <= 144) return {
|
|
1962
|
+
type: "move",
|
|
1963
|
+
index: 0,
|
|
1964
|
+
position: [i, a]
|
|
1965
|
+
};
|
|
1966
|
+
for (let e = 0; e < n.length; e++) {
|
|
1967
|
+
let t = this.map.project(n[e]), i = r.x - t.x, a = r.y - t.y;
|
|
1968
|
+
if (i * i + a * a <= 100) return {
|
|
1969
|
+
type: "vertex",
|
|
1970
|
+
index: e,
|
|
1971
|
+
position: n[e]
|
|
1972
|
+
};
|
|
1973
|
+
}
|
|
1974
|
+
for (let e = 0; e < n.length - 1; e++) {
|
|
1975
|
+
let t = n[e], i = n[e + 1], a = [(t[0] + i[0]) / 2, (t[1] + i[1]) / 2], o = this.map.project(a), s = r.x - o.x, c = r.y - o.y;
|
|
1976
|
+
if (s * s + c * c <= 100) return {
|
|
1977
|
+
type: "midpoint",
|
|
1978
|
+
index: e,
|
|
1979
|
+
position: a
|
|
1980
|
+
};
|
|
1981
|
+
}
|
|
1982
|
+
return null;
|
|
1983
|
+
}
|
|
1984
|
+
offsetCoordinates(e, t, n) {
|
|
1985
|
+
let r = n[0] - t[0], i = n[1] - t[1];
|
|
1986
|
+
return e.map((e) => [e[0] + r, e[1] + i]);
|
|
1987
|
+
}
|
|
1988
|
+
applyHandleMove(e, t) {
|
|
1989
|
+
let n;
|
|
1990
|
+
e.type === "move" ? n = this.offsetCoordinates(this.entity.coordinates, e.position, t) : (n = [...this.entity.coordinates], n[e.index] = t);
|
|
1991
|
+
let r = {
|
|
1992
|
+
...this.entity,
|
|
1993
|
+
coordinates: n
|
|
1994
|
+
};
|
|
1995
|
+
this.entity = r;
|
|
1996
|
+
let i = this.map.getSource(this.sourceId);
|
|
1997
|
+
return i && i.setData(this.getGeoJSON()), this.refreshEditHandles(), r;
|
|
1998
|
+
}
|
|
1999
|
+
updateEditPreview(e, t) {
|
|
2000
|
+
let n;
|
|
2001
|
+
e.type === "move" ? n = this.offsetCoordinates(this.entity.coordinates, e.position, t) : (n = [...this.entity.coordinates], n[e.index] = t);
|
|
2002
|
+
let r = this.entity;
|
|
2003
|
+
this.entity = {
|
|
2004
|
+
...this.entity,
|
|
2005
|
+
coordinates: n
|
|
2006
|
+
};
|
|
2007
|
+
let i = this.map.getSource(this.sourceId);
|
|
2008
|
+
i && i.setData(this.getGeoJSON()), this.entity = r, this.refreshEditHandles(n);
|
|
2009
|
+
}
|
|
2010
|
+
cancelEditPreview() {
|
|
2011
|
+
let e = this.map.getSource(this.sourceId);
|
|
2012
|
+
e && e.setData(this.getGeoJSON()), this.refreshEditHandles();
|
|
2013
|
+
}
|
|
2014
|
+
deleteVertex(e) {
|
|
2015
|
+
let t = this.entity.coordinates;
|
|
2016
|
+
if (!t || t.length <= 2) return null;
|
|
2017
|
+
let n = t.filter((t, n) => n !== e), r = {
|
|
2018
|
+
...this.entity,
|
|
2019
|
+
coordinates: n
|
|
2020
|
+
};
|
|
2021
|
+
this.entity = r;
|
|
2022
|
+
let i = this.map.getSource(this.sourceId);
|
|
2023
|
+
return i && i.setData(this.getGeoJSON()), this.refreshEditHandles(), r;
|
|
2024
|
+
}
|
|
2025
|
+
addVertex(e, t) {
|
|
2026
|
+
let n = [...this.entity.coordinates];
|
|
2027
|
+
n.splice(e + 1, 0, t);
|
|
2028
|
+
let r = {
|
|
2029
|
+
...this.entity,
|
|
2030
|
+
coordinates: n
|
|
2031
|
+
};
|
|
2032
|
+
this.entity = r;
|
|
2033
|
+
let i = this.map.getSource(this.sourceId);
|
|
2034
|
+
return i && i.setData(this.getGeoJSON()), this.refreshEditHandles(), r;
|
|
2035
|
+
}
|
|
1426
2036
|
destroy() {
|
|
1427
|
-
this.initialized &&= (this.map.getLayer(this.lengthLayerId) && this.map.removeLayer(this.lengthLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.lineLayerId) && this.map.removeLayer(this.lineLayerId), this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId), !1);
|
|
2037
|
+
this.initialized &&= (this.removeEditLayers(), this.map.getLayer(this.lengthLayerId) && this.map.removeLayer(this.lengthLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.lineLayerId) && this.map.removeLayer(this.lineLayerId), this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId), !1);
|
|
1428
2038
|
}
|
|
1429
2039
|
};
|
|
1430
2040
|
function createCirclePolygon$1(e, t, n = 64) {
|
|
@@ -1452,7 +2062,7 @@ var CircleRenderer = class e {
|
|
|
1452
2062
|
};
|
|
1453
2063
|
}
|
|
1454
2064
|
constructor(e, t, n, r, i, a) {
|
|
1455
|
-
this.isSelected = !1, this.initialized = !1, this.gradientLayerIds = [], this.gradientSourceIds = [], this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalAreaConfig = i, this.globalCircleConfig = a, this.sourceId = `circle-source-${t.id}`, this.fillLayerId = `circle-fill-${t.id}`, this.strokeLayerId = `circle-stroke-${t.id}`, this.centerPointLayerId = `circle-center-${t.id}`, this.labelLayerId = `circle-label-${t.id}`, this.areaLayerId = `circle-area-${t.id}`, this.radiusLineLayerId = `circle-radius-line-${t.id}`, this.radiusLabelLayerId = `circle-radius-label-${t.id}`, this.initLayers();
|
|
2065
|
+
this.isSelected = !1, this.initialized = !1, this.gradientLayerIds = [], this.gradientSourceIds = [], this.isEditing = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalAreaConfig = i, this.globalCircleConfig = a, this.sourceId = `circle-source-${t.id}`, this.fillLayerId = `circle-fill-${t.id}`, this.strokeLayerId = `circle-stroke-${t.id}`, this.centerPointLayerId = `circle-center-${t.id}`, this.labelLayerId = `circle-label-${t.id}`, this.areaLayerId = `circle-area-${t.id}`, this.radiusLineLayerId = `circle-radius-line-${t.id}`, this.radiusLabelLayerId = `circle-radius-label-${t.id}`, this.editSourceId = `circle-edit-source-${t.id}`, this.editHandleLayerId = `circle-edit-handles-${t.id}`, this.editMoveLayerId = `circle-edit-move-${t.id}`, this.initLayers();
|
|
1456
2066
|
}
|
|
1457
2067
|
get nameStyle() {
|
|
1458
2068
|
return resolveNameConfig(this.entity.nameConfig, this.globalNameConfig, DEFAULT_NAME_CONFIG);
|
|
@@ -1872,9 +2482,146 @@ var CircleRenderer = class e {
|
|
|
1872
2482
|
this.map.getLayer(this.gradientLayerIds[n]) && (this.map.setPaintProperty(this.gradientLayerIds[n], "fill-color", `rgb(${i.r}, ${i.g}, ${i.b})`), this.map.setPaintProperty(this.gradientLayerIds[n], "fill-opacity", a));
|
|
1873
2483
|
}
|
|
1874
2484
|
}
|
|
2485
|
+
static {
|
|
2486
|
+
this.EDGE_BEARINGS = [
|
|
2487
|
+
0,
|
|
2488
|
+
90,
|
|
2489
|
+
180,
|
|
2490
|
+
270
|
|
2491
|
+
];
|
|
2492
|
+
}
|
|
2493
|
+
getEditHandlePositions(t, n) {
|
|
2494
|
+
let r = t ?? this.entity.center, i = n ?? this.entity.radius, a = [];
|
|
2495
|
+
for (let t = 0; t < e.EDGE_BEARINGS.length; t++) a.push({
|
|
2496
|
+
type: "edge",
|
|
2497
|
+
index: t,
|
|
2498
|
+
position: destinationPoint(r, i, e.EDGE_BEARINGS[t])
|
|
2499
|
+
});
|
|
2500
|
+
return a.push({
|
|
2501
|
+
type: "move",
|
|
2502
|
+
index: 0,
|
|
2503
|
+
position: r
|
|
2504
|
+
}), a;
|
|
2505
|
+
}
|
|
2506
|
+
getEditHandleGeoJSON(e, t) {
|
|
2507
|
+
return {
|
|
2508
|
+
type: "FeatureCollection",
|
|
2509
|
+
features: this.getEditHandlePositions(e, t).map((e) => ({
|
|
2510
|
+
type: "Feature",
|
|
2511
|
+
geometry: {
|
|
2512
|
+
type: "Point",
|
|
2513
|
+
coordinates: e.position
|
|
2514
|
+
},
|
|
2515
|
+
properties: {
|
|
2516
|
+
handleType: e.type,
|
|
2517
|
+
index: e.index
|
|
2518
|
+
}
|
|
2519
|
+
}))
|
|
2520
|
+
};
|
|
2521
|
+
}
|
|
2522
|
+
createEditLayers() {
|
|
2523
|
+
this.map.getSource(this.editSourceId) || (ensureMoveIcon(this.map), this.map.addSource(this.editSourceId, {
|
|
2524
|
+
type: "geojson",
|
|
2525
|
+
data: this.getEditHandleGeoJSON()
|
|
2526
|
+
}), this.map.addLayer({
|
|
2527
|
+
id: this.editHandleLayerId,
|
|
2528
|
+
type: "circle",
|
|
2529
|
+
source: this.editSourceId,
|
|
2530
|
+
filter: [
|
|
2531
|
+
"==",
|
|
2532
|
+
["get", "handleType"],
|
|
2533
|
+
"edge"
|
|
2534
|
+
],
|
|
2535
|
+
paint: {
|
|
2536
|
+
"circle-radius": 6,
|
|
2537
|
+
"circle-color": "#ffffff",
|
|
2538
|
+
"circle-stroke-color": "#3388ff",
|
|
2539
|
+
"circle-stroke-width": 2
|
|
2540
|
+
}
|
|
2541
|
+
}), this.map.addLayer({
|
|
2542
|
+
id: this.editMoveLayerId,
|
|
2543
|
+
type: "symbol",
|
|
2544
|
+
source: this.editSourceId,
|
|
2545
|
+
filter: [
|
|
2546
|
+
"==",
|
|
2547
|
+
["get", "handleType"],
|
|
2548
|
+
"move"
|
|
2549
|
+
],
|
|
2550
|
+
layout: {
|
|
2551
|
+
"icon-image": MOVE_ICON_ID,
|
|
2552
|
+
"icon-allow-overlap": !0,
|
|
2553
|
+
"icon-ignore-placement": !0
|
|
2554
|
+
}
|
|
2555
|
+
}));
|
|
2556
|
+
}
|
|
2557
|
+
removeEditLayers() {
|
|
2558
|
+
this.map.getLayer(this.editMoveLayerId) && this.map.removeLayer(this.editMoveLayerId), this.map.getLayer(this.editHandleLayerId) && this.map.removeLayer(this.editHandleLayerId), this.map.getSource(this.editSourceId) && this.map.removeSource(this.editSourceId);
|
|
2559
|
+
}
|
|
2560
|
+
refreshEditHandles(e, t) {
|
|
2561
|
+
let n = this.map.getSource(this.editSourceId);
|
|
2562
|
+
n && n.setData(this.getEditHandleGeoJSON(e, t));
|
|
2563
|
+
}
|
|
2564
|
+
setEditing(e) {
|
|
2565
|
+
this.isEditing !== e && (this.isEditing = e, this.initialized && (e ? this.createEditLayers() : this.removeEditLayers()));
|
|
2566
|
+
}
|
|
2567
|
+
getEditHandleAt(e, t) {
|
|
2568
|
+
if (!this.isEditing) return null;
|
|
2569
|
+
let n = this.map.project(e), r = this.getEditHandlePositions(), i = r.find((e) => e.type === "move");
|
|
2570
|
+
if (i) {
|
|
2571
|
+
let e = this.map.project(i.position), t = n.x - e.x, r = n.y - e.y;
|
|
2572
|
+
if (t * t + r * r <= 144) return {
|
|
2573
|
+
type: "move",
|
|
2574
|
+
index: i.index,
|
|
2575
|
+
position: i.position
|
|
2576
|
+
};
|
|
2577
|
+
}
|
|
2578
|
+
for (let e of r) {
|
|
2579
|
+
if (e.type === "move") continue;
|
|
2580
|
+
let t = this.map.project(e.position), r = n.x - t.x, i = n.y - t.y;
|
|
2581
|
+
if (r * r + i * i <= 100) return {
|
|
2582
|
+
type: e.type,
|
|
2583
|
+
index: e.index,
|
|
2584
|
+
position: e.position
|
|
2585
|
+
};
|
|
2586
|
+
}
|
|
2587
|
+
return null;
|
|
2588
|
+
}
|
|
2589
|
+
applyHandleMove(e, t) {
|
|
2590
|
+
let n;
|
|
2591
|
+
if (e.type === "move") n = {
|
|
2592
|
+
...this.entity,
|
|
2593
|
+
center: t
|
|
2594
|
+
};
|
|
2595
|
+
else {
|
|
2596
|
+
let e = this.calculateDistance(this.entity.center, t);
|
|
2597
|
+
n = {
|
|
2598
|
+
...this.entity,
|
|
2599
|
+
radius: e
|
|
2600
|
+
};
|
|
2601
|
+
}
|
|
2602
|
+
this.entity = n;
|
|
2603
|
+
let r = this.map.getSource(this.sourceId);
|
|
2604
|
+
return r && r.setData(this.getGeoJSON()), this.refreshEditHandles(), n;
|
|
2605
|
+
}
|
|
2606
|
+
updateEditPreview(e, t) {
|
|
2607
|
+
let n, r;
|
|
2608
|
+
e.type === "move" ? (n = t, r = this.entity.radius) : (n = this.entity.center, r = this.calculateDistance(this.entity.center, t));
|
|
2609
|
+
let i = this.entity;
|
|
2610
|
+
this.entity = {
|
|
2611
|
+
...this.entity,
|
|
2612
|
+
center: n,
|
|
2613
|
+
radius: r
|
|
2614
|
+
};
|
|
2615
|
+
let a = this.map.getSource(this.sourceId);
|
|
2616
|
+
a && a.setData(this.getGeoJSON()), this.entity = i, this.refreshEditHandles(n, r);
|
|
2617
|
+
}
|
|
2618
|
+
cancelEditPreview() {
|
|
2619
|
+
let e = this.map.getSource(this.sourceId);
|
|
2620
|
+
e && e.setData(this.getGeoJSON()), this.refreshEditHandles();
|
|
2621
|
+
}
|
|
1875
2622
|
destroy() {
|
|
1876
2623
|
if (this.initialized) {
|
|
1877
|
-
this.map.getLayer(this.radiusLabelLayerId) && this.map.removeLayer(this.radiusLabelLayerId), this.map.getLayer(this.radiusLineLayerId) && this.map.removeLayer(this.radiusLineLayerId), this.map.getLayer(this.areaLayerId) && this.map.removeLayer(this.areaLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.centerPointLayerId) && this.map.removeLayer(this.centerPointLayerId), this.map.getLayer(this.strokeLayerId) && this.map.removeLayer(this.strokeLayerId), this.map.getLayer(this.fillLayerId) && this.map.removeLayer(this.fillLayerId);
|
|
2624
|
+
this.removeEditLayers(), this.map.getLayer(this.radiusLabelLayerId) && this.map.removeLayer(this.radiusLabelLayerId), this.map.getLayer(this.radiusLineLayerId) && this.map.removeLayer(this.radiusLineLayerId), this.map.getLayer(this.areaLayerId) && this.map.removeLayer(this.areaLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.centerPointLayerId) && this.map.removeLayer(this.centerPointLayerId), this.map.getLayer(this.strokeLayerId) && this.map.removeLayer(this.strokeLayerId), this.map.getLayer(this.fillLayerId) && this.map.removeLayer(this.fillLayerId);
|
|
1878
2625
|
for (let e of this.gradientLayerIds) this.map.getLayer(e) && this.map.removeLayer(e);
|
|
1879
2626
|
for (let e of this.gradientSourceIds) this.map.getSource(e) && this.map.removeSource(e);
|
|
1880
2627
|
this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId), this.initialized = !1;
|
|
@@ -1901,9 +2648,17 @@ function calculateCircleBounds(e, t) {
|
|
|
1901
2648
|
[a, s]
|
|
1902
2649
|
];
|
|
1903
2650
|
}
|
|
1904
|
-
var CanvasCircleRenderer = class extends BaseCanvasRenderer {
|
|
2651
|
+
var CanvasCircleRenderer = class e extends BaseCanvasRenderer {
|
|
2652
|
+
static {
|
|
2653
|
+
this.EDGE_BEARINGS = [
|
|
2654
|
+
0,
|
|
2655
|
+
90,
|
|
2656
|
+
180,
|
|
2657
|
+
270
|
|
2658
|
+
];
|
|
2659
|
+
}
|
|
1905
2660
|
constructor(e, t, n, r, i, a) {
|
|
1906
|
-
super(e, t, "canvas-circle", n, r, i), this.animationFrameId = null, this.animationTime = 0, this.pulsePhase = 0, this.globalCircleConfig = a, this.radiusSourceId = `canvas-circle-radius-source-${String(t.id)}`, this.radiusLineLayerId = `canvas-circle-radius-line-${String(t.id)}`, this.radiusLabelLayerId = `canvas-circle-radius-label-${String(t.id)}`;
|
|
2661
|
+
super(e, t, "canvas-circle", n, r, i), this.animationFrameId = null, this.animationTime = 0, this.pulsePhase = 0, this.isEditing = !1, this.editSourceId = "", this.editHandleLayerId = "", this.editMoveLayerId = "", this.globalCircleConfig = a, this.radiusSourceId = `canvas-circle-radius-source-${String(t.id)}`, this.radiusLineLayerId = `canvas-circle-radius-line-${String(t.id)}`, this.radiusLabelLayerId = `canvas-circle-radius-label-${String(t.id)}`, this.editSourceId = `canvas-circle-edit-source-${String(t.id)}`, this.editHandleLayerId = `canvas-circle-edit-handles-${String(t.id)}`, this.editMoveLayerId = `canvas-circle-edit-move-${String(t.id)}`;
|
|
1907
2662
|
let o = calculateCircleBounds(t.center, t.radius);
|
|
1908
2663
|
this.init(o), this.initRadiusLayer(), t.isAnimating && this.startAnimation();
|
|
1909
2664
|
}
|
|
@@ -2117,7 +2872,141 @@ var CanvasCircleRenderer = class extends BaseCanvasRenderer {
|
|
|
2117
2872
|
return Math.sqrt((r * a) ** 2 + (i * 110540) ** 2) <= n;
|
|
2118
2873
|
}
|
|
2119
2874
|
destroy() {
|
|
2120
|
-
this.stopAnimation(), this.map.getLayer(this.radiusLabelLayerId) && this.map.removeLayer(this.radiusLabelLayerId), this.map.getLayer(this.radiusLineLayerId) && this.map.removeLayer(this.radiusLineLayerId), this.map.getSource(this.radiusSourceId) && this.map.removeSource(this.radiusSourceId), super.destroy();
|
|
2875
|
+
this.removeEditLayers(), this.stopAnimation(), this.map.getLayer(this.radiusLabelLayerId) && this.map.removeLayer(this.radiusLabelLayerId), this.map.getLayer(this.radiusLineLayerId) && this.map.removeLayer(this.radiusLineLayerId), this.map.getSource(this.radiusSourceId) && this.map.removeSource(this.radiusSourceId), super.destroy();
|
|
2876
|
+
}
|
|
2877
|
+
getEditHandlePositions(t, n) {
|
|
2878
|
+
let r = t ?? this.entity.center, i = n ?? this.entity.radius, a = [];
|
|
2879
|
+
for (let t = 0; t < e.EDGE_BEARINGS.length; t++) a.push({
|
|
2880
|
+
type: "edge",
|
|
2881
|
+
index: t,
|
|
2882
|
+
position: destinationPoint(r, i, e.EDGE_BEARINGS[t])
|
|
2883
|
+
});
|
|
2884
|
+
return a.push({
|
|
2885
|
+
type: "move",
|
|
2886
|
+
index: 0,
|
|
2887
|
+
position: r
|
|
2888
|
+
}), a;
|
|
2889
|
+
}
|
|
2890
|
+
getEditHandleGeoJSON(e, t) {
|
|
2891
|
+
return {
|
|
2892
|
+
type: "FeatureCollection",
|
|
2893
|
+
features: this.getEditHandlePositions(e, t).map((e) => ({
|
|
2894
|
+
type: "Feature",
|
|
2895
|
+
geometry: {
|
|
2896
|
+
type: "Point",
|
|
2897
|
+
coordinates: e.position
|
|
2898
|
+
},
|
|
2899
|
+
properties: {
|
|
2900
|
+
handleType: e.type,
|
|
2901
|
+
index: e.index
|
|
2902
|
+
}
|
|
2903
|
+
}))
|
|
2904
|
+
};
|
|
2905
|
+
}
|
|
2906
|
+
createEditLayers() {
|
|
2907
|
+
this.map.getSource(this.editSourceId) || (ensureMoveIcon(this.map), this.map.addSource(this.editSourceId, {
|
|
2908
|
+
type: "geojson",
|
|
2909
|
+
data: this.getEditHandleGeoJSON()
|
|
2910
|
+
}), this.map.addLayer({
|
|
2911
|
+
id: this.editHandleLayerId,
|
|
2912
|
+
type: "circle",
|
|
2913
|
+
source: this.editSourceId,
|
|
2914
|
+
filter: [
|
|
2915
|
+
"==",
|
|
2916
|
+
["get", "handleType"],
|
|
2917
|
+
"edge"
|
|
2918
|
+
],
|
|
2919
|
+
paint: {
|
|
2920
|
+
"circle-radius": 6,
|
|
2921
|
+
"circle-color": "#ffffff",
|
|
2922
|
+
"circle-stroke-color": "#3388ff",
|
|
2923
|
+
"circle-stroke-width": 2
|
|
2924
|
+
}
|
|
2925
|
+
}), this.map.addLayer({
|
|
2926
|
+
id: this.editMoveLayerId,
|
|
2927
|
+
type: "symbol",
|
|
2928
|
+
source: this.editSourceId,
|
|
2929
|
+
filter: [
|
|
2930
|
+
"==",
|
|
2931
|
+
["get", "handleType"],
|
|
2932
|
+
"move"
|
|
2933
|
+
],
|
|
2934
|
+
layout: {
|
|
2935
|
+
"icon-image": MOVE_ICON_ID,
|
|
2936
|
+
"icon-allow-overlap": !0,
|
|
2937
|
+
"icon-ignore-placement": !0
|
|
2938
|
+
}
|
|
2939
|
+
}));
|
|
2940
|
+
}
|
|
2941
|
+
removeEditLayers() {
|
|
2942
|
+
this.map.getLayer(this.editMoveLayerId) && this.map.removeLayer(this.editMoveLayerId), this.map.getLayer(this.editHandleLayerId) && this.map.removeLayer(this.editHandleLayerId), this.map.getSource(this.editSourceId) && this.map.removeSource(this.editSourceId);
|
|
2943
|
+
}
|
|
2944
|
+
refreshEditHandles(e, t) {
|
|
2945
|
+
let n = this.map.getSource(this.editSourceId);
|
|
2946
|
+
n && n.setData(this.getEditHandleGeoJSON(e, t));
|
|
2947
|
+
}
|
|
2948
|
+
setEditing(e) {
|
|
2949
|
+
this.isEditing !== e && (this.isEditing = e, e ? this.createEditLayers() : this.removeEditLayers());
|
|
2950
|
+
}
|
|
2951
|
+
getEditHandleAt(e, t) {
|
|
2952
|
+
if (!this.isEditing) return null;
|
|
2953
|
+
let n = this.map.project(e), r = this.getEditHandlePositions(), i = r.find((e) => e.type === "move");
|
|
2954
|
+
if (i) {
|
|
2955
|
+
let e = this.map.project(i.position), t = n.x - e.x, r = n.y - e.y;
|
|
2956
|
+
if (t * t + r * r <= 144) return {
|
|
2957
|
+
type: "move",
|
|
2958
|
+
index: i.index,
|
|
2959
|
+
position: i.position
|
|
2960
|
+
};
|
|
2961
|
+
}
|
|
2962
|
+
for (let e of r) {
|
|
2963
|
+
if (e.type === "move") continue;
|
|
2964
|
+
let t = this.map.project(e.position), r = n.x - t.x, i = n.y - t.y;
|
|
2965
|
+
if (r * r + i * i <= 100) return {
|
|
2966
|
+
type: e.type,
|
|
2967
|
+
index: e.index,
|
|
2968
|
+
position: e.position
|
|
2969
|
+
};
|
|
2970
|
+
}
|
|
2971
|
+
return null;
|
|
2972
|
+
}
|
|
2973
|
+
applyHandleMove(e, t) {
|
|
2974
|
+
let n;
|
|
2975
|
+
if (e.type === "move") {
|
|
2976
|
+
let r = t[0] - e.position[0], i = t[1] - e.position[1], a = [this.entity.center[0] + r, this.entity.center[1] + i];
|
|
2977
|
+
n = {
|
|
2978
|
+
...this.entity,
|
|
2979
|
+
center: a
|
|
2980
|
+
};
|
|
2981
|
+
} else {
|
|
2982
|
+
let e = distance(this.entity.center, t);
|
|
2983
|
+
n = {
|
|
2984
|
+
...this.entity,
|
|
2985
|
+
radius: e
|
|
2986
|
+
};
|
|
2987
|
+
}
|
|
2988
|
+
this.entity = n;
|
|
2989
|
+
let r = calculateCircleBounds(n.center, n.radius);
|
|
2990
|
+
return this.updateSourceCoordinates(r), this.updateLabel(), this.updateAreaLabel(), this.updateRadiusLayer(), this.refreshEditHandles(), n;
|
|
2991
|
+
}
|
|
2992
|
+
updateEditPreview(e, t) {
|
|
2993
|
+
let n, r;
|
|
2994
|
+
if (e.type === "move") {
|
|
2995
|
+
let i = t[0] - e.position[0], a = t[1] - e.position[1];
|
|
2996
|
+
n = [this.entity.center[0] + i, this.entity.center[1] + a], r = this.entity.radius;
|
|
2997
|
+
} else n = this.entity.center, r = distance(this.entity.center, t);
|
|
2998
|
+
let i = calculateCircleBounds(n, r);
|
|
2999
|
+
this.updateSourceCoordinates(i);
|
|
3000
|
+
let a = this.entity;
|
|
3001
|
+
this.entity = {
|
|
3002
|
+
...this.entity,
|
|
3003
|
+
center: n,
|
|
3004
|
+
radius: r
|
|
3005
|
+
}, this.updateLabel(), this.entity = a, this.refreshEditHandles(n, r);
|
|
3006
|
+
}
|
|
3007
|
+
cancelEditPreview() {
|
|
3008
|
+
let e = calculateCircleBounds(this.entity.center, this.entity.radius);
|
|
3009
|
+
this.updateSourceCoordinates(e), this.updateLabel(), this.refreshEditHandles();
|
|
2121
3010
|
}
|
|
2122
3011
|
};
|
|
2123
3012
|
function createSquareCoordinates(e, t) {
|
|
@@ -2141,7 +3030,7 @@ var SquareRenderer = class e {
|
|
|
2141
3030
|
};
|
|
2142
3031
|
}
|
|
2143
3032
|
constructor(e, t, n, r, i, a) {
|
|
2144
|
-
this.isSelected = !1, this.initialized = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalAreaConfig = i, this.globalLengthConfig = a, this.sourceId = `square-source-${t.id}`, this.fillLayerId = `square-fill-${t.id}`, this.strokeLayerId = `square-stroke-${t.id}`, this.labelLayerId = `square-label-${t.id}`, this.areaLayerId = `square-area-${t.id}`, this.lengthLayerId = `square-length-${t.id}`, this.initLayers();
|
|
3033
|
+
this.isSelected = !1, this.initialized = !1, this.isEditing = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalAreaConfig = i, this.globalLengthConfig = a, this.sourceId = `square-source-${t.id}`, this.fillLayerId = `square-fill-${t.id}`, this.strokeLayerId = `square-stroke-${t.id}`, this.labelLayerId = `square-label-${t.id}`, this.areaLayerId = `square-area-${t.id}`, this.lengthLayerId = `square-length-${t.id}`, this.editSourceId = `square-edit-source-${t.id}`, this.editHandleLayerId = `square-edit-handles-${t.id}`, this.editMoveLayerId = `square-edit-move-${t.id}`, this.initLayers();
|
|
2145
3034
|
}
|
|
2146
3035
|
get nameStyle() {
|
|
2147
3036
|
return resolveNameConfig(this.entity.nameConfig, this.globalNameConfig, DEFAULT_NAME_CONFIG);
|
|
@@ -2440,8 +3329,142 @@ var SquareRenderer = class e {
|
|
|
2440
3329
|
}
|
|
2441
3330
|
(n.fillColor !== t.fillColor || n.fillOpacity !== t.fillOpacity || n.confidence !== t.confidence) && this.map.getLayer(this.fillLayerId) && (this.map.setPaintProperty(this.fillLayerId, "fill-color", t.fillColor ?? e.DEFAULTS.fillColor), this.map.setPaintProperty(this.fillLayerId, "fill-opacity", (t.fillOpacity ?? e.DEFAULTS.fillOpacity) * i)), (n.strokeColor !== t.strokeColor || n.strokeWidth !== t.strokeWidth || n.strokeOpacity !== t.strokeOpacity || n.confidence !== t.confidence) && this.map.getLayer(this.strokeLayerId) && (this.isSelected || this.map.setPaintProperty(this.strokeLayerId, "line-color", t.strokeColor ?? e.DEFAULTS.strokeColor), this.map.setPaintProperty(this.strokeLayerId, "line-width", t.strokeWidth ?? e.DEFAULTS.strokeWidth), this.map.setPaintProperty(this.strokeLayerId, "line-opacity", (t.strokeOpacity ?? e.DEFAULTS.strokeOpacity) * i)), n.confidence !== t.confidence && (this.map.getLayer(this.labelLayerId) && this.map.setPaintProperty(this.labelLayerId, "text-opacity", i), this.map.getLayer(this.areaLayerId) && this.map.setPaintProperty(this.areaLayerId, "text-opacity", i), this.map.getLayer(this.lengthLayerId) && this.map.setPaintProperty(this.lengthLayerId, "text-opacity", i));
|
|
2442
3331
|
}
|
|
3332
|
+
getCorners(e, t) {
|
|
3333
|
+
return createSquareCoordinates(e ?? this.entity.center, t ?? this.entity.length).slice(0, 4);
|
|
3334
|
+
}
|
|
3335
|
+
getEditHandleGeoJSON(e, t) {
|
|
3336
|
+
let n = this.getCorners(e, t).map((e, t) => ({
|
|
3337
|
+
type: "Feature",
|
|
3338
|
+
geometry: {
|
|
3339
|
+
type: "Point",
|
|
3340
|
+
coordinates: e
|
|
3341
|
+
},
|
|
3342
|
+
properties: {
|
|
3343
|
+
handleType: "vertex",
|
|
3344
|
+
index: t
|
|
3345
|
+
}
|
|
3346
|
+
})), r = e ?? this.entity.center;
|
|
3347
|
+
return n.push({
|
|
3348
|
+
type: "Feature",
|
|
3349
|
+
geometry: {
|
|
3350
|
+
type: "Point",
|
|
3351
|
+
coordinates: r
|
|
3352
|
+
},
|
|
3353
|
+
properties: {
|
|
3354
|
+
handleType: "move",
|
|
3355
|
+
index: 0
|
|
3356
|
+
}
|
|
3357
|
+
}), {
|
|
3358
|
+
type: "FeatureCollection",
|
|
3359
|
+
features: n
|
|
3360
|
+
};
|
|
3361
|
+
}
|
|
3362
|
+
createEditLayers() {
|
|
3363
|
+
this.map.getSource(this.editSourceId) || (ensureMoveIcon(this.map), this.map.addSource(this.editSourceId, {
|
|
3364
|
+
type: "geojson",
|
|
3365
|
+
data: this.getEditHandleGeoJSON()
|
|
3366
|
+
}), this.map.addLayer({
|
|
3367
|
+
id: this.editHandleLayerId,
|
|
3368
|
+
type: "circle",
|
|
3369
|
+
source: this.editSourceId,
|
|
3370
|
+
filter: [
|
|
3371
|
+
"==",
|
|
3372
|
+
["get", "handleType"],
|
|
3373
|
+
"vertex"
|
|
3374
|
+
],
|
|
3375
|
+
paint: {
|
|
3376
|
+
"circle-radius": 6,
|
|
3377
|
+
"circle-color": "#ffffff",
|
|
3378
|
+
"circle-stroke-color": "#3388ff",
|
|
3379
|
+
"circle-stroke-width": 2
|
|
3380
|
+
}
|
|
3381
|
+
}), this.map.addLayer({
|
|
3382
|
+
id: this.editMoveLayerId,
|
|
3383
|
+
type: "symbol",
|
|
3384
|
+
source: this.editSourceId,
|
|
3385
|
+
filter: [
|
|
3386
|
+
"==",
|
|
3387
|
+
["get", "handleType"],
|
|
3388
|
+
"move"
|
|
3389
|
+
],
|
|
3390
|
+
layout: {
|
|
3391
|
+
"icon-image": MOVE_ICON_ID,
|
|
3392
|
+
"icon-allow-overlap": !0,
|
|
3393
|
+
"icon-ignore-placement": !0
|
|
3394
|
+
}
|
|
3395
|
+
}));
|
|
3396
|
+
}
|
|
3397
|
+
removeEditLayers() {
|
|
3398
|
+
this.map.getLayer(this.editMoveLayerId) && this.map.removeLayer(this.editMoveLayerId), this.map.getLayer(this.editHandleLayerId) && this.map.removeLayer(this.editHandleLayerId), this.map.getSource(this.editSourceId) && this.map.removeSource(this.editSourceId);
|
|
3399
|
+
}
|
|
3400
|
+
refreshEditHandles(e, t) {
|
|
3401
|
+
let n = this.map.getSource(this.editSourceId);
|
|
3402
|
+
n && n.setData(this.getEditHandleGeoJSON(e, t));
|
|
3403
|
+
}
|
|
3404
|
+
setEditing(e) {
|
|
3405
|
+
this.isEditing !== e && (this.isEditing = e, this.initialized && (e ? this.createEditLayers() : this.removeEditLayers()));
|
|
3406
|
+
}
|
|
3407
|
+
getEditHandleAt(e, t) {
|
|
3408
|
+
if (!this.isEditing) return null;
|
|
3409
|
+
let n = this.getCorners(), r = this.map.project(e), i = this.entity.center, a = this.map.project(i), o = r.x - a.x, s = r.y - a.y;
|
|
3410
|
+
if (o * o + s * s <= 144) return {
|
|
3411
|
+
type: "move",
|
|
3412
|
+
index: 0,
|
|
3413
|
+
position: i
|
|
3414
|
+
};
|
|
3415
|
+
for (let e = 0; e < n.length; e++) {
|
|
3416
|
+
let t = this.map.project(n[e]), i = r.x - t.x, a = r.y - t.y;
|
|
3417
|
+
if (i * i + a * a <= 100) return {
|
|
3418
|
+
type: "vertex",
|
|
3419
|
+
index: e,
|
|
3420
|
+
position: n[e]
|
|
3421
|
+
};
|
|
3422
|
+
}
|
|
3423
|
+
return null;
|
|
3424
|
+
}
|
|
3425
|
+
computeNewLength(e) {
|
|
3426
|
+
return distance(this.entity.center, e) * Math.SQRT2;
|
|
3427
|
+
}
|
|
3428
|
+
applyHandleMove(e, t) {
|
|
3429
|
+
let n;
|
|
3430
|
+
if (e.type === "move") {
|
|
3431
|
+
let r = t[0] - e.position[0], i = t[1] - e.position[1], a = [this.entity.center[0] + r, this.entity.center[1] + i];
|
|
3432
|
+
n = {
|
|
3433
|
+
...this.entity,
|
|
3434
|
+
center: a
|
|
3435
|
+
};
|
|
3436
|
+
} else {
|
|
3437
|
+
let e = this.computeNewLength(t);
|
|
3438
|
+
n = {
|
|
3439
|
+
...this.entity,
|
|
3440
|
+
length: e
|
|
3441
|
+
};
|
|
3442
|
+
}
|
|
3443
|
+
this.entity = n;
|
|
3444
|
+
let r = this.map.getSource(this.sourceId);
|
|
3445
|
+
return r && r.setData(this.getGeoJSON()), this.refreshEditHandles(), n;
|
|
3446
|
+
}
|
|
3447
|
+
updateEditPreview(e, t) {
|
|
3448
|
+
let n, r;
|
|
3449
|
+
if (e.type === "move") {
|
|
3450
|
+
let i = t[0] - e.position[0], a = t[1] - e.position[1];
|
|
3451
|
+
n = [this.entity.center[0] + i, this.entity.center[1] + a], r = this.entity.length;
|
|
3452
|
+
} else n = this.entity.center, r = this.computeNewLength(t);
|
|
3453
|
+
let i = this.entity;
|
|
3454
|
+
this.entity = {
|
|
3455
|
+
...this.entity,
|
|
3456
|
+
center: n,
|
|
3457
|
+
length: r
|
|
3458
|
+
};
|
|
3459
|
+
let a = this.map.getSource(this.sourceId);
|
|
3460
|
+
a && a.setData(this.getGeoJSON()), this.entity = i, this.refreshEditHandles(n, r);
|
|
3461
|
+
}
|
|
3462
|
+
cancelEditPreview() {
|
|
3463
|
+
let e = this.map.getSource(this.sourceId);
|
|
3464
|
+
e && e.setData(this.getGeoJSON()), this.refreshEditHandles();
|
|
3465
|
+
}
|
|
2443
3466
|
destroy() {
|
|
2444
|
-
this.initialized &&= (this.map.getLayer(this.lengthLayerId) && this.map.removeLayer(this.lengthLayerId), this.map.getLayer(this.areaLayerId) && this.map.removeLayer(this.areaLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.strokeLayerId) && this.map.removeLayer(this.strokeLayerId), this.map.getLayer(this.fillLayerId) && this.map.removeLayer(this.fillLayerId), this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId), !1);
|
|
3467
|
+
this.initialized &&= (this.removeEditLayers(), this.map.getLayer(this.lengthLayerId) && this.map.removeLayer(this.lengthLayerId), this.map.getLayer(this.areaLayerId) && this.map.removeLayer(this.areaLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.strokeLayerId) && this.map.removeLayer(this.strokeLayerId), this.map.getLayer(this.fillLayerId) && this.map.removeLayer(this.fillLayerId), this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId), !1);
|
|
2445
3468
|
}
|
|
2446
3469
|
};
|
|
2447
3470
|
function createRectangleCoordinates(e) {
|
|
@@ -2465,7 +3488,7 @@ var RectangleRenderer = class e {
|
|
|
2465
3488
|
};
|
|
2466
3489
|
}
|
|
2467
3490
|
constructor(e, t, n, r, i, a) {
|
|
2468
|
-
this.isSelected = !1, this.initialized = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalAreaConfig = i, this.globalLengthConfig = a, this.sourceId = `rectangle-source-${t.id}`, this.fillLayerId = `rectangle-fill-${t.id}`, this.strokeLayerId = `rectangle-stroke-${t.id}`, this.labelLayerId = `rectangle-label-${t.id}`, this.areaLayerId = `rectangle-area-${t.id}`, this.lengthLayerId = `rectangle-length-${t.id}`, this.initLayers();
|
|
3491
|
+
this.isSelected = !1, this.initialized = !1, this.isEditing = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalAreaConfig = i, this.globalLengthConfig = a, this.sourceId = `rectangle-source-${t.id}`, this.fillLayerId = `rectangle-fill-${t.id}`, this.strokeLayerId = `rectangle-stroke-${t.id}`, this.labelLayerId = `rectangle-label-${t.id}`, this.areaLayerId = `rectangle-area-${t.id}`, this.lengthLayerId = `rectangle-length-${t.id}`, this.editSourceId = `rectangle-edit-source-${t.id}`, this.editHandleLayerId = `rectangle-edit-handles-${t.id}`, this.editMoveLayerId = `rectangle-edit-move-${t.id}`, this.initLayers();
|
|
2469
3492
|
}
|
|
2470
3493
|
get nameStyle() {
|
|
2471
3494
|
return resolveNameConfig(this.entity.nameConfig, this.globalNameConfig, DEFAULT_NAME_CONFIG);
|
|
@@ -2775,10 +3798,137 @@ var RectangleRenderer = class e {
|
|
|
2775
3798
|
}
|
|
2776
3799
|
}) : n.showLength && !t.showLength && this.map.getLayer(this.lengthLayerId) && this.map.removeLayer(this.lengthLayerId);
|
|
2777
3800
|
}
|
|
2778
|
-
(n.fillColor !== t.fillColor || n.fillOpacity !== t.fillOpacity || n.confidence !== t.confidence) && this.map.getLayer(this.fillLayerId) && (this.map.setPaintProperty(this.fillLayerId, "fill-color", t.fillColor ?? e.DEFAULTS.fillColor), this.map.setPaintProperty(this.fillLayerId, "fill-opacity", (t.fillOpacity ?? e.DEFAULTS.fillOpacity) * i)), (n.strokeColor !== t.strokeColor || n.strokeWidth !== t.strokeWidth || n.strokeOpacity !== t.strokeOpacity || n.confidence !== t.confidence) && this.map.getLayer(this.strokeLayerId) && (this.isSelected || this.map.setPaintProperty(this.strokeLayerId, "line-color", t.strokeColor ?? e.DEFAULTS.strokeColor), this.map.setPaintProperty(this.strokeLayerId, "line-width", t.strokeWidth ?? e.DEFAULTS.strokeWidth), this.map.setPaintProperty(this.strokeLayerId, "line-opacity", (t.strokeOpacity ?? e.DEFAULTS.strokeOpacity) * i)), n.confidence !== t.confidence && (this.map.getLayer(this.labelLayerId) && this.map.setPaintProperty(this.labelLayerId, "text-opacity", i), this.map.getLayer(this.areaLayerId) && this.map.setPaintProperty(this.areaLayerId, "text-opacity", i), this.map.getLayer(this.lengthLayerId) && this.map.setPaintProperty(this.lengthLayerId, "text-opacity", i));
|
|
3801
|
+
(n.fillColor !== t.fillColor || n.fillOpacity !== t.fillOpacity || n.confidence !== t.confidence) && this.map.getLayer(this.fillLayerId) && (this.map.setPaintProperty(this.fillLayerId, "fill-color", t.fillColor ?? e.DEFAULTS.fillColor), this.map.setPaintProperty(this.fillLayerId, "fill-opacity", (t.fillOpacity ?? e.DEFAULTS.fillOpacity) * i)), (n.strokeColor !== t.strokeColor || n.strokeWidth !== t.strokeWidth || n.strokeOpacity !== t.strokeOpacity || n.confidence !== t.confidence) && this.map.getLayer(this.strokeLayerId) && (this.isSelected || this.map.setPaintProperty(this.strokeLayerId, "line-color", t.strokeColor ?? e.DEFAULTS.strokeColor), this.map.setPaintProperty(this.strokeLayerId, "line-width", t.strokeWidth ?? e.DEFAULTS.strokeWidth), this.map.setPaintProperty(this.strokeLayerId, "line-opacity", (t.strokeOpacity ?? e.DEFAULTS.strokeOpacity) * i)), n.confidence !== t.confidence && (this.map.getLayer(this.labelLayerId) && this.map.setPaintProperty(this.labelLayerId, "text-opacity", i), this.map.getLayer(this.areaLayerId) && this.map.setPaintProperty(this.areaLayerId, "text-opacity", i), this.map.getLayer(this.lengthLayerId) && this.map.setPaintProperty(this.lengthLayerId, "text-opacity", i));
|
|
3802
|
+
}
|
|
3803
|
+
getCorners(e) {
|
|
3804
|
+
return createRectangleCoordinates(e ?? this.entity.bounds).slice(0, 4);
|
|
3805
|
+
}
|
|
3806
|
+
getEditHandleGeoJSON(e) {
|
|
3807
|
+
let t = this.getCorners(e).map((e, t) => ({
|
|
3808
|
+
type: "Feature",
|
|
3809
|
+
geometry: {
|
|
3810
|
+
type: "Point",
|
|
3811
|
+
coordinates: e
|
|
3812
|
+
},
|
|
3813
|
+
properties: {
|
|
3814
|
+
handleType: "vertex",
|
|
3815
|
+
index: t
|
|
3816
|
+
}
|
|
3817
|
+
})), n = e ?? this.entity.bounds, r = (n[0][0] + n[1][0]) / 2, i = (n[0][1] + n[1][1]) / 2;
|
|
3818
|
+
return t.push({
|
|
3819
|
+
type: "Feature",
|
|
3820
|
+
geometry: {
|
|
3821
|
+
type: "Point",
|
|
3822
|
+
coordinates: [r, i]
|
|
3823
|
+
},
|
|
3824
|
+
properties: {
|
|
3825
|
+
handleType: "move",
|
|
3826
|
+
index: 0
|
|
3827
|
+
}
|
|
3828
|
+
}), {
|
|
3829
|
+
type: "FeatureCollection",
|
|
3830
|
+
features: t
|
|
3831
|
+
};
|
|
3832
|
+
}
|
|
3833
|
+
createEditLayers() {
|
|
3834
|
+
this.map.getSource(this.editSourceId) || (ensureMoveIcon(this.map), this.map.addSource(this.editSourceId, {
|
|
3835
|
+
type: "geojson",
|
|
3836
|
+
data: this.getEditHandleGeoJSON()
|
|
3837
|
+
}), this.map.addLayer({
|
|
3838
|
+
id: this.editHandleLayerId,
|
|
3839
|
+
type: "circle",
|
|
3840
|
+
source: this.editSourceId,
|
|
3841
|
+
filter: [
|
|
3842
|
+
"==",
|
|
3843
|
+
["get", "handleType"],
|
|
3844
|
+
"vertex"
|
|
3845
|
+
],
|
|
3846
|
+
paint: {
|
|
3847
|
+
"circle-radius": 6,
|
|
3848
|
+
"circle-color": "#ffffff",
|
|
3849
|
+
"circle-stroke-color": "#3388ff",
|
|
3850
|
+
"circle-stroke-width": 2
|
|
3851
|
+
}
|
|
3852
|
+
}), this.map.addLayer({
|
|
3853
|
+
id: this.editMoveLayerId,
|
|
3854
|
+
type: "symbol",
|
|
3855
|
+
source: this.editSourceId,
|
|
3856
|
+
filter: [
|
|
3857
|
+
"==",
|
|
3858
|
+
["get", "handleType"],
|
|
3859
|
+
"move"
|
|
3860
|
+
],
|
|
3861
|
+
layout: {
|
|
3862
|
+
"icon-image": MOVE_ICON_ID,
|
|
3863
|
+
"icon-allow-overlap": !0,
|
|
3864
|
+
"icon-ignore-placement": !0
|
|
3865
|
+
}
|
|
3866
|
+
}));
|
|
3867
|
+
}
|
|
3868
|
+
removeEditLayers() {
|
|
3869
|
+
this.map.getLayer(this.editMoveLayerId) && this.map.removeLayer(this.editMoveLayerId), this.map.getLayer(this.editHandleLayerId) && this.map.removeLayer(this.editHandleLayerId), this.map.getSource(this.editSourceId) && this.map.removeSource(this.editSourceId);
|
|
3870
|
+
}
|
|
3871
|
+
refreshEditHandles(e) {
|
|
3872
|
+
let t = this.map.getSource(this.editSourceId);
|
|
3873
|
+
t && t.setData(this.getEditHandleGeoJSON(e));
|
|
3874
|
+
}
|
|
3875
|
+
setEditing(e) {
|
|
3876
|
+
this.isEditing !== e && (this.isEditing = e, this.initialized && (e ? this.createEditLayers() : this.removeEditLayers()));
|
|
3877
|
+
}
|
|
3878
|
+
getEditHandleAt(e, t) {
|
|
3879
|
+
if (!this.isEditing) return null;
|
|
3880
|
+
let n = this.getCorners(), r = this.map.project(e), i = this.calculateRectangleCenter(), a = this.map.project(i), o = r.x - a.x, s = r.y - a.y;
|
|
3881
|
+
if (o * o + s * s <= 144) return {
|
|
3882
|
+
type: "move",
|
|
3883
|
+
index: 0,
|
|
3884
|
+
position: i
|
|
3885
|
+
};
|
|
3886
|
+
for (let e = 0; e < n.length; e++) {
|
|
3887
|
+
let t = this.map.project(n[e]), i = r.x - t.x, a = r.y - t.y;
|
|
3888
|
+
if (i * i + a * a <= 100) return {
|
|
3889
|
+
type: "vertex",
|
|
3890
|
+
index: e,
|
|
3891
|
+
position: n[e]
|
|
3892
|
+
};
|
|
3893
|
+
}
|
|
3894
|
+
return null;
|
|
3895
|
+
}
|
|
3896
|
+
computeNewBounds(e, t) {
|
|
3897
|
+
let n = this.getCorners(), r = (e + 2) % 4, i = n[r];
|
|
3898
|
+
return [[Math.min(t[0], i[0]), Math.min(t[1], i[1])], [Math.max(t[0], i[0]), Math.max(t[1], i[1])]];
|
|
3899
|
+
}
|
|
3900
|
+
offsetBounds(e, t, n) {
|
|
3901
|
+
let r = n[0] - t[0], i = n[1] - t[1];
|
|
3902
|
+
return [[e[0][0] + r, e[0][1] + i], [e[1][0] + r, e[1][1] + i]];
|
|
3903
|
+
}
|
|
3904
|
+
applyHandleMove(e, t) {
|
|
3905
|
+
let n;
|
|
3906
|
+
n = e.type === "move" ? this.offsetBounds(this.entity.bounds, e.position, t) : this.computeNewBounds(e.index, t);
|
|
3907
|
+
let r = {
|
|
3908
|
+
...this.entity,
|
|
3909
|
+
bounds: n
|
|
3910
|
+
};
|
|
3911
|
+
this.entity = r;
|
|
3912
|
+
let i = this.map.getSource(this.sourceId);
|
|
3913
|
+
return i && i.setData(this.getGeoJSON()), this.refreshEditHandles(), r;
|
|
3914
|
+
}
|
|
3915
|
+
updateEditPreview(e, t) {
|
|
3916
|
+
let n;
|
|
3917
|
+
n = e.type === "move" ? this.offsetBounds(this.entity.bounds, e.position, t) : this.computeNewBounds(e.index, t);
|
|
3918
|
+
let r = this.entity;
|
|
3919
|
+
this.entity = {
|
|
3920
|
+
...this.entity,
|
|
3921
|
+
bounds: n
|
|
3922
|
+
};
|
|
3923
|
+
let i = this.map.getSource(this.sourceId);
|
|
3924
|
+
i && i.setData(this.getGeoJSON()), this.entity = r, this.refreshEditHandles(n);
|
|
3925
|
+
}
|
|
3926
|
+
cancelEditPreview() {
|
|
3927
|
+
let e = this.map.getSource(this.sourceId);
|
|
3928
|
+
e && e.setData(this.getGeoJSON()), this.refreshEditHandles();
|
|
2779
3929
|
}
|
|
2780
3930
|
destroy() {
|
|
2781
|
-
this.initialized &&= (this.map.getLayer(this.lengthLayerId) && this.map.removeLayer(this.lengthLayerId), this.map.getLayer(this.areaLayerId) && this.map.removeLayer(this.areaLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.strokeLayerId) && this.map.removeLayer(this.strokeLayerId), this.map.getLayer(this.fillLayerId) && this.map.removeLayer(this.fillLayerId), this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId), !1);
|
|
3931
|
+
this.initialized &&= (this.removeEditLayers(), this.map.getLayer(this.lengthLayerId) && this.map.removeLayer(this.lengthLayerId), this.map.getLayer(this.areaLayerId) && this.map.removeLayer(this.areaLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.strokeLayerId) && this.map.removeLayer(this.strokeLayerId), this.map.getLayer(this.fillLayerId) && this.map.removeLayer(this.fillLayerId), this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId), !1);
|
|
2782
3932
|
}
|
|
2783
3933
|
};
|
|
2784
3934
|
const EntityPopup = ({ popupState: e, onClose: r, portalContainer: i, popupRef: s }) => {
|
|
@@ -3505,61 +4655,65 @@ function clearAllPreviewSources(e) {
|
|
|
3505
4655
|
"polyline-vertices-source"
|
|
3506
4656
|
]) clearPreviewSource(e, `${PREVIEW_PREFIX}${t}`);
|
|
3507
4657
|
}
|
|
3508
|
-
function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i,
|
|
3509
|
-
let [
|
|
4658
|
+
function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDrawModeChange: s, className: c = "", style: l }) {
|
|
4659
|
+
let [u, d] = useState(!1), [f, g] = useState(null), [_, v] = useState({
|
|
3510
4660
|
showArea: !0,
|
|
3511
4661
|
showLength: !0,
|
|
3512
4662
|
showRadius: !0
|
|
3513
|
-
}),
|
|
4663
|
+
}), y = r !== void 0, b = y ? {
|
|
3514
4664
|
showArea: r.showArea ?? !0,
|
|
3515
4665
|
showLength: r.showLength ?? !0,
|
|
3516
4666
|
showRadius: r.showRadius ?? !0
|
|
3517
|
-
} :
|
|
3518
|
-
|
|
3519
|
-
let
|
|
3520
|
-
|
|
3521
|
-
let
|
|
3522
|
-
|
|
4667
|
+
} : _, [x, S] = useState([]), C = useRef(/* @__PURE__ */ new Map()), T = useRef(0), E = useRef(null), D = useRef(null), O = useRef(null), k = useRef(null), A = useRef(null), j = useRef([]), M = useRef([]), N = useRef(b);
|
|
4668
|
+
N.current = b;
|
|
4669
|
+
let Ce = useRef(f);
|
|
4670
|
+
Ce.current = f;
|
|
4671
|
+
let P = useCallback(() => `measure-${++T.current}`, []);
|
|
4672
|
+
useEffect(() => {
|
|
4673
|
+
s?.(f !== null);
|
|
4674
|
+
}, [f, s]);
|
|
4675
|
+
let we = useRef(!1), Te = useCallback(() => {
|
|
4676
|
+
!e || !e.isStyleLoaded() || (initAllPreviewLayers(e), we.current = !0);
|
|
3523
4677
|
}, [e]);
|
|
3524
4678
|
useEffect(() => {
|
|
3525
4679
|
if (!e) return;
|
|
3526
4680
|
let t = () => {
|
|
3527
|
-
initAllPreviewLayers(e),
|
|
4681
|
+
initAllPreviewLayers(e), we.current = !0;
|
|
3528
4682
|
};
|
|
3529
4683
|
e.isStyleLoaded() ? t() : e.once("load", t);
|
|
3530
4684
|
let n = () => {
|
|
3531
|
-
|
|
4685
|
+
we.current = !1;
|
|
3532
4686
|
};
|
|
3533
4687
|
return e.on("style.load", n), () => {
|
|
3534
4688
|
e.off("style.load", n);
|
|
3535
4689
|
};
|
|
3536
4690
|
}, [e]), useEffect(() => {
|
|
3537
4691
|
let e = (e) => {
|
|
3538
|
-
|
|
4692
|
+
E.current && !E.current.contains(e.target) && D.current && !D.current.contains(e.target) && d(!1);
|
|
3539
4693
|
};
|
|
3540
4694
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
3541
4695
|
}, []);
|
|
3542
|
-
let
|
|
4696
|
+
let F = useCallback((t) => {
|
|
3543
4697
|
if (!e) return;
|
|
3544
|
-
let n = applyEntityConfig(t,
|
|
4698
|
+
let n = applyEntityConfig(t, N.current), r = null;
|
|
3545
4699
|
if (n.type === "circle" ? r = new CircleRenderer(e, n) : n.type === "square" ? r = new SquareRenderer(e, n) : n.type === "rectangle" ? r = new RectangleRenderer(e, n) : n.type === "polygon" ? r = new PolygonRenderer(e, n) : n.type === "polyline" && (r = new PolylineRenderer(e, n)), r) {
|
|
3546
|
-
|
|
4700
|
+
C.current.set(n.id, r);
|
|
3547
4701
|
let e = {
|
|
3548
4702
|
entity: n,
|
|
3549
4703
|
shapeLabel: SHAPE_LABELS[n.type] || n.type,
|
|
3550
4704
|
area: computeEntityArea(n),
|
|
3551
4705
|
lengthOrRadius: computeEntityLengthOrRadius(n)
|
|
3552
4706
|
};
|
|
3553
|
-
|
|
3554
|
-
}
|
|
3555
|
-
}, [e]),
|
|
3556
|
-
let t =
|
|
3557
|
-
t && (t.destroy(),
|
|
3558
|
-
}, []),
|
|
3559
|
-
|
|
3560
|
-
}, []),
|
|
4707
|
+
S((t) => [...t, e]);
|
|
4708
|
+
}
|
|
4709
|
+
}, [e]), Ee = useCallback((e) => {
|
|
4710
|
+
let t = C.current.get(e);
|
|
4711
|
+
t && (t.destroy(), C.current.delete(e)), S((t) => t.filter((t) => t.entity.id !== e));
|
|
4712
|
+
}, []), De = useCallback(() => {
|
|
4713
|
+
C.current.forEach((e) => e.destroy()), C.current.clear(), S([]);
|
|
4714
|
+
}, []), Oe = useCallback((t) => {
|
|
3561
4715
|
if (!e) return;
|
|
3562
|
-
let n =
|
|
4716
|
+
let n = C.current.get(t);
|
|
3563
4717
|
if (!n) return;
|
|
3564
4718
|
let r = n.getBounds();
|
|
3565
4719
|
e.fitBounds(r, {
|
|
@@ -3567,21 +4721,21 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3567
4721
|
maxZoom: 18,
|
|
3568
4722
|
duration: 1e3
|
|
3569
4723
|
});
|
|
3570
|
-
}, [e]),
|
|
4724
|
+
}, [e]), ke = useCallback((e, t) => {
|
|
3571
4725
|
let n = {
|
|
3572
|
-
...
|
|
4726
|
+
...N.current,
|
|
3573
4727
|
[e]: t
|
|
3574
4728
|
};
|
|
3575
|
-
|
|
4729
|
+
y ? i?.({ ...n }) : v(n), S((t) => t.map((t) => {
|
|
3576
4730
|
let r = { ...t.entity };
|
|
3577
4731
|
r[e] = void 0;
|
|
3578
|
-
let i = applyEntityConfig(r, n), a =
|
|
4732
|
+
let i = applyEntityConfig(r, n), a = C.current.get(t.entity.id);
|
|
3579
4733
|
return a && a.update(i), {
|
|
3580
4734
|
...t,
|
|
3581
4735
|
entity: i
|
|
3582
4736
|
};
|
|
3583
4737
|
}));
|
|
3584
|
-
}, [
|
|
4738
|
+
}, [y, i]), Ae = useCallback((t, n) => {
|
|
3585
4739
|
if (!e) return;
|
|
3586
4740
|
let [r, i] = t, [a, o] = n, s = [
|
|
3587
4741
|
[Math.min(r, a), Math.max(i, o)],
|
|
@@ -3600,7 +4754,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3600
4754
|
});
|
|
3601
4755
|
let l = e.getSource(`${PREVIEW_PREFIX}rect-preview-measure-source`);
|
|
3602
4756
|
if (l) {
|
|
3603
|
-
let e =
|
|
4757
|
+
let e = N.current, t = [], n = s[0], r = s[1], i = s[2];
|
|
3604
4758
|
if (e?.showArea) {
|
|
3605
4759
|
let e = distance(n, r), a = distance(r, i);
|
|
3606
4760
|
t.push({
|
|
@@ -3631,7 +4785,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3631
4785
|
features: t
|
|
3632
4786
|
});
|
|
3633
4787
|
}
|
|
3634
|
-
}, [e]),
|
|
4788
|
+
}, [e]), je = useCallback((t, n) => {
|
|
3635
4789
|
if (!e) return;
|
|
3636
4790
|
let r = calculateDistance(t, n), i = createCirclePolygon(t, r), a = e.getSource(`${PREVIEW_PREFIX}circle-preview-source`);
|
|
3637
4791
|
a && a.setData({
|
|
@@ -3642,7 +4796,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3642
4796
|
},
|
|
3643
4797
|
properties: {}
|
|
3644
4798
|
});
|
|
3645
|
-
let o =
|
|
4799
|
+
let o = N.current, s = [], c = [];
|
|
3646
4800
|
if (o?.showArea && s.push({
|
|
3647
4801
|
type: "Feature",
|
|
3648
4802
|
geometry: {
|
|
@@ -3678,7 +4832,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3678
4832
|
type: "FeatureCollection",
|
|
3679
4833
|
features: c
|
|
3680
4834
|
});
|
|
3681
|
-
}, [e]),
|
|
4835
|
+
}, [e]), Me = useCallback((t, n) => {
|
|
3682
4836
|
if (!e) return;
|
|
3683
4837
|
let r = calculateDistance(t, n) * 2, i = createSquareCoords(t, r), a = e.getSource(`${PREVIEW_PREFIX}square-preview-source`);
|
|
3684
4838
|
a && a.setData({
|
|
@@ -3691,7 +4845,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3691
4845
|
});
|
|
3692
4846
|
let o = e.getSource(`${PREVIEW_PREFIX}square-preview-measure-source`);
|
|
3693
4847
|
if (o) {
|
|
3694
|
-
let e =
|
|
4848
|
+
let e = N.current, n = [];
|
|
3695
4849
|
if (e?.showArea && n.push({
|
|
3696
4850
|
type: "Feature",
|
|
3697
4851
|
geometry: {
|
|
@@ -3715,7 +4869,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3715
4869
|
features: n
|
|
3716
4870
|
});
|
|
3717
4871
|
}
|
|
3718
|
-
}, [e]),
|
|
4872
|
+
}, [e]), Ne = useCallback((t, n) => {
|
|
3719
4873
|
if (!e) return;
|
|
3720
4874
|
let r = [...t, n], i = e.getSource(`${PREVIEW_PREFIX}polygon-preview-source`);
|
|
3721
4875
|
i && (r.length >= 3 ? i.setData({
|
|
@@ -3750,7 +4904,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3750
4904
|
});
|
|
3751
4905
|
let o = e.getSource(`${PREVIEW_PREFIX}polygon-preview-measure-source`);
|
|
3752
4906
|
if (o) {
|
|
3753
|
-
let e =
|
|
4907
|
+
let e = N.current, t = [];
|
|
3754
4908
|
if (e?.showArea && r.length >= 3) {
|
|
3755
4909
|
let e = polygonArea([...r, r[0]]), n = 0, i = 0;
|
|
3756
4910
|
for (let e of r) n += e[0], i += e[1];
|
|
@@ -3792,7 +4946,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3792
4946
|
features: t
|
|
3793
4947
|
});
|
|
3794
4948
|
}
|
|
3795
|
-
}, [e]),
|
|
4949
|
+
}, [e]), I = useCallback((t, n) => {
|
|
3796
4950
|
if (!e) return;
|
|
3797
4951
|
let r = [...t, n], i = e.getSource(`${PREVIEW_PREFIX}polyline-preview-source`);
|
|
3798
4952
|
i && (r.length >= 2 ? i.setData({
|
|
@@ -3820,7 +4974,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3820
4974
|
});
|
|
3821
4975
|
let o = e.getSource(`${PREVIEW_PREFIX}polyline-preview-measure-source`);
|
|
3822
4976
|
if (o) {
|
|
3823
|
-
let e =
|
|
4977
|
+
let e = N.current, t = [];
|
|
3824
4978
|
if (e?.showLength && r.length >= 2) for (let e = 0; e < r.length - 1; e++) {
|
|
3825
4979
|
let n = r[e], i = r[e + 1];
|
|
3826
4980
|
t.push({
|
|
@@ -3839,118 +4993,118 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3839
4993
|
}
|
|
3840
4994
|
}, [e]);
|
|
3841
4995
|
useEffect(() => {
|
|
3842
|
-
if (!e || !
|
|
3843
|
-
|
|
4996
|
+
if (!e || !f) return;
|
|
4997
|
+
Te(), e.getCanvas().style.cursor = "crosshair";
|
|
3844
4998
|
let t = (t) => {
|
|
3845
|
-
let n = [t.lngLat.lng, t.lngLat.lat], r =
|
|
4999
|
+
let n = [t.lngLat.lng, t.lngLat.lat], r = Ce.current;
|
|
3846
5000
|
if (r === "rectangle") {
|
|
3847
|
-
let t =
|
|
3848
|
-
if (!t)
|
|
5001
|
+
let t = O.current;
|
|
5002
|
+
if (!t) O.current = n;
|
|
3849
5003
|
else {
|
|
3850
5004
|
let r = {
|
|
3851
|
-
id:
|
|
5005
|
+
id: P(),
|
|
3852
5006
|
type: "rectangle",
|
|
3853
5007
|
bounds: [t, n]
|
|
3854
5008
|
};
|
|
3855
|
-
|
|
5009
|
+
F(r), O.current = null, clearAllPreviewSources(e), g(null);
|
|
3856
5010
|
}
|
|
3857
5011
|
} else if (r === "circle") {
|
|
3858
|
-
let t =
|
|
3859
|
-
if (!t)
|
|
5012
|
+
let t = k.current;
|
|
5013
|
+
if (!t) k.current = { center: n };
|
|
3860
5014
|
else {
|
|
3861
5015
|
let r = calculateDistance(t.center, n), i = {
|
|
3862
|
-
id:
|
|
5016
|
+
id: P(),
|
|
3863
5017
|
type: "circle",
|
|
3864
5018
|
center: t.center,
|
|
3865
5019
|
radius: r
|
|
3866
5020
|
};
|
|
3867
|
-
|
|
5021
|
+
F(i), k.current = null, clearAllPreviewSources(e), g(null);
|
|
3868
5022
|
}
|
|
3869
5023
|
} else if (r === "square") {
|
|
3870
|
-
let t =
|
|
3871
|
-
if (!t)
|
|
5024
|
+
let t = A.current;
|
|
5025
|
+
if (!t) A.current = { center: n };
|
|
3872
5026
|
else {
|
|
3873
5027
|
let r = calculateDistance(t.center, n) * 2, i = {
|
|
3874
|
-
id:
|
|
5028
|
+
id: P(),
|
|
3875
5029
|
type: "square",
|
|
3876
5030
|
center: t.center,
|
|
3877
5031
|
length: r
|
|
3878
5032
|
};
|
|
3879
|
-
|
|
5033
|
+
F(i), A.current = null, clearAllPreviewSources(e), g(null);
|
|
3880
5034
|
}
|
|
3881
5035
|
} else if (r === "polygon") {
|
|
3882
|
-
let t =
|
|
5036
|
+
let t = j.current;
|
|
3883
5037
|
if (t.length >= 3 && calculateDistance(t[0], n) < 20) {
|
|
3884
5038
|
let n = {
|
|
3885
|
-
id:
|
|
5039
|
+
id: P(),
|
|
3886
5040
|
type: "polygon",
|
|
3887
5041
|
coordinates: [...t]
|
|
3888
5042
|
};
|
|
3889
|
-
|
|
5043
|
+
F(n), j.current = [], clearAllPreviewSources(e), g(null);
|
|
3890
5044
|
return;
|
|
3891
5045
|
}
|
|
3892
|
-
|
|
3893
|
-
} else r === "polyline" && (
|
|
5046
|
+
j.current = [...t, n];
|
|
5047
|
+
} else r === "polyline" && (M.current = [...M.current, n]);
|
|
3894
5048
|
}, n = (e) => {
|
|
3895
|
-
let t = [e.lngLat.lng, e.lngLat.lat], n =
|
|
3896
|
-
if (n === "rectangle" &&
|
|
3897
|
-
else if (n === "circle" &&
|
|
3898
|
-
else if (n === "square" &&
|
|
5049
|
+
let t = [e.lngLat.lng, e.lngLat.lat], n = Ce.current;
|
|
5050
|
+
if (n === "rectangle" && O.current) Ae(O.current, t);
|
|
5051
|
+
else if (n === "circle" && k.current) je(k.current.center, t);
|
|
5052
|
+
else if (n === "square" && A.current) Me(A.current.center, t);
|
|
3899
5053
|
else if (n === "polygon") {
|
|
3900
|
-
let e = A.current;
|
|
3901
|
-
e.length > 0 && Me(e, t);
|
|
3902
|
-
} else if (n === "polyline") {
|
|
3903
5054
|
let e = j.current;
|
|
3904
|
-
e.length > 0 &&
|
|
5055
|
+
e.length > 0 && Ne(e, t);
|
|
5056
|
+
} else if (n === "polyline") {
|
|
5057
|
+
let e = M.current;
|
|
5058
|
+
e.length > 0 && I(e, t);
|
|
3905
5059
|
}
|
|
3906
5060
|
}, r = (t) => {
|
|
3907
5061
|
t.preventDefault();
|
|
3908
|
-
let n =
|
|
5062
|
+
let n = Ce.current;
|
|
3909
5063
|
if (n === "polygon") {
|
|
3910
|
-
let t =
|
|
5064
|
+
let t = j.current;
|
|
3911
5065
|
if (t.length >= 3) {
|
|
3912
5066
|
let n = {
|
|
3913
|
-
id:
|
|
5067
|
+
id: P(),
|
|
3914
5068
|
type: "polygon",
|
|
3915
5069
|
coordinates: [...t]
|
|
3916
5070
|
};
|
|
3917
|
-
|
|
3918
|
-
} else
|
|
5071
|
+
F(n), j.current = [], clearAllPreviewSources(e), g(null);
|
|
5072
|
+
} else j.current = [], clearAllPreviewSources(e);
|
|
3919
5073
|
} else if (n === "polyline") {
|
|
3920
|
-
let t =
|
|
5074
|
+
let t = M.current;
|
|
3921
5075
|
if (t.length >= 2) {
|
|
3922
5076
|
let n = {
|
|
3923
|
-
id:
|
|
5077
|
+
id: P(),
|
|
3924
5078
|
type: "polyline",
|
|
3925
5079
|
coordinates: [...t]
|
|
3926
5080
|
};
|
|
3927
|
-
|
|
3928
|
-
} else
|
|
5081
|
+
F(n), M.current = [], clearAllPreviewSources(e), g(null);
|
|
5082
|
+
} else M.current = [], clearAllPreviewSources(e);
|
|
3929
5083
|
}
|
|
3930
5084
|
}, i = (t) => {
|
|
3931
|
-
t.key === "Escape" && (
|
|
5085
|
+
t.key === "Escape" && (O.current = null, k.current = null, A.current = null, j.current = [], M.current = [], clearAllPreviewSources(e), g(null));
|
|
3932
5086
|
}, a = (t) => {
|
|
3933
5087
|
t.preventDefault();
|
|
3934
|
-
let n =
|
|
5088
|
+
let n = Ce.current;
|
|
3935
5089
|
if (n === "polygon") {
|
|
3936
|
-
let t =
|
|
5090
|
+
let t = j.current;
|
|
3937
5091
|
if (t.length >= 3) {
|
|
3938
5092
|
let n = {
|
|
3939
|
-
id:
|
|
5093
|
+
id: P(),
|
|
3940
5094
|
type: "polygon",
|
|
3941
5095
|
coordinates: [...t]
|
|
3942
5096
|
};
|
|
3943
|
-
|
|
5097
|
+
F(n), j.current = [], clearAllPreviewSources(e), g(null);
|
|
3944
5098
|
}
|
|
3945
5099
|
} else if (n === "polyline") {
|
|
3946
|
-
let t =
|
|
5100
|
+
let t = M.current;
|
|
3947
5101
|
if (t.length >= 2) {
|
|
3948
5102
|
let n = {
|
|
3949
|
-
id:
|
|
5103
|
+
id: P(),
|
|
3950
5104
|
type: "polyline",
|
|
3951
5105
|
coordinates: [...t]
|
|
3952
5106
|
};
|
|
3953
|
-
|
|
5107
|
+
F(n), M.current = [], clearAllPreviewSources(e), g(null);
|
|
3954
5108
|
}
|
|
3955
5109
|
}
|
|
3956
5110
|
};
|
|
@@ -3959,28 +5113,28 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3959
5113
|
};
|
|
3960
5114
|
}, [
|
|
3961
5115
|
e,
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
ke,
|
|
5116
|
+
f,
|
|
5117
|
+
P,
|
|
5118
|
+
F,
|
|
5119
|
+
Te,
|
|
3967
5120
|
Ae,
|
|
3968
5121
|
je,
|
|
3969
5122
|
Me,
|
|
3970
|
-
|
|
5123
|
+
Ne,
|
|
5124
|
+
I
|
|
3971
5125
|
]), useEffect(() => () => {
|
|
3972
|
-
|
|
5126
|
+
C.current.forEach((e) => e.destroy()), C.current.clear();
|
|
3973
5127
|
}, []);
|
|
3974
|
-
let
|
|
3975
|
-
|
|
5128
|
+
let Pe = useCallback((t) => {
|
|
5129
|
+
g((e) => e === t ? null : t), O.current = null, k.current = null, A.current = null, j.current = [], M.current = [], e && clearAllPreviewSources(e);
|
|
3976
5130
|
}, [e]);
|
|
3977
5131
|
return e ? /* @__PURE__ */ jsxs("div", {
|
|
3978
|
-
className: `mapbox-measure-control ${
|
|
3979
|
-
style:
|
|
5132
|
+
className: `mapbox-measure-control ${c}`,
|
|
5133
|
+
style: l,
|
|
3980
5134
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
3981
|
-
ref:
|
|
3982
|
-
className: `mapbox-control-btn mapbox-measure-control__btn ${
|
|
3983
|
-
onClick: () =>
|
|
5135
|
+
ref: D,
|
|
5136
|
+
className: `mapbox-control-btn mapbox-measure-control__btn ${u ? "mapbox-measure-control__btn--active" : ""}`,
|
|
5137
|
+
onClick: () => d(!u),
|
|
3984
5138
|
title: "测量",
|
|
3985
5139
|
children: [
|
|
3986
5140
|
/* @__PURE__ */ jsx("img", {
|
|
@@ -3989,14 +5143,14 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
3989
5143
|
className: "mapbox-measure-control__btn-icon"
|
|
3990
5144
|
}),
|
|
3991
5145
|
/* @__PURE__ */ jsx("span", { children: "测量" }),
|
|
3992
|
-
|
|
5146
|
+
x.length > 0 && /* @__PURE__ */ jsxs("span", { children: [
|
|
3993
5147
|
"(",
|
|
3994
|
-
|
|
5148
|
+
x.length,
|
|
3995
5149
|
")"
|
|
3996
5150
|
] })
|
|
3997
5151
|
]
|
|
3998
|
-
}),
|
|
3999
|
-
ref:
|
|
5152
|
+
}), u && /* @__PURE__ */ jsxs("div", {
|
|
5153
|
+
ref: E,
|
|
4000
5154
|
className: "mapbox-measure-control__panel",
|
|
4001
5155
|
children: [
|
|
4002
5156
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -4007,18 +5161,18 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
4007
5161
|
className: "mapbox-measure-control__settings",
|
|
4008
5162
|
children: [
|
|
4009
5163
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
4010
|
-
checked:
|
|
4011
|
-
onChange: (e) =>
|
|
5164
|
+
checked: b.showArea,
|
|
5165
|
+
onChange: (e) => ke("showArea", e),
|
|
4012
5166
|
children: "面积"
|
|
4013
5167
|
}),
|
|
4014
5168
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
4015
|
-
checked:
|
|
4016
|
-
onChange: (e) =>
|
|
5169
|
+
checked: b.showLength,
|
|
5170
|
+
onChange: (e) => ke("showLength", e),
|
|
4017
5171
|
children: "长度"
|
|
4018
5172
|
}),
|
|
4019
5173
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
4020
|
-
checked:
|
|
4021
|
-
onChange: (e) =>
|
|
5174
|
+
checked: b.showRadius,
|
|
5175
|
+
onChange: (e) => ke("showRadius", e),
|
|
4022
5176
|
children: "半径"
|
|
4023
5177
|
})
|
|
4024
5178
|
]
|
|
@@ -4030,16 +5184,16 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
4030
5184
|
/* @__PURE__ */ jsxs("div", {
|
|
4031
5185
|
className: "mapbox-measure-control__tools",
|
|
4032
5186
|
children: [DRAW_TOOLS.map((e) => /* @__PURE__ */ jsx("button", {
|
|
4033
|
-
className: `mapbox-measure-control__tool-btn ${
|
|
4034
|
-
onClick: () =>
|
|
5187
|
+
className: `mapbox-measure-control__tool-btn ${f === e.mode ? "mapbox-measure-control__tool-btn--active" : ""}`,
|
|
5188
|
+
onClick: () => Pe(e.mode),
|
|
4035
5189
|
title: e.label,
|
|
4036
5190
|
children: /* @__PURE__ */ jsx("img", {
|
|
4037
5191
|
src: e.icon,
|
|
4038
5192
|
alt: e.label
|
|
4039
5193
|
})
|
|
4040
|
-
}, e.mode)),
|
|
5194
|
+
}, e.mode)), x.length > 0 && /* @__PURE__ */ jsx("button", {
|
|
4041
5195
|
className: "mapbox-measure-control__tool-btn mapbox-measure-control__tool-btn--danger",
|
|
4042
|
-
onClick:
|
|
5196
|
+
onClick: De,
|
|
4043
5197
|
title: "清除全部",
|
|
4044
5198
|
children: /* @__PURE__ */ jsx("img", {
|
|
4045
5199
|
src: "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769394652565'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6483'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M841.385637%20288.639098a36.479886%2036.479886%200%200%201%2072.74644%207.679976l6.613312%20629.544699A109.866323%20109.866323%200%200%201%20810.665733%201023.9968H222.507571a109.652991%20109.652991%200%200%201-109.012992-98.133027l-3.626656-629.544699a36.479886%2036.479886%200%200%201%2072.74644-7.679976L186.241018%20917.330467a36.479886%2036.479886%200%200%200%2036.266553%2032.639898H810.665733A36.479886%2036.479886%200%200%200%20847.99895%20917.330467z%20m-219.732646%20113.706311a36.479886%2036.479886%200%200%201%2036.693218%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.479886-36.479886z%20m-219.305982%200a36.479886%2036.479886%200%200%201%2036.479886%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.693218-36.479886z%20m-36.693218-255.9992h292.692418V91.519714a18.346609%2018.346609%200%200%200-18.346609-18.346609H384.0004a18.346609%2018.346609%200%200%200-18.346609%2018.346609z%20m-73.173105%200V73.173105A73.173105%2073.173105%200%200%201%20365.653791%200h292.692418a73.386437%2073.386437%200%200%201%2073.173105%2073.173105v73.173104h255.9992a36.693219%2036.693219%200%200%201%200%2073.173105H36.481486a36.693219%2036.693219%200%200%201%200-73.173105z'%20fill='%23EB6865'%20p-id='6484'%3e%3c/path%3e%3c/svg%3e",
|
|
@@ -4047,7 +5201,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
4047
5201
|
})
|
|
4048
5202
|
})]
|
|
4049
5203
|
}),
|
|
4050
|
-
|
|
5204
|
+
x.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
4051
5205
|
className: "mapbox-measure-control__list",
|
|
4052
5206
|
children: /* @__PURE__ */ jsxs("table", {
|
|
4053
5207
|
className: "mapbox-measure-control__table",
|
|
@@ -4057,9 +5211,9 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
4057
5211
|
/* @__PURE__ */ jsx("th", { children: "面积" }),
|
|
4058
5212
|
/* @__PURE__ */ jsx("th", { children: "长度/半径" }),
|
|
4059
5213
|
/* @__PURE__ */ jsx("th", {})
|
|
4060
|
-
] }) }), /* @__PURE__ */ jsx("tbody", { children:
|
|
5214
|
+
] }) }), /* @__PURE__ */ jsx("tbody", { children: x.map((e) => /* @__PURE__ */ jsxs("tr", {
|
|
4061
5215
|
className: "mapbox-measure-control__table-row",
|
|
4062
|
-
onClick: () =>
|
|
5216
|
+
onClick: () => Oe(e.entity.id),
|
|
4063
5217
|
children: [
|
|
4064
5218
|
/* @__PURE__ */ jsx("td", { children: e.shapeLabel }),
|
|
4065
5219
|
/* @__PURE__ */ jsx("td", { children: String(e.entity.id) }),
|
|
@@ -4068,7 +5222,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
|
|
|
4068
5222
|
/* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx("button", {
|
|
4069
5223
|
className: "mapbox-measure-control__delete-btn",
|
|
4070
5224
|
onClick: (t) => {
|
|
4071
|
-
t.stopPropagation(),
|
|
5225
|
+
t.stopPropagation(), Ee(e.entity.id);
|
|
4072
5226
|
},
|
|
4073
5227
|
title: "删除",
|
|
4074
5228
|
children: /* @__PURE__ */ jsx("img", {
|
|
@@ -4403,6 +5557,220 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
|
|
|
4403
5557
|
});
|
|
4404
5558
|
return createPortal(d, i);
|
|
4405
5559
|
};
|
|
5560
|
+
var route_planning_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1775031767174'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='30653'%20data-spm-anchor-id='a313x.search_index.0.i6.78953a81FCkAe0'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='64'%20height='64'%3e%3cpath%20d='M322.24%20479.210667l-42.453333-42.432%20198.826666-198.826667c53.397333-53.376%20139.306667-53.568%20191.914667-0.981333%2052.608%2052.608%2052.416%20138.517333-0.981333%20191.914666L455.722667%20642.709333l-42.432-42.453333%20213.824-213.802667a74.773333%2074.773333%200%200%200-0.341334-105.728%2074.773333%2074.773333%200%200%200-105.728-0.341333l-198.826666%20198.826667z'%20fill='%23ffffff'%20p-id='30654'%3e%3c/path%3e%3cpath%20d='M699.093333%20613.333333l42.453334%2042.432-169.429334%20169.408c-48.341333%2048.341333-129.28%2042.282667-181.248-9.664-51.968-51.968-58.026667-132.906667-9.664-181.248l234.346667-234.346666%2042.432%2042.410666L423.616%20676.693333c-22.250667%2022.250667-19.050667%2065.024%2011.008%2095.061334%2030.037333%2030.058667%2072.810667%2033.258667%2095.061333%2010.986666l169.429334-169.408zM187.989333%20571.029333c-38.933333-38.933333-38.805333-102.613333%200.853334-142.293333%2039.68-39.68%20103.381333-39.808%20142.293333-0.853333%2038.954667%2038.912%2038.826667%20102.613333-0.853333%20142.293333-39.68%2039.658667-103.381333%2039.786667-142.293334%200.853333z%20m43.733334-43.733333c15.744%2015.744%2040.874667%2015.68%2056.128%200.426667%2015.253333-15.232%2015.296-40.362667-0.426667-56.106667-15.765333-15.744-40.896-15.701333-56.149333-0.448-15.232%2015.232-15.296%2040.384%200.448%2056.106667z'%20fill='%23ffffff'%20p-id='30655'%3e%3c/path%3e%3cpath%20d='M846.144%20489.728l-31.466667%20198.784-56.96-101.461333-104.042666-38.506667z'%20fill='%23ffffff'%20p-id='30656'%3e%3c/path%3e%3c/svg%3e", SOURCE_ID = "route-planning-temp-line", LINE_LAYER_ID = "route-planning-temp-line-layer", POINT_LAYER_ID = "route-planning-temp-point-layer";
|
|
5561
|
+
const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointCountInput: c = !1, visualType: l = "marker", onSelectFinished: u, showButton: d = !0 }, f) => {
|
|
5562
|
+
let [h, g] = useState("idle"), [_, v] = useState(0), [y, b] = useState(i), [x, S] = useState(!1), C = useRef(null), w = useRef(null), T = useRef([]), E = useRef([]), D = useRef("idle"), O = useRef(null), ve = useRef("");
|
|
5563
|
+
useEffect(() => {
|
|
5564
|
+
D.current = h;
|
|
5565
|
+
}, [h]), useEffect(() => {
|
|
5566
|
+
b(i);
|
|
5567
|
+
}, [i]), useEffect(() => {
|
|
5568
|
+
if (!x) return;
|
|
5569
|
+
let e = (e) => {
|
|
5570
|
+
w.current && !w.current.contains(e.target) && C.current && !C.current.contains(e.target) && S(!1);
|
|
5571
|
+
}, t = setTimeout(() => {
|
|
5572
|
+
document.addEventListener("mousedown", e);
|
|
5573
|
+
}, 0);
|
|
5574
|
+
return () => {
|
|
5575
|
+
clearTimeout(t), document.removeEventListener("mousedown", e);
|
|
5576
|
+
};
|
|
5577
|
+
}, [x]);
|
|
5578
|
+
let ye = useCallback(() => {
|
|
5579
|
+
for (let e of E.current) e.remove();
|
|
5580
|
+
E.current = [], e && (e.getLayer(LINE_LAYER_ID) && e.removeLayer(LINE_LAYER_ID), e.getLayer(POINT_LAYER_ID) && e.removeLayer(POINT_LAYER_ID), e.getSource(SOURCE_ID) && e.removeSource(SOURCE_ID));
|
|
5581
|
+
}, [e]), k = useCallback(() => {
|
|
5582
|
+
if (!e) return;
|
|
5583
|
+
let t = T.current, n = {
|
|
5584
|
+
type: "FeatureCollection",
|
|
5585
|
+
features: [{
|
|
5586
|
+
type: "Feature",
|
|
5587
|
+
properties: {},
|
|
5588
|
+
geometry: {
|
|
5589
|
+
type: "LineString",
|
|
5590
|
+
coordinates: t.length >= 2 ? t : []
|
|
5591
|
+
}
|
|
5592
|
+
}, ...t.map((e, t) => ({
|
|
5593
|
+
type: "Feature",
|
|
5594
|
+
properties: { index: t },
|
|
5595
|
+
geometry: {
|
|
5596
|
+
type: "Point",
|
|
5597
|
+
coordinates: e
|
|
5598
|
+
}
|
|
5599
|
+
}))]
|
|
5600
|
+
}, r = e.getSource(SOURCE_ID);
|
|
5601
|
+
r ? r.setData(n) : (e.addSource(SOURCE_ID, {
|
|
5602
|
+
type: "geojson",
|
|
5603
|
+
data: n
|
|
5604
|
+
}), e.addLayer({
|
|
5605
|
+
id: LINE_LAYER_ID,
|
|
5606
|
+
type: "line",
|
|
5607
|
+
source: SOURCE_ID,
|
|
5608
|
+
filter: [
|
|
5609
|
+
"==",
|
|
5610
|
+
"$type",
|
|
5611
|
+
"LineString"
|
|
5612
|
+
],
|
|
5613
|
+
paint: {
|
|
5614
|
+
"line-color": "#4A90D9",
|
|
5615
|
+
"line-width": 3,
|
|
5616
|
+
"line-dasharray": [2, 2]
|
|
5617
|
+
}
|
|
5618
|
+
}), e.addLayer({
|
|
5619
|
+
id: POINT_LAYER_ID,
|
|
5620
|
+
type: "circle",
|
|
5621
|
+
source: SOURCE_ID,
|
|
5622
|
+
filter: [
|
|
5623
|
+
"==",
|
|
5624
|
+
"$type",
|
|
5625
|
+
"Point"
|
|
5626
|
+
],
|
|
5627
|
+
paint: {
|
|
5628
|
+
"circle-radius": 6,
|
|
5629
|
+
"circle-color": "#4A90D9",
|
|
5630
|
+
"circle-stroke-width": 2,
|
|
5631
|
+
"circle-stroke-color": "#fff"
|
|
5632
|
+
}
|
|
5633
|
+
}));
|
|
5634
|
+
}, [e]), be = useCallback((t) => {
|
|
5635
|
+
if (!e || !O.current) return;
|
|
5636
|
+
let { visualType: n } = O.current;
|
|
5637
|
+
if (n === "marker") {
|
|
5638
|
+
let n = document.createElement("div");
|
|
5639
|
+
n.className = "route-planning-temp-marker", n.textContent = String(T.current.length);
|
|
5640
|
+
let r = new mapboxgl.Marker({ element: n }).setLngLat(t).addTo(e);
|
|
5641
|
+
E.current.push(r);
|
|
5642
|
+
} else k();
|
|
5643
|
+
}, [e, k]), xe = useCallback(() => {
|
|
5644
|
+
ye(), T.current = [], O.current = null, v(0), g("idle"), e && (e.getCanvas().style.cursor = ve.current);
|
|
5645
|
+
}, [ye, e]), Se = useCallback(async () => {
|
|
5646
|
+
let e = O.current, t = [...T.current];
|
|
5647
|
+
if (!e || t.length < 2) {
|
|
5648
|
+
xe();
|
|
5649
|
+
return;
|
|
5650
|
+
}
|
|
5651
|
+
g("planning");
|
|
5652
|
+
try {
|
|
5653
|
+
await e.onSelectFinished(t);
|
|
5654
|
+
} catch (e) {
|
|
5655
|
+
console.error("Route planning onSelectFinished failed:", e);
|
|
5656
|
+
} finally {
|
|
5657
|
+
xe();
|
|
5658
|
+
}
|
|
5659
|
+
}, [xe]), A = useCallback((e) => {
|
|
5660
|
+
if (D.current !== "selecting" || !O.current) return;
|
|
5661
|
+
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
5662
|
+
T.current.push(t);
|
|
5663
|
+
let n = T.current.length;
|
|
5664
|
+
v(n), be(t), n >= O.current.pointCount && Se();
|
|
5665
|
+
}, [be, Se]), j = useCallback((e) => {
|
|
5666
|
+
D.current === "selecting" && (e.preventDefault(), xe());
|
|
5667
|
+
}, [xe]);
|
|
5668
|
+
useEffect(() => {
|
|
5669
|
+
if (e && h === "selecting") return e.on("click", A), e.on("contextmenu", j), () => {
|
|
5670
|
+
e.off("click", A), e.off("contextmenu", j);
|
|
5671
|
+
};
|
|
5672
|
+
}, [
|
|
5673
|
+
e,
|
|
5674
|
+
h,
|
|
5675
|
+
A,
|
|
5676
|
+
j
|
|
5677
|
+
]);
|
|
5678
|
+
let M = useCallback((t) => {
|
|
5679
|
+
if (!e) return;
|
|
5680
|
+
D.current !== "idle" && xe();
|
|
5681
|
+
let n = Math.max(2, t.pointCount ?? i), r = t.visualType ?? l;
|
|
5682
|
+
O.current = {
|
|
5683
|
+
pointCount: n,
|
|
5684
|
+
visualType: r,
|
|
5685
|
+
onSelectFinished: t.onSelectFinished
|
|
5686
|
+
}, T.current = [], v(0), b(n), S(!1), ve.current = e.getCanvas().style.cursor, e.getCanvas().style.cursor = "crosshair", g("selecting");
|
|
5687
|
+
}, [
|
|
5688
|
+
e,
|
|
5689
|
+
i,
|
|
5690
|
+
l,
|
|
5691
|
+
xe
|
|
5692
|
+
]);
|
|
5693
|
+
useImperativeHandle(f, () => ({ startPlanning: M }), [M]);
|
|
5694
|
+
let N = () => {
|
|
5695
|
+
h === "idle" ? S((e) => !e) : h === "selecting" && xe();
|
|
5696
|
+
}, Ce = () => {
|
|
5697
|
+
u && M({
|
|
5698
|
+
pointCount: Math.max(2, y),
|
|
5699
|
+
visualType: l,
|
|
5700
|
+
onSelectFinished: u
|
|
5701
|
+
});
|
|
5702
|
+
}, P = (e) => {
|
|
5703
|
+
let t = parseInt(e.target.value, 10);
|
|
5704
|
+
!isNaN(t) && t >= 2 ? b(t) : e.target.value === "" && b(2);
|
|
5705
|
+
}, we = () => {
|
|
5706
|
+
if (h === "planning") return /* @__PURE__ */ jsx("span", { children: "规划中..." });
|
|
5707
|
+
if (h === "selecting") {
|
|
5708
|
+
let e = O.current?.pointCount ?? y;
|
|
5709
|
+
return /* @__PURE__ */ jsxs("span", { children: [
|
|
5710
|
+
_,
|
|
5711
|
+
"/",
|
|
5712
|
+
e
|
|
5713
|
+
] });
|
|
5714
|
+
}
|
|
5715
|
+
return "路径规划";
|
|
5716
|
+
}, Te = h === "selecting", F = h === "planning";
|
|
5717
|
+
return !d && h === "idle" ? null : /* @__PURE__ */ jsxs("div", {
|
|
5718
|
+
className: `mapbox-route-planning-control${d ? "" : " mapbox-route-planning-control--floating"}`,
|
|
5719
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
5720
|
+
ref: C,
|
|
5721
|
+
className: `mapbox-control-btn mapbox-route-planning-control__btn${Te ? " mapbox-route-planning-control__btn--active" : ""}${F ? " mapbox-route-planning-control__btn--planning" : ""}${x ? " mapbox-route-planning-control__btn--active" : ""}`,
|
|
5722
|
+
onClick: N,
|
|
5723
|
+
disabled: F,
|
|
5724
|
+
title: h === "idle" ? "路径规划" : h === "selecting" ? "取消选点" : "规划中...",
|
|
5725
|
+
children: [/* @__PURE__ */ jsx("img", {
|
|
5726
|
+
src: route_planning_default,
|
|
5727
|
+
alt: "route",
|
|
5728
|
+
className: "mapbox-route-planning-control__btn-icon"
|
|
5729
|
+
}), we()]
|
|
5730
|
+
}), x && h === "idle" && /* @__PURE__ */ jsxs("div", {
|
|
5731
|
+
ref: w,
|
|
5732
|
+
className: "mapbox-route-planning-control__panel",
|
|
5733
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
5734
|
+
className: "mapbox-route-planning-control__panel-header",
|
|
5735
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
5736
|
+
className: "mapbox-route-planning-control__panel-title",
|
|
5737
|
+
children: "路径规划"
|
|
5738
|
+
})
|
|
5739
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
5740
|
+
className: "mapbox-route-planning-control__panel-body",
|
|
5741
|
+
children: [
|
|
5742
|
+
/* @__PURE__ */ jsxs("div", {
|
|
5743
|
+
className: "mapbox-route-planning-control__panel-row",
|
|
5744
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
5745
|
+
className: "mapbox-route-planning-control__panel-label",
|
|
5746
|
+
children: "选点数量"
|
|
5747
|
+
}), c ? /* @__PURE__ */ jsx("input", {
|
|
5748
|
+
type: "number",
|
|
5749
|
+
className: "mapbox-route-planning-control__panel-input",
|
|
5750
|
+
value: y,
|
|
5751
|
+
min: 2,
|
|
5752
|
+
onChange: P
|
|
5753
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
5754
|
+
className: "mapbox-route-planning-control__panel-value",
|
|
5755
|
+
children: y
|
|
5756
|
+
})]
|
|
5757
|
+
}),
|
|
5758
|
+
/* @__PURE__ */ jsx("div", {
|
|
5759
|
+
className: "mapbox-route-planning-control__panel-tip",
|
|
5760
|
+
children: "左键点击地图选点,右键取消"
|
|
5761
|
+
}),
|
|
5762
|
+
/* @__PURE__ */ jsx("button", {
|
|
5763
|
+
className: "mapbox-route-planning-control__panel-start",
|
|
5764
|
+
onClick: Ce,
|
|
5765
|
+
disabled: !u,
|
|
5766
|
+
children: "开始规划"
|
|
5767
|
+
})
|
|
5768
|
+
]
|
|
5769
|
+
})]
|
|
5770
|
+
})]
|
|
5771
|
+
});
|
|
5772
|
+
});
|
|
5773
|
+
RoutePlanningControl.displayName = "RoutePlanningControl";
|
|
4406
5774
|
function mergePopupConfig(e, t, n) {
|
|
4407
5775
|
return {
|
|
4408
5776
|
content: e.content ?? n ?? null,
|
|
@@ -4550,51 +5918,53 @@ function adjustPopupForBounds(e, t) {
|
|
|
4550
5918
|
return r.x + t.width + 10 > n.width && (r.x = n.width - t.width - 10), r.x < 10 && (r.x = 10), r.y + t.height + 10 > n.height && (r.y = n.height - t.height - 10), r.y < 10 && (r.y = 10), r;
|
|
4551
5919
|
}
|
|
4552
5920
|
const Mapbox = forwardRef((e, c) => {
|
|
4553
|
-
let { center: l = [116.4074, 39.9042], zoom: u = 12, pitch: d = 0, bearing: f = 0, style: h = "mapbox://styles/mapbox/dark-v11", maxBounds: g, mode: _ = "display", editConfig: v = {}, pickerConfig: y = {}, onPick: b, interactive: x = {}, layers: S = [], rasterPaint:
|
|
5921
|
+
let { center: l = [116.4074, 39.9042], zoom: u = 12, pitch: d = 0, bearing: f = 0, style: h = "mapbox://styles/mapbox/dark-v11", maxBounds: g, mode: _ = "display", editConfig: v = {}, pickerConfig: y = {}, onPick: b, interactive: x = {}, layers: S = [], rasterPaint: T, entities: E = [], selectedIds: D = [], entityConfig: O, nameConfig: k, selectNameConfig: A, areaConfig: j, circleConfig: M, lengthConfig: N, showCoordinates: Ce = !0, showScale: P = !0, showResetView: we = !0, showRoadHighlight: Te = !1, showMeasure: Ee = !1, showRasterPaint: Ae = !1, showRoutePlanning: je, onRasterPaintChange: Me, popupDefaults: I, renderPopup: Pe, onMapLoad: Fe, onEntityClick: Ie, onPopupOpen: Le, onPopupClose: Re, className: ze = "", containerStyle: Be } = e, Ve = useRef(null), He = useRef(null), L = useRef(null), R = useRef(/* @__PURE__ */ new Map()), z = useRef(/* @__PURE__ */ new Map()), Ue = useRef(/* @__PURE__ */ new Set()), [B, We] = useState(null), Ge = useRef(null), Ke = useRef(null), qe = useRef(null), [Je, Ye] = useState(null), Xe = useRef(null), Ze = useRef(null), [V, Qe] = useState(null), [$e, et] = useState(_), [tt, nt] = useState(null), rt = useRef(null), [it, H] = useState(null), [at, U] = useState(null), [ot, st] = useState(null), W = useRef(!1), G = useRef(null), ct = useRef(null), K = useRef(null), lt = useRef(null), q = useRef(null), ut = useRef([]), J = useRef(null), dt = useRef(null), ft = useRef(null), pt = useRef([]), mt = useRef(null), ht = useRef(!1), [gt, _t] = useState([]), vt = useRef([]);
|
|
5922
|
+
vt.current = gt;
|
|
5923
|
+
let Y = useRef(null);
|
|
4554
5924
|
useEffect(() => {
|
|
4555
|
-
|
|
5925
|
+
et(_);
|
|
4556
5926
|
}, [_]);
|
|
4557
|
-
let
|
|
4558
|
-
let t =
|
|
5927
|
+
let yt = useCallback((e) => {
|
|
5928
|
+
let t = R.current.get(e), n = z.current.get(e);
|
|
4559
5929
|
if (t && n) {
|
|
4560
5930
|
if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
|
|
4561
5931
|
let r = {
|
|
4562
5932
|
...n,
|
|
4563
5933
|
isAnimating: !0
|
|
4564
5934
|
};
|
|
4565
|
-
|
|
5935
|
+
z.current.set(e, r), t.startAnimation();
|
|
4566
5936
|
} else if (n.type === "circle" && t instanceof CanvasCircleRenderer) {
|
|
4567
5937
|
let r = {
|
|
4568
5938
|
...n,
|
|
4569
5939
|
isAnimating: !0
|
|
4570
5940
|
};
|
|
4571
|
-
|
|
5941
|
+
z.current.set(e, r), t.startAnimation();
|
|
4572
5942
|
}
|
|
4573
5943
|
}
|
|
4574
|
-
}, []),
|
|
4575
|
-
let t =
|
|
5944
|
+
}, []), bt = useCallback((e) => {
|
|
5945
|
+
let t = R.current.get(e), n = z.current.get(e);
|
|
4576
5946
|
if (t && n) {
|
|
4577
5947
|
if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
|
|
4578
5948
|
let r = {
|
|
4579
5949
|
...n,
|
|
4580
5950
|
isAnimating: !1
|
|
4581
5951
|
};
|
|
4582
|
-
|
|
5952
|
+
z.current.set(e, r), t.stopAnimation();
|
|
4583
5953
|
} else if (n.type === "circle" && t instanceof CanvasCircleRenderer) {
|
|
4584
5954
|
let r = {
|
|
4585
5955
|
...n,
|
|
4586
5956
|
isAnimating: !1
|
|
4587
5957
|
};
|
|
4588
|
-
|
|
5958
|
+
z.current.set(e, r), t.stopAnimation();
|
|
4589
5959
|
}
|
|
4590
5960
|
}
|
|
4591
|
-
}, []),
|
|
4592
|
-
let t =
|
|
4593
|
-
t && (t.type === "radar" || t.type === "circle") && (t.type, t.isAnimating ?
|
|
4594
|
-
}, [
|
|
5961
|
+
}, []), xt = useCallback((e) => {
|
|
5962
|
+
let t = z.current.get(e);
|
|
5963
|
+
t && (t.type === "radar" || t.type === "circle") && (t.type, t.isAnimating ? bt(e) : yt(e));
|
|
5964
|
+
}, [yt, bt]), St = useCallback((e) => {
|
|
4595
5965
|
if (e === void 0) {
|
|
4596
5966
|
let e = !1;
|
|
4597
|
-
for (let [, t] of
|
|
5967
|
+
for (let [, t] of R.current) if (t instanceof UnitRenderer) {
|
|
4598
5968
|
let n = t.getShowTrajectory();
|
|
4599
5969
|
if (n === "all" || typeof n == "number" && n > 0) {
|
|
4600
5970
|
e = !0;
|
|
@@ -4602,18 +5972,18 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4602
5972
|
}
|
|
4603
5973
|
}
|
|
4604
5974
|
let t = e ? 0 : "all";
|
|
4605
|
-
for (let [, e] of
|
|
5975
|
+
for (let [, e] of R.current) e instanceof UnitRenderer && e.setShowTrajectory(t);
|
|
4606
5976
|
} else {
|
|
4607
5977
|
let t = new Set(e.map(String));
|
|
4608
|
-
for (let [e, n] of
|
|
5978
|
+
for (let [e, n] of R.current) n instanceof UnitRenderer && n.setShowTrajectory(t.has(String(e)) ? "all" : 0);
|
|
4609
5979
|
}
|
|
4610
|
-
}, []),
|
|
4611
|
-
let r =
|
|
4612
|
-
if (!r?.popup || !
|
|
5980
|
+
}, []), Ct = useCallback((e, t, n) => {
|
|
5981
|
+
let r = E.find((t) => String(t.id) === String(e));
|
|
5982
|
+
if (!r?.popup || !L.current) return;
|
|
4613
5983
|
let i = r.popup.content ?? Pe?.(r);
|
|
4614
5984
|
if (!i) return;
|
|
4615
|
-
let a = mergePopupConfig(r.popup,
|
|
4616
|
-
|
|
5985
|
+
let a = mergePopupConfig(r.popup, I, i), { position: o, actualPosition: s } = calculatePopupPosition(r, a, L.current, n);
|
|
5986
|
+
We({
|
|
4617
5987
|
entityId: e,
|
|
4618
5988
|
position: o,
|
|
4619
5989
|
config: a,
|
|
@@ -4621,27 +5991,27 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4621
5991
|
actualPosition: s
|
|
4622
5992
|
}), Le?.(e);
|
|
4623
5993
|
}, [
|
|
4624
|
-
|
|
4625
|
-
|
|
5994
|
+
E,
|
|
5995
|
+
I,
|
|
4626
5996
|
Pe,
|
|
4627
5997
|
Le
|
|
4628
|
-
]),
|
|
4629
|
-
|
|
4630
|
-
}, [
|
|
4631
|
-
|
|
4632
|
-
}, [Re]),
|
|
4633
|
-
let r =
|
|
5998
|
+
]), wt = useCallback((e) => {
|
|
5999
|
+
B?.entityId === e && (We(null), Re?.(e));
|
|
6000
|
+
}, [B, Re]), Tt = useCallback(() => {
|
|
6001
|
+
We((e) => (e && Re?.(e.entityId), null));
|
|
6002
|
+
}, [Re]), Et = useCallback((e) => B?.entityId === e, [B]), Dt = useCallback((e, t, n) => {
|
|
6003
|
+
let r = L.current;
|
|
4634
6004
|
r && r.flyTo({
|
|
4635
6005
|
center: e,
|
|
4636
6006
|
zoom: t ?? r.getZoom(),
|
|
4637
6007
|
...n
|
|
4638
6008
|
});
|
|
4639
|
-
}, []),
|
|
4640
|
-
let r =
|
|
6009
|
+
}, []), Ot = useCallback((e, t, n) => {
|
|
6010
|
+
let r = L.current;
|
|
4641
6011
|
if (!r || e.length === 0) return;
|
|
4642
6012
|
let i = [];
|
|
4643
6013
|
for (let t of e) {
|
|
4644
|
-
let e =
|
|
6014
|
+
let e = R.current.get(t);
|
|
4645
6015
|
e && i.push(e.getBounds());
|
|
4646
6016
|
}
|
|
4647
6017
|
if (i.length === 0) return;
|
|
@@ -4663,51 +6033,65 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4663
6033
|
pitch: n?.pitch ?? r.getPitch()
|
|
4664
6034
|
};
|
|
4665
6035
|
t !== void 0 && (p.maxZoom = t), n?.essential !== void 0 && (p.essential = n.essential), r.fitBounds(f, p);
|
|
4666
|
-
}, []),
|
|
4667
|
-
let t =
|
|
6036
|
+
}, []), kt = useCallback((e) => {
|
|
6037
|
+
let t = L.current;
|
|
4668
6038
|
if (!t || !t.getContainer()) return;
|
|
4669
|
-
let { showMarker: n = !0, markerColor: r = "#3388ff" } = y;
|
|
6039
|
+
let { showMarker: n = !0, markerColor: r = "#3388ff", name: i, nameConfig: a } = y;
|
|
4670
6040
|
if (!n) {
|
|
4671
|
-
|
|
6041
|
+
rt.current &&= (rt.current.remove(), null);
|
|
4672
6042
|
return;
|
|
4673
6043
|
}
|
|
4674
|
-
if (
|
|
4675
|
-
|
|
6044
|
+
if (rt.current) {
|
|
6045
|
+
rt.current.setLngLat(e);
|
|
6046
|
+
let t = rt.current.getElement(), n = t.querySelector(".marker-label");
|
|
6047
|
+
if (i) {
|
|
6048
|
+
let e = resolveNameConfig(a, k);
|
|
6049
|
+
if (n) n.textContent = i, n.style.color = e.fillColor, n.style.opacity = String(e.fillOpacity), n.style.webkitTextStrokeColor = e.strokeColor, n.style.webkitTextStrokeWidth = `${e.strokeWidth}px`;
|
|
6050
|
+
else {
|
|
6051
|
+
let n = document.createElement("div");
|
|
6052
|
+
n.className = "marker-label", n.textContent = i, n.style.color = e.fillColor, n.style.opacity = String(e.fillOpacity), n.style.webkitTextStrokeColor = e.strokeColor, n.style.webkitTextStrokeWidth = `${e.strokeWidth}px`, t.appendChild(n);
|
|
6053
|
+
}
|
|
6054
|
+
} else n && n.remove();
|
|
6055
|
+
} else {
|
|
4676
6056
|
let n = document.createElement("div");
|
|
4677
6057
|
n.className = "mapbox-picker-marker";
|
|
4678
|
-
let
|
|
4679
|
-
|
|
6058
|
+
let o = document.createElement("div");
|
|
6059
|
+
if (o.className = "marker-inner", o.style.background = r, n.appendChild(o), i) {
|
|
6060
|
+
let e = resolveNameConfig(a, k), t = document.createElement("div");
|
|
6061
|
+
t.className = "marker-label", t.textContent = i, t.style.color = e.fillColor, t.style.opacity = String(e.fillOpacity), t.style.webkitTextStrokeColor = e.strokeColor, t.style.webkitTextStrokeWidth = `${e.strokeWidth}px`, n.appendChild(t);
|
|
6062
|
+
}
|
|
6063
|
+
rt.current = new mapboxgl.Marker({
|
|
4680
6064
|
element: n,
|
|
4681
6065
|
anchor: "bottom"
|
|
4682
6066
|
}).setLngLat(e).addTo(t);
|
|
4683
6067
|
}
|
|
4684
|
-
}, [y]),
|
|
4685
|
-
|
|
4686
|
-
}, []),
|
|
4687
|
-
let t =
|
|
4688
|
-
if (Ve.current) if (
|
|
6068
|
+
}, [y, k]), At = useCallback(() => {
|
|
6069
|
+
rt.current &&= (rt.current.remove(), null);
|
|
6070
|
+
}, []), jt = useCallback(() => `marker-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`, []), Mt = useCallback((e) => {
|
|
6071
|
+
let t = L.current;
|
|
6072
|
+
if (Ve.current) if (mt.current &&= (mt.current.remove(), null), e && t) {
|
|
4689
6073
|
t.getCanvas().style.cursor = "none";
|
|
4690
6074
|
let n = document.createElement("div");
|
|
4691
6075
|
n.className = "mapbox-custom-cursor";
|
|
4692
6076
|
let r = e.size || e.width || 32;
|
|
4693
6077
|
n.style.cssText = "\n position: fixed;\n pointer-events: none;\n z-index: 9999;\n transform: translate(-50%, -50%);\n opacity: 0.8;\n ";
|
|
4694
6078
|
let i = document.createElement("img");
|
|
4695
|
-
i.src = e.icon, i.style.width = `${r}px`, i.style.height = `${e.size || e.height || r}px`, i.style.objectFit = "contain", n.appendChild(i), document.body.appendChild(n),
|
|
6079
|
+
i.src = e.icon, i.style.width = `${r}px`, i.style.height = `${e.size || e.height || r}px`, i.style.objectFit = "contain", n.appendChild(i), document.body.appendChild(n), mt.current = n;
|
|
4696
6080
|
let a = (e) => {
|
|
4697
|
-
|
|
6081
|
+
mt.current && (mt.current.style.left = `${e.clientX}px`, mt.current.style.top = `${e.clientY}px`);
|
|
4698
6082
|
};
|
|
4699
6083
|
document.addEventListener("mousemove", a), n.dataset.cleanup = "true", n._cleanup = () => {
|
|
4700
6084
|
document.removeEventListener("mousemove", a);
|
|
4701
6085
|
};
|
|
4702
6086
|
} else t && (t.getCanvas().style.cursor = "");
|
|
4703
|
-
}, []),
|
|
4704
|
-
if (
|
|
4705
|
-
let e =
|
|
4706
|
-
e && e(),
|
|
6087
|
+
}, []), X = useCallback(() => {
|
|
6088
|
+
if (mt.current) {
|
|
6089
|
+
let e = mt.current._cleanup;
|
|
6090
|
+
e && e(), mt.current.remove(), mt.current = null;
|
|
4707
6091
|
}
|
|
4708
|
-
let e =
|
|
6092
|
+
let e = L.current;
|
|
4709
6093
|
e && (e.getCanvas().style.cursor = "");
|
|
4710
|
-
}, []),
|
|
6094
|
+
}, []), Nt = useCallback((e, t, n) => {
|
|
4711
6095
|
if (!e.getSource(t)) {
|
|
4712
6096
|
if (!e.getStyle().glyphs) {
|
|
4713
6097
|
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
@@ -4743,8 +6127,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4743
6127
|
}
|
|
4744
6128
|
});
|
|
4745
6129
|
}
|
|
4746
|
-
}, []),
|
|
4747
|
-
let e =
|
|
6130
|
+
}, []), Pt = useCallback(() => {
|
|
6131
|
+
let e = L.current;
|
|
4748
6132
|
e && (e.getSource("rect-preview-source") || (e.addSource("rect-preview-source", {
|
|
4749
6133
|
type: "geojson",
|
|
4750
6134
|
data: {
|
|
@@ -4768,9 +6152,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4768
6152
|
"line-width": 2,
|
|
4769
6153
|
"line-dasharray": [4, 4]
|
|
4770
6154
|
}
|
|
4771
|
-
}),
|
|
4772
|
-
}, [
|
|
4773
|
-
let n =
|
|
6155
|
+
}), Nt(e, "rect-preview-measure-source", "rect-preview-measure-label")));
|
|
6156
|
+
}, [Nt]), Ft = useCallback((e, t) => {
|
|
6157
|
+
let n = L.current;
|
|
4774
6158
|
if (!n) return;
|
|
4775
6159
|
let r = n.getSource("rect-preview-source");
|
|
4776
6160
|
if (!r) return;
|
|
@@ -4789,11 +6173,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4789
6173
|
},
|
|
4790
6174
|
properties: {}
|
|
4791
6175
|
});
|
|
4792
|
-
let l =
|
|
6176
|
+
let l = G.current, u = l?.strokeColor ?? "#3388ff", d = l?.strokeWidth ?? 2, f = l?.fillColor ?? "#3388ff", p = l?.fillOpacity ?? .1;
|
|
4793
6177
|
n.getLayer("rect-preview-line") && (n.setPaintProperty("rect-preview-line", "line-color", u), n.setPaintProperty("rect-preview-line", "line-width", d)), n.getLayer("rect-preview-fill") && (n.setPaintProperty("rect-preview-fill", "fill-color", f), n.setPaintProperty("rect-preview-fill", "fill-opacity", p));
|
|
4794
6178
|
let m = n.getSource("rect-preview-measure-source");
|
|
4795
6179
|
if (m) {
|
|
4796
|
-
let e =
|
|
6180
|
+
let e = Nn.current, t = [], n = c[0], r = c[1], i = c[2];
|
|
4797
6181
|
if (e?.showArea) {
|
|
4798
6182
|
let e = [(n[0] + i[0]) / 2, (n[1] + i[1]) / 2], a = distance(n, r), o = distance(r, i);
|
|
4799
6183
|
t.push({
|
|
@@ -4830,8 +6214,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4830
6214
|
features: t
|
|
4831
6215
|
});
|
|
4832
6216
|
}
|
|
4833
|
-
}, []),
|
|
4834
|
-
let e =
|
|
6217
|
+
}, []), It = useCallback(() => {
|
|
6218
|
+
let e = L.current;
|
|
4835
6219
|
if (!e) return;
|
|
4836
6220
|
let t = e.getSource("rect-preview-source");
|
|
4837
6221
|
t && t.setData({
|
|
@@ -4844,9 +6228,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4844
6228
|
features: []
|
|
4845
6229
|
});
|
|
4846
6230
|
}, []), Z = useCallback(() => {
|
|
4847
|
-
|
|
4848
|
-
}, [
|
|
4849
|
-
let e =
|
|
6231
|
+
st(null), It();
|
|
6232
|
+
}, [It]), Lt = useCallback(() => {
|
|
6233
|
+
let e = L.current;
|
|
4850
6234
|
e && (e.getSource("circle-preview-source") || (e.addSource("circle-preview-source", {
|
|
4851
6235
|
type: "geojson",
|
|
4852
6236
|
data: {
|
|
@@ -4870,7 +6254,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4870
6254
|
"line-width": 2,
|
|
4871
6255
|
"line-dasharray": [4, 4]
|
|
4872
6256
|
}
|
|
4873
|
-
}),
|
|
6257
|
+
}), Nt(e, "circle-preview-measure-source", "circle-preview-measure-label"), e.getSource("circle-preview-radius-source") || (e.addSource("circle-preview-radius-source", {
|
|
4874
6258
|
type: "geojson",
|
|
4875
6259
|
data: {
|
|
4876
6260
|
type: "FeatureCollection",
|
|
@@ -4887,22 +6271,22 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4887
6271
|
"line-dasharray": [4, 4]
|
|
4888
6272
|
}
|
|
4889
6273
|
}))));
|
|
4890
|
-
}, [
|
|
6274
|
+
}, [Nt]), Rt = useCallback((e, t, n = 64) => {
|
|
4891
6275
|
let [r, i] = e, a = [], o = t / 6371e3, s = i * Math.PI / 180;
|
|
4892
6276
|
for (let e = 0; e <= n; e++) {
|
|
4893
6277
|
let t = e / n * 2 * Math.PI, c = o * Math.cos(t), l = o * Math.sin(t) / Math.cos(s), u = i + c * 180 / Math.PI, d = r + l * 180 / Math.PI;
|
|
4894
6278
|
a.push([d, u]);
|
|
4895
6279
|
}
|
|
4896
6280
|
return a;
|
|
4897
|
-
}, []),
|
|
6281
|
+
}, []), zt = useCallback((e, t) => {
|
|
4898
6282
|
let [n, r] = e, [i, a] = t, o = (a - r) * Math.PI / 180, s = (i - n) * Math.PI / 180, c = Math.sin(o / 2) * Math.sin(o / 2) + Math.cos(r * Math.PI / 180) * Math.cos(a * Math.PI / 180) * Math.sin(s / 2) * Math.sin(s / 2);
|
|
4899
6283
|
return 6371e3 * (2 * Math.atan2(Math.sqrt(c), Math.sqrt(1 - c)));
|
|
4900
|
-
}, []),
|
|
4901
|
-
let n =
|
|
6284
|
+
}, []), Bt = useCallback((e, t) => {
|
|
6285
|
+
let n = L.current;
|
|
4902
6286
|
if (!n) return;
|
|
4903
6287
|
let r = n.getSource("circle-preview-source");
|
|
4904
6288
|
if (!r) return;
|
|
4905
|
-
let i =
|
|
6289
|
+
let i = zt(e, t), a = Rt(e, i);
|
|
4906
6290
|
r.setData({
|
|
4907
6291
|
type: "Feature",
|
|
4908
6292
|
geometry: {
|
|
@@ -4911,9 +6295,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4911
6295
|
},
|
|
4912
6296
|
properties: {}
|
|
4913
6297
|
});
|
|
4914
|
-
let o =
|
|
6298
|
+
let o = K.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
4915
6299
|
n.getLayer("circle-preview-line") && (n.setPaintProperty("circle-preview-line", "line-color", s), n.setPaintProperty("circle-preview-line", "line-width", c)), n.getLayer("circle-preview-fill") && (n.setPaintProperty("circle-preview-fill", "fill-color", l), n.setPaintProperty("circle-preview-fill", "fill-opacity", u));
|
|
4916
|
-
let d =
|
|
6300
|
+
let d = Nn.current, f = [], p = [];
|
|
4917
6301
|
if (d?.showArea) {
|
|
4918
6302
|
let t = Math.PI * i * i;
|
|
4919
6303
|
f.push({
|
|
@@ -4926,7 +6310,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4926
6310
|
});
|
|
4927
6311
|
}
|
|
4928
6312
|
if (d?.showRadius) {
|
|
4929
|
-
let t =
|
|
6313
|
+
let t = K.current?.radiusAngle ?? 90, n = destinationPoint(e, i, t), r = [(e[0] + n[0]) / 2, (e[1] + n[1]) / 2];
|
|
4930
6314
|
p.push({
|
|
4931
6315
|
type: "Feature",
|
|
4932
6316
|
geometry: {
|
|
@@ -4953,8 +6337,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4953
6337
|
type: "FeatureCollection",
|
|
4954
6338
|
features: p
|
|
4955
6339
|
});
|
|
4956
|
-
}, [
|
|
4957
|
-
let e =
|
|
6340
|
+
}, [zt, Rt]), Vt = useCallback(() => {
|
|
6341
|
+
let e = L.current;
|
|
4958
6342
|
if (!e) return;
|
|
4959
6343
|
let t = e.getSource("circle-preview-source");
|
|
4960
6344
|
t && t.setData({
|
|
@@ -4971,10 +6355,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
4971
6355
|
type: "FeatureCollection",
|
|
4972
6356
|
features: []
|
|
4973
6357
|
});
|
|
4974
|
-
}, []),
|
|
4975
|
-
|
|
4976
|
-
}, [
|
|
4977
|
-
let e =
|
|
6358
|
+
}, []), Ht = useCallback(() => {
|
|
6359
|
+
lt.current = null, Vt();
|
|
6360
|
+
}, [Vt]), Ut = useCallback(() => {
|
|
6361
|
+
let e = L.current;
|
|
4978
6362
|
e && (e.getSource("polygon-preview-source") || (e.addSource("polygon-preview-source", {
|
|
4979
6363
|
type: "geojson",
|
|
4980
6364
|
data: {
|
|
@@ -5014,9 +6398,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5014
6398
|
"circle-stroke-color": "#ffffff",
|
|
5015
6399
|
"circle-stroke-width": 2
|
|
5016
6400
|
}
|
|
5017
|
-
}),
|
|
5018
|
-
}, [
|
|
5019
|
-
let n =
|
|
6401
|
+
}), Nt(e, "polygon-preview-measure-source", "polygon-preview-measure-label")));
|
|
6402
|
+
}, [Nt]), Wt = useCallback((e, t) => {
|
|
6403
|
+
let n = L.current;
|
|
5020
6404
|
if (!n) return;
|
|
5021
6405
|
let r = n.getSource("polygon-preview-source"), i = n.getSource("polygon-vertices-source");
|
|
5022
6406
|
if (!r || !i) return;
|
|
@@ -5053,11 +6437,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5053
6437
|
properties: {}
|
|
5054
6438
|
}))
|
|
5055
6439
|
});
|
|
5056
|
-
let o =
|
|
6440
|
+
let o = q.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
5057
6441
|
n.getLayer("polygon-preview-line") && (n.setPaintProperty("polygon-preview-line", "line-color", s), n.setPaintProperty("polygon-preview-line", "line-width", c)), n.getLayer("polygon-preview-fill") && (n.setPaintProperty("polygon-preview-fill", "fill-color", l), n.setPaintProperty("polygon-preview-fill", "fill-opacity", u)), n.getLayer("polygon-vertices") && n.setPaintProperty("polygon-vertices", "circle-color", s);
|
|
5058
6442
|
let d = n.getSource("polygon-preview-measure-source");
|
|
5059
6443
|
if (d) {
|
|
5060
|
-
let e =
|
|
6444
|
+
let e = Nn.current, t = [];
|
|
5061
6445
|
if (e?.showArea && a.length >= 3) {
|
|
5062
6446
|
let e = [...a, a[0]], n = polygonArea(e), r = 0, i = 0;
|
|
5063
6447
|
for (let e of a) r += e[0], i += e[1];
|
|
@@ -5099,8 +6483,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5099
6483
|
features: t
|
|
5100
6484
|
});
|
|
5101
6485
|
}
|
|
5102
|
-
}, []),
|
|
5103
|
-
let e =
|
|
6486
|
+
}, []), Gt = useCallback(() => {
|
|
6487
|
+
let e = L.current;
|
|
5104
6488
|
if (!e) return;
|
|
5105
6489
|
let t = e.getSource("polygon-preview-source");
|
|
5106
6490
|
t && t.setData({
|
|
@@ -5117,10 +6501,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5117
6501
|
type: "FeatureCollection",
|
|
5118
6502
|
features: []
|
|
5119
6503
|
});
|
|
5120
|
-
}, []),
|
|
5121
|
-
|
|
5122
|
-
}, [
|
|
5123
|
-
let e =
|
|
6504
|
+
}, []), Kt = useCallback(() => {
|
|
6505
|
+
ut.current = [], Gt();
|
|
6506
|
+
}, [Gt]), qt = useCallback(() => {
|
|
6507
|
+
let e = L.current;
|
|
5124
6508
|
e && (e.getSource("square-preview-source") || (e.addSource("square-preview-source", {
|
|
5125
6509
|
type: "geojson",
|
|
5126
6510
|
data: {
|
|
@@ -5144,8 +6528,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5144
6528
|
"line-width": 2,
|
|
5145
6529
|
"line-dasharray": [4, 4]
|
|
5146
6530
|
}
|
|
5147
|
-
}),
|
|
5148
|
-
}, [
|
|
6531
|
+
}), Nt(e, "square-preview-measure-source", "square-preview-measure-label")));
|
|
6532
|
+
}, [Nt]), Jt = useCallback((e, t) => {
|
|
5149
6533
|
let [n, r] = e, i = t / 2 / 6371e3, a = r * Math.PI / 180, o = i * 180 / Math.PI, s = i * 180 / Math.PI / Math.cos(a);
|
|
5150
6534
|
return [
|
|
5151
6535
|
[n - s, r + o],
|
|
@@ -5154,12 +6538,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5154
6538
|
[n - s, r - o],
|
|
5155
6539
|
[n - s, r + o]
|
|
5156
6540
|
];
|
|
5157
|
-
}, []),
|
|
5158
|
-
let n =
|
|
6541
|
+
}, []), Yt = useCallback((e, t) => {
|
|
6542
|
+
let n = L.current;
|
|
5159
6543
|
if (!n) return;
|
|
5160
6544
|
let r = n.getSource("square-preview-source");
|
|
5161
6545
|
if (!r) return;
|
|
5162
|
-
let i =
|
|
6546
|
+
let i = zt(e, t) * 2, a = Jt(e, i);
|
|
5163
6547
|
r.setData({
|
|
5164
6548
|
type: "Feature",
|
|
5165
6549
|
geometry: {
|
|
@@ -5168,11 +6552,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5168
6552
|
},
|
|
5169
6553
|
properties: {}
|
|
5170
6554
|
});
|
|
5171
|
-
let o =
|
|
6555
|
+
let o = J.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
|
|
5172
6556
|
n.getLayer("square-preview-line") && (n.setPaintProperty("square-preview-line", "line-color", s), n.setPaintProperty("square-preview-line", "line-width", c)), n.getLayer("square-preview-fill") && (n.setPaintProperty("square-preview-fill", "fill-color", l), n.setPaintProperty("square-preview-fill", "fill-opacity", u));
|
|
5173
6557
|
let d = n.getSource("square-preview-measure-source");
|
|
5174
6558
|
if (d) {
|
|
5175
|
-
let t =
|
|
6559
|
+
let t = Nn.current, n = [];
|
|
5176
6560
|
if (t?.showArea && n.push({
|
|
5177
6561
|
type: "Feature",
|
|
5178
6562
|
geometry: {
|
|
@@ -5196,8 +6580,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5196
6580
|
features: n
|
|
5197
6581
|
});
|
|
5198
6582
|
}
|
|
5199
|
-
}, [
|
|
5200
|
-
let e =
|
|
6583
|
+
}, [zt, Jt]), Xt = useCallback(() => {
|
|
6584
|
+
let e = L.current;
|
|
5201
6585
|
if (!e) return;
|
|
5202
6586
|
let t = e.getSource("square-preview-source");
|
|
5203
6587
|
t && t.setData({
|
|
@@ -5209,10 +6593,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5209
6593
|
type: "FeatureCollection",
|
|
5210
6594
|
features: []
|
|
5211
6595
|
});
|
|
5212
|
-
}, []),
|
|
5213
|
-
|
|
5214
|
-
}, [
|
|
5215
|
-
let e =
|
|
6596
|
+
}, []), Zt = useCallback(() => {
|
|
6597
|
+
dt.current = null, Xt();
|
|
6598
|
+
}, [Xt]), Qt = useCallback(() => {
|
|
6599
|
+
let e = L.current;
|
|
5216
6600
|
e && (e.getSource("polyline-preview-source") || (e.addSource("polyline-preview-source", {
|
|
5217
6601
|
type: "geojson",
|
|
5218
6602
|
data: {
|
|
@@ -5244,9 +6628,9 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5244
6628
|
"circle-stroke-color": "#ffffff",
|
|
5245
6629
|
"circle-stroke-width": 2
|
|
5246
6630
|
}
|
|
5247
|
-
}),
|
|
5248
|
-
}, [
|
|
5249
|
-
let n =
|
|
6631
|
+
}), Nt(e, "polyline-preview-measure-source", "polyline-preview-measure-label")));
|
|
6632
|
+
}, [Nt]), $t = useCallback((e, t) => {
|
|
6633
|
+
let n = L.current;
|
|
5250
6634
|
if (!n) return;
|
|
5251
6635
|
let r = n.getSource("polyline-preview-source"), i = n.getSource("polyline-vertices-source");
|
|
5252
6636
|
if (!r || !i) return;
|
|
@@ -5272,11 +6656,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5272
6656
|
properties: {}
|
|
5273
6657
|
}))
|
|
5274
6658
|
});
|
|
5275
|
-
let o =
|
|
6659
|
+
let o = ft.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2;
|
|
5276
6660
|
n.getLayer("polyline-preview-line") && (n.setPaintProperty("polyline-preview-line", "line-color", s), n.setPaintProperty("polyline-preview-line", "line-width", c)), n.getLayer("polyline-vertices") && n.setPaintProperty("polyline-vertices", "circle-color", s);
|
|
5277
6661
|
let l = n.getSource("polyline-preview-measure-source");
|
|
5278
6662
|
if (l) {
|
|
5279
|
-
let e =
|
|
6663
|
+
let e = Nn.current, t = [];
|
|
5280
6664
|
if (e?.showLength && a.length >= 2) for (let e = 0; e < a.length - 1; e++) {
|
|
5281
6665
|
let n = a[e], r = a[e + 1], i = [(n[0] + r[0]) / 2, (n[1] + r[1]) / 2];
|
|
5282
6666
|
t.push({
|
|
@@ -5293,8 +6677,8 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5293
6677
|
features: t
|
|
5294
6678
|
});
|
|
5295
6679
|
}
|
|
5296
|
-
}, []),
|
|
5297
|
-
let e =
|
|
6680
|
+
}, []), en = useCallback(() => {
|
|
6681
|
+
let e = L.current;
|
|
5298
6682
|
if (!e) return;
|
|
5299
6683
|
let t = e.getSource("polyline-preview-source");
|
|
5300
6684
|
t && t.setData({
|
|
@@ -5312,145 +6696,158 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5312
6696
|
features: []
|
|
5313
6697
|
});
|
|
5314
6698
|
}, []), Q = useCallback(() => {
|
|
5315
|
-
|
|
5316
|
-
}, [
|
|
5317
|
-
|
|
6699
|
+
pt.current = [], en();
|
|
6700
|
+
}, [en]), tn = useCallback((e) => {
|
|
6701
|
+
H(e), Mt(e), e ? (U("marker"), Z(), Ht(), Kt(), Zt(), Q()) : U(null);
|
|
5318
6702
|
}, [
|
|
5319
|
-
|
|
6703
|
+
Mt,
|
|
5320
6704
|
Z,
|
|
5321
|
-
Nt,
|
|
5322
|
-
Lt,
|
|
5323
6705
|
Ht,
|
|
6706
|
+
Kt,
|
|
6707
|
+
Zt,
|
|
5324
6708
|
Q
|
|
5325
|
-
]),
|
|
5326
|
-
if (
|
|
5327
|
-
|
|
5328
|
-
let e =
|
|
6709
|
+
]), nn = useCallback((e) => {
|
|
6710
|
+
if (U(e), e === "rectangle") {
|
|
6711
|
+
H(null), X(), Ht(), Kt(), Zt(), Q();
|
|
6712
|
+
let e = L.current;
|
|
5329
6713
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
5330
6714
|
} else if (e === "circle") {
|
|
5331
|
-
|
|
5332
|
-
let e =
|
|
6715
|
+
H(null), X(), Z(), Kt(), Zt(), Q();
|
|
6716
|
+
let e = L.current;
|
|
5333
6717
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
5334
6718
|
} else if (e === "polygon") {
|
|
5335
|
-
|
|
5336
|
-
let e =
|
|
6719
|
+
H(null), X(), Z(), Ht(), Zt(), Q();
|
|
6720
|
+
let e = L.current;
|
|
5337
6721
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
5338
6722
|
} else if (e === "square") {
|
|
5339
|
-
|
|
5340
|
-
let e =
|
|
6723
|
+
H(null), X(), Z(), Ht(), Kt(), Q();
|
|
6724
|
+
let e = L.current;
|
|
5341
6725
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
5342
6726
|
} else if (e === "polyline") {
|
|
5343
|
-
|
|
5344
|
-
let e =
|
|
6727
|
+
H(null), X(), Z(), Ht(), Kt(), Zt();
|
|
6728
|
+
let e = L.current;
|
|
5345
6729
|
e && (e.getCanvas().style.cursor = "crosshair");
|
|
5346
|
-
} else e === "marker" ? (Z(),
|
|
6730
|
+
} else e === "marker" ? (Z(), Ht(), Kt(), Zt(), Q()) : (H(null), X(), Z(), Ht(), Kt(), Zt(), Q());
|
|
5347
6731
|
}, [
|
|
5348
|
-
|
|
6732
|
+
X,
|
|
5349
6733
|
Z,
|
|
5350
|
-
Nt,
|
|
5351
|
-
Lt,
|
|
5352
6734
|
Ht,
|
|
6735
|
+
Kt,
|
|
6736
|
+
Zt,
|
|
5353
6737
|
Q
|
|
5354
|
-
]),
|
|
5355
|
-
|
|
6738
|
+
]), rn = useCallback((e) => {
|
|
6739
|
+
if (e !== "picker") {
|
|
6740
|
+
let e = y.value && isFinite(y.value.lng) && isFinite(y.value.lat), t = y.showMarker !== !1;
|
|
6741
|
+
(!e || !t) && At(), nt(null);
|
|
6742
|
+
}
|
|
6743
|
+
e !== "edit" && (H(null), U(null), Z(), Q(), X()), et(e);
|
|
5356
6744
|
}, [
|
|
5357
|
-
|
|
5358
|
-
|
|
6745
|
+
At,
|
|
6746
|
+
X,
|
|
5359
6747
|
Z,
|
|
5360
6748
|
Q
|
|
5361
|
-
]),
|
|
5362
|
-
|
|
5363
|
-
}, [
|
|
6749
|
+
]), an = useCallback(() => $e, [$e]), on = useCallback(() => tt, [tt]), sn = useCallback(() => {
|
|
6750
|
+
At(), nt(null);
|
|
6751
|
+
}, [At]);
|
|
5364
6752
|
useEffect(() => {
|
|
5365
|
-
if (!
|
|
6753
|
+
if (!V) return;
|
|
5366
6754
|
let e = y.value;
|
|
5367
6755
|
if (e && isFinite(e.lng) && isFinite(e.lat)) {
|
|
5368
6756
|
let t = [e.lng, e.lat];
|
|
5369
|
-
|
|
6757
|
+
nt(e), kt(t);
|
|
5370
6758
|
}
|
|
5371
6759
|
}, [
|
|
5372
6760
|
y.value,
|
|
5373
|
-
|
|
5374
|
-
|
|
6761
|
+
kt,
|
|
6762
|
+
V
|
|
5375
6763
|
]);
|
|
5376
|
-
let
|
|
5377
|
-
if (
|
|
5378
|
-
if (e.mode === "marker") e.markerStyle ? (
|
|
6764
|
+
let cn = (e) => "mode" in e, ln = useCallback((e) => {
|
|
6765
|
+
if (et("edit"), At(), nt(null), W.current = !0, cn(e)) {
|
|
6766
|
+
if (e.mode === "marker") e.markerStyle ? (ct.current = e.markerStyle, G.current = null, K.current = null, q.current = null, J.current = null, ft.current = null, H(null), U("marker"), e.markerStyle.src && e.markerStyle.width ? Mt({
|
|
5379
6767
|
id: "custom",
|
|
5380
6768
|
name: e.markerStyle.name || "Marker",
|
|
5381
6769
|
icon: e.markerStyle.src,
|
|
5382
6770
|
width: e.markerStyle.width
|
|
5383
|
-
}) :
|
|
6771
|
+
}) : X()) : e.template && (ct.current = null, G.current = null, K.current = null, q.current = null, J.current = null, ft.current = null, H(e.template), U("marker"), Mt(e.template));
|
|
5384
6772
|
else if (e.mode === "rectangle") {
|
|
5385
|
-
|
|
5386
|
-
let t =
|
|
6773
|
+
G.current = e.rectangleStyle || null, ct.current = null, K.current = null, q.current = null, J.current = null, ft.current = null, H(null), U("rectangle"), X();
|
|
6774
|
+
let t = L.current;
|
|
5387
6775
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
5388
6776
|
} else if (e.mode === "circle") {
|
|
5389
|
-
|
|
5390
|
-
let t =
|
|
6777
|
+
K.current = e.circleStyle || null, G.current = null, ct.current = null, q.current = null, J.current = null, ft.current = null, H(null), U("circle"), X();
|
|
6778
|
+
let t = L.current;
|
|
5391
6779
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
5392
6780
|
} else if (e.mode === "polygon") {
|
|
5393
|
-
|
|
5394
|
-
let t =
|
|
6781
|
+
q.current = e.polygonStyle || null, G.current = null, ct.current = null, K.current = null, J.current = null, ft.current = null, H(null), U("polygon"), X();
|
|
6782
|
+
let t = L.current;
|
|
5395
6783
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
5396
6784
|
} else if (e.mode === "square") {
|
|
5397
|
-
|
|
5398
|
-
let t =
|
|
6785
|
+
J.current = e.squareStyle || null, G.current = null, ct.current = null, K.current = null, q.current = null, ft.current = null, H(null), U("square"), X();
|
|
6786
|
+
let t = L.current;
|
|
5399
6787
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
5400
6788
|
} else if (e.mode === "polyline") {
|
|
5401
|
-
|
|
5402
|
-
let t =
|
|
6789
|
+
ft.current = e.polylineStyle || null, G.current = null, ct.current = null, K.current = null, q.current = null, J.current = null, H(null), U("polyline"), X();
|
|
6790
|
+
let t = L.current;
|
|
5403
6791
|
t && (t.getCanvas().style.cursor = "crosshair");
|
|
5404
6792
|
}
|
|
5405
|
-
} else
|
|
6793
|
+
} else H(e), U("marker"), Mt(e), G.current = null, ct.current = null, K.current = null, q.current = null, J.current = null, ft.current = null;
|
|
5406
6794
|
}, [
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
6795
|
+
At,
|
|
6796
|
+
Mt,
|
|
6797
|
+
X
|
|
5410
6798
|
]);
|
|
5411
6799
|
useImperativeHandle(c, () => ({
|
|
5412
|
-
startAnimation:
|
|
5413
|
-
stopAnimation:
|
|
5414
|
-
toggleAnimation:
|
|
5415
|
-
getMap: () =>
|
|
5416
|
-
openPopup: (e) =>
|
|
5417
|
-
closePopup:
|
|
5418
|
-
closeAllPopups:
|
|
5419
|
-
isPopupOpen:
|
|
5420
|
-
toggleUnitTrajectory:
|
|
5421
|
-
flyTo:
|
|
5422
|
-
flyToEntities:
|
|
5423
|
-
getMode:
|
|
5424
|
-
setMode:
|
|
5425
|
-
getPickedLocation:
|
|
5426
|
-
clearPickedLocation:
|
|
5427
|
-
startDrawing:
|
|
5428
|
-
getRenderer: (e) =>
|
|
6800
|
+
startAnimation: yt,
|
|
6801
|
+
stopAnimation: bt,
|
|
6802
|
+
toggleAnimation: xt,
|
|
6803
|
+
getMap: () => L.current,
|
|
6804
|
+
openPopup: (e) => Ct(e, "programmatic"),
|
|
6805
|
+
closePopup: wt,
|
|
6806
|
+
closeAllPopups: Tt,
|
|
6807
|
+
isPopupOpen: Et,
|
|
6808
|
+
toggleUnitTrajectory: St,
|
|
6809
|
+
flyTo: Dt,
|
|
6810
|
+
flyToEntities: Ot,
|
|
6811
|
+
getMode: an,
|
|
6812
|
+
setMode: rn,
|
|
6813
|
+
getPickedLocation: on,
|
|
6814
|
+
clearPickedLocation: sn,
|
|
6815
|
+
startDrawing: ln,
|
|
6816
|
+
getRenderer: (e) => R.current.get(e),
|
|
6817
|
+
setEditingEntities: (e) => {
|
|
6818
|
+
for (let t of vt.current) e.map(String).includes(String(t)) || R.current.get(t)?.setEditing?.(!1);
|
|
6819
|
+
for (let t of e) R.current.get(t)?.setEditing?.(!0);
|
|
6820
|
+
Y.current &&= (R.current.get(Y.current.entityId)?.cancelEditPreview?.(), null), _t(e);
|
|
6821
|
+
},
|
|
6822
|
+
getEditingEntities: () => vt.current,
|
|
6823
|
+
startRoutePlanning: (e) => {
|
|
6824
|
+
He.current?.startPlanning(e);
|
|
6825
|
+
}
|
|
5429
6826
|
}), [
|
|
5430
|
-
dt,
|
|
5431
|
-
ft,
|
|
5432
|
-
pt,
|
|
5433
|
-
ht,
|
|
5434
|
-
gt,
|
|
5435
|
-
_t,
|
|
5436
|
-
vt,
|
|
5437
|
-
mt,
|
|
5438
6827
|
yt,
|
|
5439
6828
|
bt,
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
6829
|
+
xt,
|
|
6830
|
+
Ct,
|
|
6831
|
+
wt,
|
|
6832
|
+
Tt,
|
|
6833
|
+
Et,
|
|
6834
|
+
St,
|
|
6835
|
+
Dt,
|
|
6836
|
+
Ot,
|
|
6837
|
+
an,
|
|
6838
|
+
rn,
|
|
6839
|
+
on,
|
|
6840
|
+
sn,
|
|
6841
|
+
ln
|
|
5445
6842
|
]);
|
|
5446
|
-
let
|
|
5447
|
-
let e =
|
|
6843
|
+
let un = useCallback(() => {
|
|
6844
|
+
let e = L.current;
|
|
5448
6845
|
if (!e) return;
|
|
5449
|
-
let t = new Set(
|
|
5450
|
-
for (let e of n) t.has(e) || (
|
|
5451
|
-
let r = new Set(
|
|
5452
|
-
for (let t of
|
|
5453
|
-
let n = applyEntityConfig(t,
|
|
6846
|
+
let t = new Set(E.map((e) => e.id)), n = new Set(R.current.keys());
|
|
6847
|
+
for (let e of n) t.has(e) || (R.current.get(e)?.destroy(), R.current.delete(e));
|
|
6848
|
+
let r = new Set(D.map(String));
|
|
6849
|
+
for (let t of E) {
|
|
6850
|
+
let n = applyEntityConfig(t, O), i = R.current.get(n.id);
|
|
5454
6851
|
if (i) if (n.type === "radar" && i instanceof CanvasRadarRenderer) i.update(n);
|
|
5455
6852
|
else if (n.type === "image" && i instanceof CanvasImageRenderer) i.update(n);
|
|
5456
6853
|
else if (n.type === "marker" && i instanceof MarkerRenderer) i.update(n);
|
|
@@ -5459,34 +6856,38 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5459
6856
|
else if (n.type === "circle") if (n.fillType === "radial-gradient") if (i instanceof CanvasCircleRenderer) i.update(n);
|
|
5460
6857
|
else {
|
|
5461
6858
|
i.destroy();
|
|
5462
|
-
let t = new CanvasCircleRenderer(e, n,
|
|
5463
|
-
|
|
6859
|
+
let t = new CanvasCircleRenderer(e, n, k, A, j, M);
|
|
6860
|
+
R.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
|
|
5464
6861
|
}
|
|
5465
6862
|
else if (i instanceof CircleRenderer) i.update(n);
|
|
5466
6863
|
else {
|
|
5467
6864
|
i.destroy();
|
|
5468
|
-
let t = new CircleRenderer(e, n,
|
|
5469
|
-
|
|
6865
|
+
let t = new CircleRenderer(e, n, k, A, j, M);
|
|
6866
|
+
R.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
|
|
5470
6867
|
}
|
|
5471
6868
|
else (n.type === "square" && i instanceof SquareRenderer || n.type === "rectangle" && i instanceof RectangleRenderer || n.type === "polyline" && i instanceof PolylineRenderer) && i.update(n);
|
|
5472
6869
|
else {
|
|
5473
6870
|
let t = null;
|
|
5474
|
-
n.type === "radar" ? t = new CanvasRadarRenderer(e, n,
|
|
6871
|
+
n.type === "radar" ? t = new CanvasRadarRenderer(e, n, k, A) : n.type === "image" ? t = new CanvasImageRenderer(e, n, k, A) : n.type === "marker" ? t = new MarkerRenderer(e, n, k, A) : n.type === "unit" ? t = new UnitRenderer(e, n, k, A) : n.type === "polygon" ? t = new PolygonRenderer(e, n, k, A, j, N) : n.type === "circle" ? t = n.fillType === "radial-gradient" ? new CanvasCircleRenderer(e, n, k, A, j, M) : new CircleRenderer(e, n, k, A, j, M) : n.type === "square" ? t = new SquareRenderer(e, n, k, A, j, N) : n.type === "rectangle" ? t = new RectangleRenderer(e, n, k, A, j, N) : n.type === "polyline" && (t = new PolylineRenderer(e, n, k, A, N)), t && (R.current.set(n.id, t), t.setSelected(r.has(String(n.id))), vt.current.map(String).includes(String(n.id)) && t.setEditing?.(!0));
|
|
5475
6872
|
}
|
|
5476
6873
|
}
|
|
6874
|
+
for (let e of vt.current) {
|
|
6875
|
+
let t = R.current.get(e);
|
|
6876
|
+
t && t.setEditing?.(!0);
|
|
6877
|
+
}
|
|
5477
6878
|
}, [
|
|
5478
|
-
T,
|
|
5479
6879
|
E,
|
|
5480
6880
|
D,
|
|
5481
6881
|
O,
|
|
5482
6882
|
k,
|
|
5483
6883
|
A,
|
|
5484
6884
|
j,
|
|
5485
|
-
M
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
6885
|
+
M,
|
|
6886
|
+
N
|
|
6887
|
+
]), dn = useCallback(() => {
|
|
6888
|
+
for (let e of R.current.values()) e.destroy();
|
|
6889
|
+
R.current.clear();
|
|
6890
|
+
}, []), fn = useCallback((e) => {
|
|
5490
6891
|
let t = e.getStyle();
|
|
5491
6892
|
if (!t?.layers) return;
|
|
5492
6893
|
let n = [
|
|
@@ -5501,10 +6902,10 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5501
6902
|
"marker-"
|
|
5502
6903
|
];
|
|
5503
6904
|
for (let e of t.layers) if (n.some((t) => e.id.startsWith(t))) return e.id;
|
|
5504
|
-
}, []),
|
|
5505
|
-
let t =
|
|
6905
|
+
}, []), pn = useCallback((e) => {
|
|
6906
|
+
let t = T, n = { "raster-opacity": e.opacity ?? 1 }, r = e.brightness ?? t?.brightness, i = e.saturation ?? t?.saturation, a = e.contrast ?? t?.contrast, o = e.hueRotate ?? t?.hueRotate;
|
|
5506
6907
|
return r !== void 0 && (n["raster-brightness-min"] = 0, n["raster-brightness-max"] = r), i !== void 0 && (n["raster-saturation"] = i), a !== void 0 && (n["raster-contrast"] = a), o !== void 0 && (n["raster-hue-rotate"] = o), n;
|
|
5507
|
-
}, [
|
|
6908
|
+
}, [T]), mn = useCallback((e, t) => {
|
|
5508
6909
|
let n = `base-layer-source-${t.id}`, r = `base-layer-${t.id}`, i = {
|
|
5509
6910
|
type: "raster",
|
|
5510
6911
|
tiles: [t.url],
|
|
@@ -5514,19 +6915,19 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5514
6915
|
scheme: t.scheme ?? "xyz"
|
|
5515
6916
|
};
|
|
5516
6917
|
t.bounds && (i.bounds = t.bounds), t.attribution && (i.attribution = t.attribution), e.addSource(n, i);
|
|
5517
|
-
let a =
|
|
6918
|
+
let a = fn(e);
|
|
5518
6919
|
e.addLayer({
|
|
5519
6920
|
id: r,
|
|
5520
6921
|
type: "raster",
|
|
5521
6922
|
source: n,
|
|
5522
|
-
paint:
|
|
6923
|
+
paint: pn(t),
|
|
5523
6924
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
5524
6925
|
}, a);
|
|
5525
|
-
}, [
|
|
6926
|
+
}, [fn, pn]), hn = useCallback(async (e, t) => {
|
|
5526
6927
|
try {
|
|
5527
6928
|
let n = await (await fetch(t.url)).json(), r = `base-layer-source-${t.id}`, i = `base-layer-${t.id}`;
|
|
5528
|
-
if (!
|
|
5529
|
-
let a = n.format === "pbf" || n.vector_layers, o =
|
|
6929
|
+
if (!Ue.current.has(t.id)) return;
|
|
6930
|
+
let a = n.format === "pbf" || n.vector_layers, o = fn(e);
|
|
5530
6931
|
a ? (e.addSource(r, {
|
|
5531
6932
|
type: "vector",
|
|
5532
6933
|
tiles: n.tiles,
|
|
@@ -5546,21 +6947,21 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5546
6947
|
id: i,
|
|
5547
6948
|
type: "raster",
|
|
5548
6949
|
source: r,
|
|
5549
|
-
paint:
|
|
6950
|
+
paint: pn(t),
|
|
5550
6951
|
layout: { visibility: t.visible === !1 ? "none" : "visible" }
|
|
5551
6952
|
}, o));
|
|
5552
6953
|
} catch (e) {
|
|
5553
6954
|
console.error(`Failed to load TileJSON from ${t.url}:`, e);
|
|
5554
6955
|
}
|
|
5555
|
-
}, [
|
|
6956
|
+
}, [fn, pn]), gn = useCallback(async (e, t) => {
|
|
5556
6957
|
try {
|
|
5557
6958
|
let n = await (await fetch(t.url)).json();
|
|
5558
|
-
if (!
|
|
6959
|
+
if (!Ue.current.has(t.id)) return;
|
|
5559
6960
|
if (n.sources) for (let [r, i] of Object.entries(n.sources)) {
|
|
5560
6961
|
let n = `base-layer-source-${t.id}-${r}`;
|
|
5561
6962
|
e.getSource(n) || e.addSource(n, i);
|
|
5562
6963
|
}
|
|
5563
|
-
let r =
|
|
6964
|
+
let r = fn(e);
|
|
5564
6965
|
if (n.layers) for (let i of n.layers) {
|
|
5565
6966
|
let n = `base-layer-${t.id}-${i.id}`;
|
|
5566
6967
|
if (e.getLayer(n)) continue;
|
|
@@ -5571,7 +6972,7 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5571
6972
|
};
|
|
5572
6973
|
i.type === "raster" && (a.paint = {
|
|
5573
6974
|
...a.paint,
|
|
5574
|
-
...
|
|
6975
|
+
...pn(t)
|
|
5575
6976
|
}), t.visible === !1 && (a.layout = {
|
|
5576
6977
|
...a.layout,
|
|
5577
6978
|
visibility: "none"
|
|
@@ -5584,50 +6985,50 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5584
6985
|
} catch (e) {
|
|
5585
6986
|
console.error(`Failed to load Style JSON from ${t.url}:`, e);
|
|
5586
6987
|
}
|
|
5587
|
-
}, [
|
|
6988
|
+
}, [fn, pn]), _n = useCallback((e, t) => {
|
|
5588
6989
|
let n = e.getStyle();
|
|
5589
6990
|
if (!n) return;
|
|
5590
6991
|
let r = `base-layer-${t}`, i = n.layers?.filter((e) => e.id.startsWith(r)) ?? [];
|
|
5591
6992
|
for (let t of i) e.getLayer(t.id) && e.removeLayer(t.id);
|
|
5592
6993
|
let a = `base-layer-source-${t}`, o = n.sources ?? {};
|
|
5593
6994
|
for (let t of Object.keys(o)) t.startsWith(a) && e.getSource(t) && e.removeSource(t);
|
|
5594
|
-
}, []),
|
|
5595
|
-
let t =
|
|
6995
|
+
}, []), vn = useCallback((e) => {
|
|
6996
|
+
let t = L.current;
|
|
5596
6997
|
if (!t) return;
|
|
5597
|
-
let n = new Set(e.map((e) => e.id)), r =
|
|
5598
|
-
for (let e of r) n.has(e) || (
|
|
6998
|
+
let n = new Set(e.map((e) => e.id)), r = Ue.current;
|
|
6999
|
+
for (let e of r) n.has(e) || (_n(t, e), r.delete(e));
|
|
5599
7000
|
for (let n of e) if (r.has(n.id)) {
|
|
5600
7001
|
let e = `base-layer-${n.id}`;
|
|
5601
7002
|
if (t.getLayer(e)) {
|
|
5602
|
-
let r =
|
|
7003
|
+
let r = pn(n);
|
|
5603
7004
|
for (let [n, i] of Object.entries(r)) t.setPaintProperty(e, n, i);
|
|
5604
7005
|
t.setLayoutProperty(e, "visibility", n.visible === !1 ? "none" : "visible");
|
|
5605
7006
|
}
|
|
5606
7007
|
} else switch (r.add(n.id), n.type) {
|
|
5607
7008
|
case "raster":
|
|
5608
|
-
|
|
7009
|
+
mn(t, n);
|
|
5609
7010
|
break;
|
|
5610
7011
|
case "tilejson":
|
|
5611
|
-
|
|
7012
|
+
hn(t, n);
|
|
5612
7013
|
break;
|
|
5613
7014
|
case "style":
|
|
5614
|
-
|
|
7015
|
+
gn(t, n);
|
|
5615
7016
|
break;
|
|
5616
7017
|
default: {
|
|
5617
7018
|
let e = n;
|
|
5618
|
-
e.url &&
|
|
7019
|
+
e.url && mn(t, {
|
|
5619
7020
|
...e,
|
|
5620
7021
|
type: "raster"
|
|
5621
7022
|
});
|
|
5622
7023
|
}
|
|
5623
7024
|
}
|
|
5624
7025
|
}, [
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
]),
|
|
7026
|
+
mn,
|
|
7027
|
+
hn,
|
|
7028
|
+
gn,
|
|
7029
|
+
_n,
|
|
7030
|
+
pn
|
|
7031
|
+
]), yn = useCallback((e) => {
|
|
5631
7032
|
let t = e;
|
|
5632
7033
|
for (; t;) {
|
|
5633
7034
|
let e = t.getAttribute?.("data-entity-id");
|
|
@@ -5635,293 +7036,353 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5635
7036
|
t = t.parentElement;
|
|
5636
7037
|
}
|
|
5637
7038
|
return null;
|
|
5638
|
-
}, []),
|
|
7039
|
+
}, []), bn = useCallback((e) => {
|
|
5639
7040
|
let t = [e.lngLat.lng, e.lngLat.lat], n = {
|
|
5640
7041
|
x: e.point.x,
|
|
5641
7042
|
y: e.point.y
|
|
5642
|
-
}, r =
|
|
7043
|
+
}, r = On.current;
|
|
5643
7044
|
if (r === "picker") {
|
|
5644
7045
|
let e = {
|
|
5645
7046
|
lng: t[0],
|
|
5646
7047
|
lat: t[1]
|
|
5647
7048
|
};
|
|
5648
|
-
|
|
7049
|
+
nt(e), kt(t), kn.current?.(e);
|
|
5649
7050
|
return;
|
|
5650
7051
|
}
|
|
7052
|
+
if (ht.current) return;
|
|
5651
7053
|
if (r === "edit") {
|
|
5652
|
-
let e =
|
|
7054
|
+
let e = jn.current;
|
|
5653
7055
|
if (e === "rectangle") {
|
|
5654
|
-
let e =
|
|
5655
|
-
if (!e)
|
|
7056
|
+
let e = Mn.current;
|
|
7057
|
+
if (!e) st(t);
|
|
5656
7058
|
else {
|
|
5657
|
-
let n =
|
|
7059
|
+
let n = G.current, r = applyEntityConfig({
|
|
5658
7060
|
...n,
|
|
5659
|
-
id: n?.id ??
|
|
7061
|
+
id: n?.id ?? jt(),
|
|
5660
7062
|
type: "rectangle",
|
|
5661
7063
|
bounds: [e, t]
|
|
5662
|
-
},
|
|
5663
|
-
|
|
5664
|
-
let i =
|
|
5665
|
-
if (i && !
|
|
5666
|
-
let e = new RectangleRenderer(i, r,
|
|
5667
|
-
|
|
7064
|
+
}, O);
|
|
7065
|
+
It();
|
|
7066
|
+
let i = L.current;
|
|
7067
|
+
if (i && !R.current.has(r.id)) {
|
|
7068
|
+
let e = new RectangleRenderer(i, r, k, A, j, N);
|
|
7069
|
+
R.current.set(r.id, e);
|
|
5668
7070
|
}
|
|
5669
|
-
|
|
7071
|
+
$.current.onRectangleAdd?.(r), st(null), G.current = null, W.current && (W.current = !1, U(null), i && (i.getCanvas().style.cursor = ""));
|
|
5670
7072
|
}
|
|
5671
7073
|
return;
|
|
5672
7074
|
}
|
|
5673
7075
|
if (e === "circle") {
|
|
5674
|
-
let e =
|
|
5675
|
-
if (!e)
|
|
7076
|
+
let e = lt.current;
|
|
7077
|
+
if (!e) lt.current = { center: t };
|
|
5676
7078
|
else {
|
|
5677
|
-
let n =
|
|
7079
|
+
let n = zt(e.center, t), r = K.current, i = applyEntityConfig({
|
|
5678
7080
|
...r,
|
|
5679
|
-
id: r?.id ??
|
|
7081
|
+
id: r?.id ?? jt(),
|
|
5680
7082
|
type: "circle",
|
|
5681
7083
|
center: e.center,
|
|
5682
7084
|
radius: n
|
|
5683
|
-
},
|
|
5684
|
-
|
|
5685
|
-
let a =
|
|
5686
|
-
if (a && !
|
|
5687
|
-
let e = new CircleRenderer(a, i,
|
|
5688
|
-
|
|
7085
|
+
}, O);
|
|
7086
|
+
Vt();
|
|
7087
|
+
let a = L.current;
|
|
7088
|
+
if (a && !R.current.has(i.id)) {
|
|
7089
|
+
let e = new CircleRenderer(a, i, k, A, j, M);
|
|
7090
|
+
R.current.set(i.id, e);
|
|
5689
7091
|
}
|
|
5690
|
-
|
|
7092
|
+
$.current.onCircleAdd?.(i), lt.current = null, K.current = null, W.current && (W.current = !1, U(null), a && (a.getCanvas().style.cursor = ""));
|
|
5691
7093
|
}
|
|
5692
7094
|
return;
|
|
5693
7095
|
}
|
|
5694
7096
|
if (e === "polygon") {
|
|
5695
|
-
let e =
|
|
7097
|
+
let e = ut.current;
|
|
5696
7098
|
if (e.length >= 3) {
|
|
5697
7099
|
let n = e[0];
|
|
5698
|
-
if (
|
|
5699
|
-
let t =
|
|
7100
|
+
if (zt(n, t) < 20) {
|
|
7101
|
+
let t = q.current, n = applyEntityConfig({
|
|
5700
7102
|
...t,
|
|
5701
|
-
id: t?.id ??
|
|
7103
|
+
id: t?.id ?? jt(),
|
|
5702
7104
|
type: "polygon",
|
|
5703
7105
|
coordinates: [...e]
|
|
5704
|
-
},
|
|
5705
|
-
|
|
5706
|
-
let r =
|
|
5707
|
-
if (r && !
|
|
5708
|
-
let e = new PolygonRenderer(r, n,
|
|
5709
|
-
|
|
7106
|
+
}, O);
|
|
7107
|
+
Gt();
|
|
7108
|
+
let r = L.current;
|
|
7109
|
+
if (r && !R.current.has(n.id)) {
|
|
7110
|
+
let e = new PolygonRenderer(r, n, k, A, j, N);
|
|
7111
|
+
R.current.set(n.id, e);
|
|
5710
7112
|
}
|
|
5711
|
-
|
|
7113
|
+
$.current.onPolygonAdd?.(n), ut.current = [], q.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
|
|
5712
7114
|
return;
|
|
5713
7115
|
}
|
|
5714
7116
|
}
|
|
5715
|
-
|
|
7117
|
+
ut.current = [...e, t];
|
|
5716
7118
|
return;
|
|
5717
7119
|
}
|
|
5718
7120
|
if (e === "square") {
|
|
5719
|
-
let e =
|
|
5720
|
-
if (!e)
|
|
7121
|
+
let e = dt.current;
|
|
7122
|
+
if (!e) dt.current = { center: t };
|
|
5721
7123
|
else {
|
|
5722
|
-
let n =
|
|
7124
|
+
let n = zt(e.center, t) * 2, r = J.current, i = applyEntityConfig({
|
|
5723
7125
|
...r,
|
|
5724
|
-
id: r?.id ??
|
|
7126
|
+
id: r?.id ?? jt(),
|
|
5725
7127
|
type: "square",
|
|
5726
7128
|
center: e.center,
|
|
5727
7129
|
length: n
|
|
5728
|
-
},
|
|
5729
|
-
|
|
5730
|
-
let a =
|
|
5731
|
-
if (a && !
|
|
5732
|
-
let e = new SquareRenderer(a, i,
|
|
5733
|
-
|
|
7130
|
+
}, O);
|
|
7131
|
+
Xt();
|
|
7132
|
+
let a = L.current;
|
|
7133
|
+
if (a && !R.current.has(i.id)) {
|
|
7134
|
+
let e = new SquareRenderer(a, i, k, A, j, N);
|
|
7135
|
+
R.current.set(i.id, e);
|
|
5734
7136
|
}
|
|
5735
|
-
|
|
7137
|
+
$.current.onSquareAdd?.(i), dt.current = null, J.current = null, W.current && (W.current = !1, U(null), a && (a.getCanvas().style.cursor = ""));
|
|
5736
7138
|
}
|
|
5737
7139
|
return;
|
|
5738
7140
|
}
|
|
5739
7141
|
if (e === "polyline") {
|
|
5740
|
-
|
|
7142
|
+
pt.current = [...pt.current, t];
|
|
5741
7143
|
return;
|
|
5742
7144
|
}
|
|
5743
|
-
let n =
|
|
7145
|
+
let n = ct.current;
|
|
5744
7146
|
if (n && n.src && n.width) {
|
|
5745
7147
|
let e = {
|
|
5746
7148
|
...n,
|
|
5747
|
-
id: n.id ??
|
|
7149
|
+
id: n.id ?? jt(),
|
|
5748
7150
|
type: "marker",
|
|
5749
7151
|
center: t,
|
|
5750
7152
|
src: n.src,
|
|
5751
7153
|
width: n.width
|
|
5752
7154
|
};
|
|
5753
|
-
|
|
7155
|
+
$.current.onMarkerAdd?.(e), H(null), U(null), X(), ct.current = null, W.current = !1;
|
|
5754
7156
|
return;
|
|
5755
7157
|
}
|
|
5756
|
-
let r =
|
|
7158
|
+
let r = An.current;
|
|
5757
7159
|
if (r) {
|
|
5758
7160
|
let e = {
|
|
5759
|
-
id:
|
|
7161
|
+
id: jt(),
|
|
5760
7162
|
type: "marker",
|
|
5761
7163
|
name: r.name,
|
|
5762
7164
|
center: t,
|
|
5763
7165
|
src: r.icon,
|
|
5764
7166
|
width: r.size || r.width || 32
|
|
5765
7167
|
};
|
|
5766
|
-
r.customData !== void 0 && (e.customData = r.customData),
|
|
7168
|
+
r.customData !== void 0 && (e.customData = r.customData), $.current.onMarkerAdd?.(e), H(null), U(null), X(), W.current = !1;
|
|
7169
|
+
return;
|
|
7170
|
+
}
|
|
7171
|
+
}
|
|
7172
|
+
if (vt.current.length > 0) {
|
|
7173
|
+
let e = L.current?.getZoom() ?? 12;
|
|
7174
|
+
if (Y.current) {
|
|
7175
|
+
let { entityId: e, activeHandle: n } = Y.current, r = R.current.get(e);
|
|
7176
|
+
if (r?.applyHandleMove) {
|
|
7177
|
+
let e = r.applyHandleMove(n, t);
|
|
7178
|
+
$.current.onEntityEdit?.(e);
|
|
7179
|
+
}
|
|
7180
|
+
Y.current = null;
|
|
5767
7181
|
return;
|
|
5768
7182
|
}
|
|
7183
|
+
for (let n of vt.current) {
|
|
7184
|
+
let r = R.current.get(n);
|
|
7185
|
+
if (!r?.getEditHandleAt) continue;
|
|
7186
|
+
let i = r.getEditHandleAt(t, e);
|
|
7187
|
+
if (i) {
|
|
7188
|
+
if (i.type === "midpoint" && r.addVertex) {
|
|
7189
|
+
let e = r.addVertex(i.index, i.position);
|
|
7190
|
+
$.current.onEntityEdit?.(e), Y.current = {
|
|
7191
|
+
entityId: n,
|
|
7192
|
+
activeHandle: {
|
|
7193
|
+
type: "vertex",
|
|
7194
|
+
index: i.index + 1,
|
|
7195
|
+
position: i.position
|
|
7196
|
+
}
|
|
7197
|
+
};
|
|
7198
|
+
} else Y.current = {
|
|
7199
|
+
entityId: n,
|
|
7200
|
+
activeHandle: i
|
|
7201
|
+
};
|
|
7202
|
+
return;
|
|
7203
|
+
}
|
|
7204
|
+
}
|
|
5769
7205
|
}
|
|
5770
|
-
let i =
|
|
7206
|
+
let i = Tn.current, a = En.current, o = Dn.current, s = yn(e.originalEvent.target);
|
|
5771
7207
|
if (s) {
|
|
5772
7208
|
let e = i.find((e) => String(e.id) === s);
|
|
5773
7209
|
if (e) {
|
|
5774
7210
|
if (a?.(e), e.popup) {
|
|
5775
7211
|
let t = e.popup.content ?? Pe?.(e);
|
|
5776
|
-
t && mergePopupConfig(e.popup,
|
|
7212
|
+
t && mergePopupConfig(e.popup, I, t).trigger === "click" && o(s, "click", n);
|
|
5777
7213
|
}
|
|
5778
7214
|
return;
|
|
5779
7215
|
}
|
|
5780
7216
|
}
|
|
5781
|
-
for (let [t, r] of
|
|
7217
|
+
for (let [t, r] of R.current) {
|
|
5782
7218
|
let s = r.getLabelLayerId();
|
|
5783
|
-
if (s &&
|
|
7219
|
+
if (s && L.current?.getLayer(s) && L.current.queryRenderedFeatures(e.point, { layers: [s] }).length > 0) {
|
|
5784
7220
|
let e = i.find((e) => e.id === t);
|
|
5785
7221
|
if (e) {
|
|
5786
7222
|
if (a?.(e), e.popup) {
|
|
5787
7223
|
let r = e.popup.content ?? Pe?.(e);
|
|
5788
|
-
r && mergePopupConfig(e.popup,
|
|
7224
|
+
r && mergePopupConfig(e.popup, I, r).trigger === "click" && o(t, "click", n);
|
|
5789
7225
|
}
|
|
5790
7226
|
return;
|
|
5791
7227
|
}
|
|
5792
7228
|
}
|
|
5793
7229
|
}
|
|
5794
|
-
for (let [e, r] of
|
|
7230
|
+
for (let [e, r] of R.current) if (r.isPointInEntity(t)) {
|
|
5795
7231
|
let t = i.find((t) => t.id === e);
|
|
5796
7232
|
if (t) {
|
|
5797
7233
|
if (a?.(t), t.popup) {
|
|
5798
7234
|
let r = t.popup.content ?? Pe?.(t);
|
|
5799
|
-
r && mergePopupConfig(t.popup,
|
|
7235
|
+
r && mergePopupConfig(t.popup, I, r).trigger === "click" && o(e, "click", n);
|
|
5800
7236
|
}
|
|
5801
7237
|
return;
|
|
5802
7238
|
}
|
|
5803
7239
|
}
|
|
5804
7240
|
}, [
|
|
5805
|
-
|
|
7241
|
+
I,
|
|
5806
7242
|
Pe,
|
|
5807
|
-
|
|
5808
|
-
]),
|
|
5809
|
-
let t = [e.lngLat.lng, e.lngLat.lat]
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
let
|
|
5816
|
-
n === "
|
|
5817
|
-
let
|
|
5818
|
-
n === "
|
|
5819
|
-
let
|
|
5820
|
-
|
|
7243
|
+
yn
|
|
7244
|
+
]), xn = useCallback((e) => {
|
|
7245
|
+
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
7246
|
+
if (Y.current) {
|
|
7247
|
+
let { entityId: e, activeHandle: n } = Y.current;
|
|
7248
|
+
R.current.get(e)?.updateEditPreview?.(n, t);
|
|
7249
|
+
return;
|
|
7250
|
+
}
|
|
7251
|
+
let n = jn.current, r = Mn.current;
|
|
7252
|
+
n === "rectangle" && r && Ft(r, t);
|
|
7253
|
+
let i = lt.current;
|
|
7254
|
+
n === "circle" && i && Bt(i.center, t);
|
|
7255
|
+
let a = ut.current;
|
|
7256
|
+
n === "polygon" && a.length > 0 && Wt(a, t);
|
|
7257
|
+
let o = dt.current;
|
|
7258
|
+
n === "square" && o && Yt(o.center, t);
|
|
7259
|
+
let s = pt.current;
|
|
7260
|
+
n === "polyline" && s.length > 0 && $t(s, t);
|
|
7261
|
+
let c = Tn.current, l = Dn.current;
|
|
7262
|
+
for (let [e, n] of R.current) if (n.isPointInEntity(t)) {
|
|
5821
7263
|
let t = c.find((t) => t.id === e);
|
|
5822
7264
|
if (!t?.popup) continue;
|
|
5823
7265
|
let n = t.popup.content ?? Pe?.(t);
|
|
5824
7266
|
if (!n) continue;
|
|
5825
|
-
let r = mergePopupConfig(t.popup,
|
|
7267
|
+
let r = mergePopupConfig(t.popup, I, n);
|
|
5826
7268
|
if (r.trigger === "hover") {
|
|
5827
|
-
|
|
7269
|
+
qe.current && clearTimeout(qe.current), qe.current = window.setTimeout(() => {
|
|
5828
7270
|
l(e, "hover");
|
|
5829
7271
|
}, r.hoverDelay);
|
|
5830
7272
|
return;
|
|
5831
7273
|
}
|
|
5832
7274
|
}
|
|
5833
|
-
if (
|
|
5834
|
-
let e =
|
|
5835
|
-
e && !e.isPointInEntity(t) &&
|
|
7275
|
+
if (qe.current &&= (clearTimeout(qe.current), null), B?.openedBy === "hover") {
|
|
7276
|
+
let e = R.current.get(B.entityId);
|
|
7277
|
+
e && !e.isPointInEntity(t) && wt(B.entityId);
|
|
5836
7278
|
}
|
|
5837
7279
|
}, [
|
|
5838
|
-
|
|
7280
|
+
I,
|
|
5839
7281
|
Pe,
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
Et,
|
|
5843
|
-
jt,
|
|
7282
|
+
B,
|
|
7283
|
+
wt,
|
|
5844
7284
|
Ft,
|
|
5845
7285
|
Bt,
|
|
5846
|
-
Wt
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
7286
|
+
Wt,
|
|
7287
|
+
Yt,
|
|
7288
|
+
$t
|
|
7289
|
+
]), Sn = useCallback((e) => {
|
|
7290
|
+
if (e.preventDefault(), ht.current) return;
|
|
7291
|
+
if (vt.current.length > 0) {
|
|
7292
|
+
let t = [e.lngLat.lng, e.lngLat.lat];
|
|
7293
|
+
if (Y.current) {
|
|
7294
|
+
R.current.get(Y.current.entityId)?.cancelEditPreview?.(), Y.current = null;
|
|
7295
|
+
return;
|
|
7296
|
+
}
|
|
7297
|
+
let n = L.current?.getZoom() ?? 12;
|
|
7298
|
+
for (let e of vt.current) {
|
|
7299
|
+
let r = R.current.get(e);
|
|
7300
|
+
if (!r?.getEditHandleAt || !r.deleteVertex) continue;
|
|
7301
|
+
let i = r.getEditHandleAt(t, n);
|
|
7302
|
+
if (i && i.type === "vertex") {
|
|
7303
|
+
let e = r.deleteVertex(i.index);
|
|
7304
|
+
e && $.current.onEntityEdit?.(e);
|
|
7305
|
+
return;
|
|
7306
|
+
}
|
|
7307
|
+
}
|
|
7308
|
+
}
|
|
7309
|
+
if (On.current !== "edit") return;
|
|
7310
|
+
if (An.current) {
|
|
7311
|
+
H(null), U(null), X();
|
|
5851
7312
|
return;
|
|
5852
7313
|
}
|
|
5853
|
-
let t =
|
|
7314
|
+
let t = jn.current;
|
|
5854
7315
|
if (t === "rectangle") {
|
|
5855
|
-
if (
|
|
7316
|
+
if (Mn.current) st(null), It();
|
|
5856
7317
|
else {
|
|
5857
|
-
|
|
5858
|
-
let e =
|
|
7318
|
+
U(null);
|
|
7319
|
+
let e = L.current;
|
|
5859
7320
|
e && (e.getCanvas().style.cursor = "");
|
|
5860
7321
|
}
|
|
5861
7322
|
return;
|
|
5862
7323
|
}
|
|
5863
7324
|
if (t === "circle") {
|
|
5864
|
-
if (
|
|
7325
|
+
if (lt.current) lt.current = null, Vt();
|
|
5865
7326
|
else {
|
|
5866
|
-
|
|
5867
|
-
let e =
|
|
7327
|
+
U(null);
|
|
7328
|
+
let e = L.current;
|
|
5868
7329
|
e && (e.getCanvas().style.cursor = "");
|
|
5869
7330
|
}
|
|
5870
7331
|
return;
|
|
5871
7332
|
}
|
|
5872
7333
|
if (t === "polygon") {
|
|
5873
|
-
let e =
|
|
7334
|
+
let e = ut.current;
|
|
5874
7335
|
if (e.length >= 3) {
|
|
5875
|
-
let t =
|
|
7336
|
+
let t = q.current, n = applyEntityConfig({
|
|
5876
7337
|
...t,
|
|
5877
|
-
id: t?.id ??
|
|
7338
|
+
id: t?.id ?? jt(),
|
|
5878
7339
|
type: "polygon",
|
|
5879
7340
|
coordinates: [...e]
|
|
5880
|
-
},
|
|
5881
|
-
|
|
5882
|
-
let r =
|
|
5883
|
-
if (r && !
|
|
5884
|
-
let e = new PolygonRenderer(r, n,
|
|
5885
|
-
|
|
7341
|
+
}, O);
|
|
7342
|
+
Gt();
|
|
7343
|
+
let r = L.current;
|
|
7344
|
+
if (r && !R.current.has(n.id)) {
|
|
7345
|
+
let e = new PolygonRenderer(r, n, k, A, j, N);
|
|
7346
|
+
R.current.set(n.id, e);
|
|
5886
7347
|
}
|
|
5887
|
-
|
|
5888
|
-
} else if (e.length > 0)
|
|
7348
|
+
$.current.onPolygonAdd?.(n), ut.current = [], q.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
|
|
7349
|
+
} else if (e.length > 0) ut.current = [], Gt();
|
|
5889
7350
|
else {
|
|
5890
|
-
|
|
5891
|
-
let e =
|
|
7351
|
+
U(null);
|
|
7352
|
+
let e = L.current;
|
|
5892
7353
|
e && (e.getCanvas().style.cursor = "");
|
|
5893
7354
|
}
|
|
5894
7355
|
return;
|
|
5895
7356
|
}
|
|
5896
7357
|
if (t === "square") {
|
|
5897
|
-
if (
|
|
7358
|
+
if (dt.current) dt.current = null, Xt();
|
|
5898
7359
|
else {
|
|
5899
|
-
|
|
5900
|
-
let e =
|
|
7360
|
+
U(null);
|
|
7361
|
+
let e = L.current;
|
|
5901
7362
|
e && (e.getCanvas().style.cursor = "");
|
|
5902
7363
|
}
|
|
5903
7364
|
return;
|
|
5904
7365
|
}
|
|
5905
7366
|
if (t === "polyline") {
|
|
5906
|
-
let e =
|
|
7367
|
+
let e = pt.current;
|
|
5907
7368
|
if (e.length >= 2) {
|
|
5908
|
-
let t =
|
|
7369
|
+
let t = ft.current, n = applyEntityConfig({
|
|
5909
7370
|
...t,
|
|
5910
|
-
id: t?.id ??
|
|
7371
|
+
id: t?.id ?? jt(),
|
|
5911
7372
|
type: "polyline",
|
|
5912
7373
|
coordinates: [...e]
|
|
5913
|
-
},
|
|
5914
|
-
|
|
5915
|
-
let r =
|
|
5916
|
-
if (r && !
|
|
5917
|
-
let e = new PolylineRenderer(r, n,
|
|
5918
|
-
|
|
7374
|
+
}, O);
|
|
7375
|
+
en();
|
|
7376
|
+
let r = L.current;
|
|
7377
|
+
if (r && !R.current.has(n.id)) {
|
|
7378
|
+
let e = new PolylineRenderer(r, n, k, A, N);
|
|
7379
|
+
R.current.set(n.id, e);
|
|
5919
7380
|
}
|
|
5920
|
-
|
|
5921
|
-
} else if (e.length > 0)
|
|
7381
|
+
$.current.onPolylineAdd?.(n), pt.current = [], ft.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
|
|
7382
|
+
} else if (e.length > 0) pt.current = [], en();
|
|
5922
7383
|
else {
|
|
5923
|
-
|
|
5924
|
-
let e =
|
|
7384
|
+
U(null);
|
|
7385
|
+
let e = L.current;
|
|
5925
7386
|
e && (e.getCanvas().style.cursor = "");
|
|
5926
7387
|
}
|
|
5927
7388
|
return;
|
|
@@ -5929,45 +7390,45 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5929
7390
|
let n = [e.lngLat.lng, e.lngLat.lat], r = {
|
|
5930
7391
|
x: e.point.x,
|
|
5931
7392
|
y: e.point.y
|
|
5932
|
-
}, i =
|
|
7393
|
+
}, i = Tn.current, a = yn(e.originalEvent.target);
|
|
5933
7394
|
if (a) {
|
|
5934
7395
|
let e = i.find((e) => String(e.id) === a);
|
|
5935
7396
|
if (e) {
|
|
5936
|
-
|
|
7397
|
+
Cn(e, r, n);
|
|
5937
7398
|
return;
|
|
5938
7399
|
}
|
|
5939
7400
|
}
|
|
5940
|
-
for (let [t, a] of
|
|
7401
|
+
for (let [t, a] of R.current) {
|
|
5941
7402
|
let o = a.getLabelLayerId();
|
|
5942
|
-
if (o &&
|
|
7403
|
+
if (o && L.current?.getLayer(o) && L.current.queryRenderedFeatures(e.point, { layers: [o] }).length > 0) {
|
|
5943
7404
|
let e = i.find((e) => e.id === t);
|
|
5944
7405
|
if (e) {
|
|
5945
|
-
|
|
7406
|
+
Cn(e, r, n);
|
|
5946
7407
|
return;
|
|
5947
7408
|
}
|
|
5948
7409
|
}
|
|
5949
7410
|
}
|
|
5950
|
-
for (let [e, t] of
|
|
7411
|
+
for (let [e, t] of R.current) if (t.isPointInEntity(n)) {
|
|
5951
7412
|
let t = i.find((t) => t.id === e);
|
|
5952
7413
|
if (t) {
|
|
5953
|
-
|
|
7414
|
+
Cn(t, r, n);
|
|
5954
7415
|
return;
|
|
5955
7416
|
}
|
|
5956
7417
|
}
|
|
5957
7418
|
}, [
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
Dt,
|
|
5961
|
-
Mt,
|
|
7419
|
+
yn,
|
|
7420
|
+
X,
|
|
5962
7421
|
It,
|
|
5963
7422
|
Vt,
|
|
5964
|
-
Gt
|
|
5965
|
-
|
|
7423
|
+
Gt,
|
|
7424
|
+
Xt,
|
|
7425
|
+
en
|
|
7426
|
+
]), Cn = useCallback((e, t, n) => {
|
|
5966
7427
|
let r = Ve.current?.getBoundingClientRect(), i = r ? {
|
|
5967
7428
|
x: t.x + r.left,
|
|
5968
7429
|
y: t.y + r.top
|
|
5969
7430
|
} : t;
|
|
5970
|
-
|
|
7431
|
+
Ye({
|
|
5971
7432
|
position: i,
|
|
5972
7433
|
lngLat: n,
|
|
5973
7434
|
items: [{
|
|
@@ -5983,12 +7444,12 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5983
7444
|
}),
|
|
5984
7445
|
danger: !0,
|
|
5985
7446
|
onClick: () => {
|
|
5986
|
-
|
|
7447
|
+
$.current.onEntityDelete?.(e);
|
|
5987
7448
|
}
|
|
5988
7449
|
}]
|
|
5989
7450
|
});
|
|
5990
|
-
}, []),
|
|
5991
|
-
|
|
7451
|
+
}, []), wn = useCallback(() => {
|
|
7452
|
+
Ye(null);
|
|
5992
7453
|
}, []);
|
|
5993
7454
|
useEffect(() => {
|
|
5994
7455
|
let e = document.createElement("div");
|
|
@@ -5999,11 +7460,11 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
5999
7460
|
width: 100%;
|
|
6000
7461
|
pointer-events: none;
|
|
6001
7462
|
height: 100%;
|
|
6002
|
-
z-index: ${
|
|
6003
|
-
`, document.body.appendChild(e),
|
|
7463
|
+
z-index: ${I?.zIndex ?? 1e3};
|
|
7464
|
+
`, document.body.appendChild(e), Ge.current = e, () => {
|
|
6004
7465
|
document.body.contains(e) && document.body.removeChild(e);
|
|
6005
7466
|
};
|
|
6006
|
-
}, [
|
|
7467
|
+
}, [I?.zIndex]), useEffect(() => {
|
|
6007
7468
|
let e = document.createElement("div");
|
|
6008
7469
|
return e.id = `mapbox-context-menu-container-${Date.now()}`, e.style.cssText = `
|
|
6009
7470
|
position: fixed;
|
|
@@ -6012,61 +7473,65 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6012
7473
|
width: 100%;
|
|
6013
7474
|
pointer-events: none;
|
|
6014
7475
|
height: 100%;
|
|
6015
|
-
z-index: ${(
|
|
6016
|
-
`, document.body.appendChild(e),
|
|
7476
|
+
z-index: ${(I?.zIndex ?? 1e3) + 100};
|
|
7477
|
+
`, document.body.appendChild(e), Xe.current = e, () => {
|
|
6017
7478
|
document.body.contains(e) && document.body.removeChild(e);
|
|
6018
7479
|
};
|
|
6019
|
-
}, [
|
|
6020
|
-
let
|
|
6021
|
-
|
|
6022
|
-
let
|
|
6023
|
-
|
|
6024
|
-
let
|
|
6025
|
-
|
|
6026
|
-
let
|
|
6027
|
-
|
|
6028
|
-
let
|
|
6029
|
-
|
|
6030
|
-
let
|
|
6031
|
-
|
|
6032
|
-
let
|
|
6033
|
-
|
|
6034
|
-
let
|
|
6035
|
-
|
|
6036
|
-
let
|
|
6037
|
-
|
|
6038
|
-
let
|
|
6039
|
-
|
|
7480
|
+
}, [I?.zIndex]);
|
|
7481
|
+
let Tn = useRef(E);
|
|
7482
|
+
Tn.current = E;
|
|
7483
|
+
let En = useRef(Ie);
|
|
7484
|
+
En.current = Ie;
|
|
7485
|
+
let Dn = useRef(Ct);
|
|
7486
|
+
Dn.current = Ct;
|
|
7487
|
+
let On = useRef($e);
|
|
7488
|
+
On.current = $e;
|
|
7489
|
+
let kn = useRef(b);
|
|
7490
|
+
kn.current = b;
|
|
7491
|
+
let An = useRef(it);
|
|
7492
|
+
An.current = it;
|
|
7493
|
+
let jn = useRef(at);
|
|
7494
|
+
jn.current = at;
|
|
7495
|
+
let Mn = useRef(ot);
|
|
7496
|
+
Mn.current = ot;
|
|
7497
|
+
let $ = useRef(v);
|
|
7498
|
+
$.current = v;
|
|
7499
|
+
let Nn = useRef(O);
|
|
7500
|
+
Nn.current = O, useEffect(() => {
|
|
6040
7501
|
let e = (e) => {
|
|
6041
|
-
if (e.key === "Escape" &&
|
|
6042
|
-
|
|
7502
|
+
if (e.key === "Escape" && Y.current) {
|
|
7503
|
+
R.current.get(Y.current.entityId)?.cancelEditPreview?.(), Y.current = null;
|
|
7504
|
+
return;
|
|
7505
|
+
}
|
|
7506
|
+
if (e.key === "Escape" && $e === "edit") {
|
|
7507
|
+
if (it && (H(null), U(null), X()), at === "rectangle") if (ot) st(null), It();
|
|
6043
7508
|
else {
|
|
6044
|
-
|
|
6045
|
-
let e =
|
|
7509
|
+
U(null);
|
|
7510
|
+
let e = L.current;
|
|
6046
7511
|
e && (e.getCanvas().style.cursor = "");
|
|
6047
7512
|
}
|
|
6048
|
-
if (
|
|
7513
|
+
if (at === "circle") if (lt.current) lt.current = null, Vt();
|
|
6049
7514
|
else {
|
|
6050
|
-
|
|
6051
|
-
let e =
|
|
7515
|
+
U(null);
|
|
7516
|
+
let e = L.current;
|
|
6052
7517
|
e && (e.getCanvas().style.cursor = "");
|
|
6053
7518
|
}
|
|
6054
|
-
if (
|
|
7519
|
+
if (at === "polygon") if (ut.current.length > 0) ut.current = [], Gt();
|
|
6055
7520
|
else {
|
|
6056
|
-
|
|
6057
|
-
let e =
|
|
7521
|
+
U(null);
|
|
7522
|
+
let e = L.current;
|
|
6058
7523
|
e && (e.getCanvas().style.cursor = "");
|
|
6059
7524
|
}
|
|
6060
|
-
if (
|
|
7525
|
+
if (at === "square") if (dt.current) dt.current = null, Xt();
|
|
6061
7526
|
else {
|
|
6062
|
-
|
|
6063
|
-
let e =
|
|
7527
|
+
U(null);
|
|
7528
|
+
let e = L.current;
|
|
6064
7529
|
e && (e.getCanvas().style.cursor = "");
|
|
6065
7530
|
}
|
|
6066
|
-
if (
|
|
7531
|
+
if (at === "polyline") if (pt.current.length > 0) pt.current = [], en();
|
|
6067
7532
|
else {
|
|
6068
|
-
|
|
6069
|
-
let e =
|
|
7533
|
+
U(null);
|
|
7534
|
+
let e = L.current;
|
|
6070
7535
|
e && (e.getCanvas().style.cursor = "");
|
|
6071
7536
|
}
|
|
6072
7537
|
}
|
|
@@ -6075,49 +7540,49 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6075
7540
|
document.removeEventListener("keydown", e);
|
|
6076
7541
|
};
|
|
6077
7542
|
}, [
|
|
6078
|
-
|
|
6079
|
-
rt,
|
|
7543
|
+
$e,
|
|
6080
7544
|
it,
|
|
6081
7545
|
at,
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
Mt,
|
|
7546
|
+
ot,
|
|
7547
|
+
X,
|
|
6085
7548
|
It,
|
|
6086
7549
|
Vt,
|
|
6087
|
-
Gt
|
|
7550
|
+
Gt,
|
|
7551
|
+
Xt,
|
|
7552
|
+
en
|
|
6088
7553
|
]), useEffect(() => {
|
|
6089
|
-
let e =
|
|
6090
|
-
if (!e || !
|
|
6091
|
-
let t =
|
|
6092
|
-
let r =
|
|
7554
|
+
let e = L.current;
|
|
7555
|
+
if (!e || !B) return;
|
|
7556
|
+
let t = B.entityId, n = B.config, r = () => {
|
|
7557
|
+
let r = Tn.current.find((e) => e.id === t);
|
|
6093
7558
|
if (!r) {
|
|
6094
|
-
|
|
7559
|
+
Tt();
|
|
6095
7560
|
return;
|
|
6096
7561
|
}
|
|
6097
|
-
let { position: i } = calculatePopupPosition(r, n, e, void 0,
|
|
6098
|
-
|
|
7562
|
+
let { position: i } = calculatePopupPosition(r, n, e, void 0, Ke.current);
|
|
7563
|
+
Ke.current && (Ke.current.style.left = `${i.x}px`, Ke.current.style.top = `${i.y}px`);
|
|
6099
7564
|
}, i = setTimeout(() => {
|
|
6100
7565
|
r();
|
|
6101
7566
|
}, 50);
|
|
6102
7567
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
6103
7568
|
clearTimeout(i), e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
6104
7569
|
};
|
|
6105
|
-
}, [
|
|
6106
|
-
let e =
|
|
6107
|
-
if (!e || !
|
|
6108
|
-
let n =
|
|
7570
|
+
}, [B?.entityId, Tt]), useEffect(() => {
|
|
7571
|
+
let e = L.current, t = Ve.current;
|
|
7572
|
+
if (!e || !Je || !t) return;
|
|
7573
|
+
let n = Je.lngLat, r = () => {
|
|
6109
7574
|
let r = e.project(n), i = t.clientWidth, a = t.clientHeight;
|
|
6110
7575
|
if (r.x < 0 || r.x > i || r.y < 0 || r.y > a) {
|
|
6111
|
-
|
|
7576
|
+
wn();
|
|
6112
7577
|
return;
|
|
6113
7578
|
}
|
|
6114
7579
|
let o = t.getBoundingClientRect(), s = r.x + o.left, c = r.y + o.top;
|
|
6115
|
-
|
|
7580
|
+
Ze.current && (Ze.current.style.left = `${s}px`, Ze.current.style.top = `${c}px`);
|
|
6116
7581
|
};
|
|
6117
7582
|
return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
|
|
6118
7583
|
e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
|
|
6119
7584
|
};
|
|
6120
|
-
}, [
|
|
7585
|
+
}, [Je?.lngLat, wn]), useEffect(() => {
|
|
6121
7586
|
if (!Ve.current) return;
|
|
6122
7587
|
let e = {
|
|
6123
7588
|
version: 8,
|
|
@@ -6151,98 +7616,98 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6151
7616
|
return { url: e };
|
|
6152
7617
|
}
|
|
6153
7618
|
});
|
|
6154
|
-
return
|
|
7619
|
+
return L.current = _, _.on("load", () => {
|
|
6155
7620
|
if (!_.getStyle().glyphs) {
|
|
6156
7621
|
let e = _.style, t = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
6157
7622
|
e.glyphs = t, e.stylesheet && (e.stylesheet.glyphs = t);
|
|
6158
7623
|
}
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
}),
|
|
6162
|
-
}), _.on("click",
|
|
6163
|
-
_.off("click",
|
|
7624
|
+
z.current.clear(), E.forEach((e) => {
|
|
7625
|
+
z.current.set(e.id, e);
|
|
7626
|
+
}), vn(S), un(), Pt(), Lt(), Ut(), qt(), Qt(), Qe(_), Fe?.(_);
|
|
7627
|
+
}), _.on("click", bn), _.on("mousemove", xn), _.on("contextmenu", Sn), () => {
|
|
7628
|
+
_.off("click", bn), _.off("mousemove", xn), _.off("contextmenu", Sn), dn(), At(), X(), Z(), Q(), _.remove(), L.current = null;
|
|
6164
7629
|
};
|
|
6165
7630
|
}, []), useEffect(() => {
|
|
6166
|
-
if (
|
|
6167
|
-
if (!
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
}),
|
|
7631
|
+
if (L.current) {
|
|
7632
|
+
if (!L.current.isStyleLoaded()) {
|
|
7633
|
+
L.current.once("load", () => {
|
|
7634
|
+
z.current.clear(), E.forEach((e) => {
|
|
7635
|
+
z.current.set(e.id, e);
|
|
7636
|
+
}), un();
|
|
6172
7637
|
});
|
|
6173
7638
|
return;
|
|
6174
7639
|
}
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
}),
|
|
7640
|
+
z.current.clear(), E.forEach((e) => {
|
|
7641
|
+
z.current.set(e.id, e);
|
|
7642
|
+
}), un();
|
|
6178
7643
|
}
|
|
6179
|
-
}, [
|
|
6180
|
-
!
|
|
7644
|
+
}, [E, un]), useEffect(() => {
|
|
7645
|
+
!L.current || !L.current.isStyleLoaded() || (dn(), un());
|
|
6181
7646
|
}, [
|
|
6182
|
-
O,
|
|
6183
7647
|
k,
|
|
6184
7648
|
A,
|
|
6185
7649
|
j,
|
|
6186
7650
|
M,
|
|
6187
|
-
|
|
6188
|
-
|
|
7651
|
+
N,
|
|
7652
|
+
dn,
|
|
7653
|
+
un
|
|
6189
7654
|
]), useEffect(() => {
|
|
6190
|
-
if (
|
|
6191
|
-
if (!
|
|
6192
|
-
|
|
6193
|
-
|
|
7655
|
+
if (L.current) {
|
|
7656
|
+
if (!L.current.isStyleLoaded()) {
|
|
7657
|
+
L.current.once("load", () => {
|
|
7658
|
+
vn(S);
|
|
6194
7659
|
});
|
|
6195
7660
|
return;
|
|
6196
7661
|
}
|
|
6197
|
-
|
|
6198
|
-
}
|
|
6199
|
-
}, [S,
|
|
6200
|
-
let
|
|
6201
|
-
|
|
6202
|
-
let
|
|
6203
|
-
|
|
6204
|
-
let
|
|
6205
|
-
|
|
6206
|
-
let
|
|
6207
|
-
|
|
6208
|
-
let
|
|
6209
|
-
|
|
6210
|
-
let
|
|
6211
|
-
|
|
6212
|
-
let
|
|
6213
|
-
|
|
6214
|
-
let
|
|
6215
|
-
|
|
6216
|
-
let
|
|
6217
|
-
|
|
6218
|
-
let e =
|
|
7662
|
+
vn(S);
|
|
7663
|
+
}
|
|
7664
|
+
}, [S, vn]);
|
|
7665
|
+
let Pn = useRef(void 0), Fn = useRef(!0), In = useRef(S);
|
|
7666
|
+
In.current = S;
|
|
7667
|
+
let Ln = useRef(vn);
|
|
7668
|
+
Ln.current = vn;
|
|
7669
|
+
let Rn = useRef(dn);
|
|
7670
|
+
Rn.current = dn;
|
|
7671
|
+
let zn = useRef(un);
|
|
7672
|
+
zn.current = un;
|
|
7673
|
+
let Bn = useRef(Pt);
|
|
7674
|
+
Bn.current = Pt;
|
|
7675
|
+
let Vn = useRef(Lt);
|
|
7676
|
+
Vn.current = Lt;
|
|
7677
|
+
let Hn = useRef(Ut);
|
|
7678
|
+
Hn.current = Ut;
|
|
7679
|
+
let Un = useRef(qt);
|
|
7680
|
+
Un.current = qt;
|
|
7681
|
+
let Wn = useRef(Qt);
|
|
7682
|
+
Wn.current = Qt, useEffect(() => {
|
|
7683
|
+
let e = L.current;
|
|
6219
7684
|
if (!e) return;
|
|
6220
7685
|
let t = h || {
|
|
6221
7686
|
version: 8,
|
|
6222
7687
|
sources: {},
|
|
6223
7688
|
layers: []
|
|
6224
7689
|
};
|
|
6225
|
-
if (
|
|
6226
|
-
|
|
7690
|
+
if (Fn.current) {
|
|
7691
|
+
Fn.current = !1, Pn.current = h;
|
|
6227
7692
|
return;
|
|
6228
7693
|
}
|
|
6229
|
-
|
|
7694
|
+
Pn.current !== h && (Pn.current = h, e.setStyle(t), e.once("style.load", () => {
|
|
6230
7695
|
if (!e.getStyle().glyphs) {
|
|
6231
7696
|
let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
|
|
6232
7697
|
t.glyphs = n, t.stylesheet && (t.stylesheet.glyphs = n);
|
|
6233
7698
|
}
|
|
6234
|
-
|
|
7699
|
+
Ue.current.clear(), Ln.current(In.current), Rn.current(), zn.current(), Bn.current(), Vn.current(), Hn.current(), Un.current(), Wn.current();
|
|
6235
7700
|
}));
|
|
6236
7701
|
}, [h]), useEffect(() => {
|
|
6237
|
-
let e = new Set(
|
|
6238
|
-
for (let [t, n] of
|
|
6239
|
-
}, [
|
|
6240
|
-
let
|
|
7702
|
+
let e = new Set(D.map(String));
|
|
7703
|
+
for (let [t, n] of R.current) n.setSelected(e.has(String(t)));
|
|
7704
|
+
}, [D]);
|
|
7705
|
+
let Gn = useRef({});
|
|
6241
7706
|
useEffect(() => {
|
|
6242
|
-
let e =
|
|
7707
|
+
let e = L.current;
|
|
6243
7708
|
if (!e) return;
|
|
6244
|
-
let t =
|
|
6245
|
-
!n && !r && !i && !a || (
|
|
7709
|
+
let t = Gn.current, n = l && (t.center?.[0] !== l[0] || t.center?.[1] !== l[1]), r = t.zoom !== u, i = t.pitch !== d, a = t.bearing !== f;
|
|
7710
|
+
!n && !r && !i && !a || (Gn.current = {
|
|
6246
7711
|
center: l,
|
|
6247
7712
|
zoom: u,
|
|
6248
7713
|
pitch: d,
|
|
@@ -6259,13 +7724,13 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6259
7724
|
d,
|
|
6260
7725
|
f
|
|
6261
7726
|
]);
|
|
6262
|
-
let
|
|
6263
|
-
if (
|
|
7727
|
+
let Kn = (() => Ce === !1 ? null : Ce === !0 ? { enabled: !0 } : Ce)(), qn = (() => P === !1 ? null : P === !0 ? { enabled: !0 } : P)(), Jn = (() => we === !1 ? null : we === !0 ? { enabled: !0 } : we)(), Yn = (() => {
|
|
7728
|
+
if (Te === !1) return null;
|
|
6264
7729
|
let e, t;
|
|
6265
7730
|
if (S && S.length > 0) {
|
|
6266
7731
|
let n = S.find((e) => e.hasRoadNetwork === !0) || S[0];
|
|
6267
7732
|
if (n.type === "style") {
|
|
6268
|
-
let t =
|
|
7733
|
+
let t = L.current?.getStyle();
|
|
6269
7734
|
if (t?.sources) {
|
|
6270
7735
|
let r = `base-layer-source-${n.id}-`, i = Object.keys(t.sources).find((e) => e.startsWith(r));
|
|
6271
7736
|
i && (e = i);
|
|
@@ -6273,35 +7738,35 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6273
7738
|
} else e = `base-layer-source-${n.id}`;
|
|
6274
7739
|
t = n.roadNetworkSourceLayer || "road";
|
|
6275
7740
|
}
|
|
6276
|
-
return
|
|
7741
|
+
return Te === !0 ? {
|
|
6277
7742
|
enabled: !0,
|
|
6278
7743
|
source: e,
|
|
6279
7744
|
sourceLayer: t
|
|
6280
7745
|
} : {
|
|
6281
|
-
...
|
|
6282
|
-
source:
|
|
6283
|
-
sourceLayer:
|
|
7746
|
+
...Te,
|
|
7747
|
+
source: Te.source || e,
|
|
7748
|
+
sourceLayer: Te.sourceLayer || t
|
|
6284
7749
|
};
|
|
6285
|
-
})(),
|
|
7750
|
+
})(), Xn = (() => Ee ? Ee === !0 ? { enabled: !0 } : Ee : null)(), Zn = (() => Ae ? Ae === !0 ? { enabled: !0 } : Ae : null)(), Qn = (() => je || null)(), $n = useMemo(() => {
|
|
6286
7751
|
let e = [];
|
|
6287
7752
|
for (let t of S) if (t.applyRasterPaint) if (t.type === "style") {
|
|
6288
|
-
let n =
|
|
7753
|
+
let n = L.current;
|
|
6289
7754
|
if (n) {
|
|
6290
7755
|
let r = `base-layer-${t.id}-`, i = n.getStyle();
|
|
6291
7756
|
if (i?.layers) for (let t of i.layers) t.id.startsWith(r) && t.type === "raster" && e.push(t.id);
|
|
6292
7757
|
}
|
|
6293
7758
|
} else e.push(`base-layer-${t.id}`);
|
|
6294
7759
|
return e;
|
|
6295
|
-
}, [S,
|
|
7760
|
+
}, [S, V]);
|
|
6296
7761
|
return /* @__PURE__ */ jsxs("div", {
|
|
6297
|
-
className: `comp-mapbox ${
|
|
7762
|
+
className: `comp-mapbox ${$e === "picker" ? "comp-mapbox--picker-mode" : ""} ${ze}`,
|
|
6298
7763
|
style: Be,
|
|
6299
7764
|
children: [
|
|
6300
7765
|
/* @__PURE__ */ jsx("div", {
|
|
6301
7766
|
ref: Ve,
|
|
6302
7767
|
className: "comp-mapbox__map"
|
|
6303
7768
|
}),
|
|
6304
|
-
|
|
7769
|
+
$e === "picker" && y.showCrosshair === !0 && /* @__PURE__ */ jsxs("div", {
|
|
6305
7770
|
className: "comp-mapbox__crosshair",
|
|
6306
7771
|
children: [/* @__PURE__ */ jsx("div", {
|
|
6307
7772
|
className: "comp-mapbox__crosshair-h",
|
|
@@ -6311,83 +7776,102 @@ const Mapbox = forwardRef((e, c) => {
|
|
|
6311
7776
|
style: y.crosshairColor ? { backgroundColor: y.crosshairColor } : void 0
|
|
6312
7777
|
})]
|
|
6313
7778
|
}),
|
|
6314
|
-
|
|
7779
|
+
$e === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) || Yn && Yn.enabled !== !1 || Qn && Qn.enabled !== !1 ? /* @__PURE__ */ jsxs("div", {
|
|
6315
7780
|
className: "comp-mapbox__edit-controls",
|
|
6316
|
-
children: [
|
|
6317
|
-
markerTemplates
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
7781
|
+
children: [
|
|
7782
|
+
$e === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) && /* @__PURE__ */ jsx(EditControl, {
|
|
7783
|
+
markerTemplates: v.markerTemplates || [],
|
|
7784
|
+
selectedTemplate: it,
|
|
7785
|
+
onTemplateSelect: tn,
|
|
7786
|
+
drawMode: at,
|
|
7787
|
+
onDrawModeChange: nn,
|
|
7788
|
+
showRectangleTool: v.showRectangleTool,
|
|
7789
|
+
showCircleTool: v.showCircleTool,
|
|
7790
|
+
showPolygonTool: v.showPolygonTool,
|
|
7791
|
+
showSquareTool: v.showSquareTool,
|
|
7792
|
+
showPolylineTool: v.showPolylineTool
|
|
7793
|
+
}),
|
|
7794
|
+
Yn && Yn.enabled !== !1 && /* @__PURE__ */ jsx(RoadHighlightControl, {
|
|
7795
|
+
map: V,
|
|
7796
|
+
highlightWidth: Yn.highlightWidth,
|
|
7797
|
+
defaultRoadTypes: Yn.defaultRoadTypes,
|
|
7798
|
+
defaultMinWidth: Yn.defaultMinWidth,
|
|
7799
|
+
source: Yn.source,
|
|
7800
|
+
sourceLayer: Yn.sourceLayer,
|
|
7801
|
+
className: Yn.className,
|
|
7802
|
+
style: Yn.style
|
|
7803
|
+
}),
|
|
7804
|
+
Qn && Qn.enabled !== !1 && /* @__PURE__ */ jsx(RoutePlanningControl, {
|
|
7805
|
+
ref: He,
|
|
7806
|
+
map: V,
|
|
7807
|
+
pointCount: Qn.pointCount,
|
|
7808
|
+
showPointCountInput: Qn.showPointCountInput,
|
|
7809
|
+
visualType: Qn.visualType,
|
|
7810
|
+
onSelectFinished: Qn.onSelectFinished
|
|
7811
|
+
})
|
|
7812
|
+
]
|
|
6337
7813
|
}) : null,
|
|
6338
|
-
(
|
|
7814
|
+
(Kn?.enabled !== !1 || qn?.enabled !== !1 || Jn?.enabled !== !1 || Xn && Xn.enabled !== !1 || Zn && Zn.enabled !== !1) && /* @__PURE__ */ jsxs("div", {
|
|
6339
7815
|
className: "comp-mapbox__controls",
|
|
6340
7816
|
children: [
|
|
6341
|
-
|
|
6342
|
-
map:
|
|
6343
|
-
precision:
|
|
6344
|
-
className:
|
|
6345
|
-
style:
|
|
7817
|
+
Kn && Kn.enabled !== !1 && /* @__PURE__ */ jsx(CoordinateDisplay, {
|
|
7818
|
+
map: V,
|
|
7819
|
+
precision: Kn.precision,
|
|
7820
|
+
className: Kn.className,
|
|
7821
|
+
style: Kn.style
|
|
6346
7822
|
}),
|
|
6347
|
-
|
|
6348
|
-
map:
|
|
6349
|
-
maxWidth:
|
|
6350
|
-
unit:
|
|
6351
|
-
className:
|
|
6352
|
-
style:
|
|
7823
|
+
qn && qn.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
|
|
7824
|
+
map: V,
|
|
7825
|
+
maxWidth: qn.maxWidth,
|
|
7826
|
+
unit: qn.unit,
|
|
7827
|
+
className: qn.className,
|
|
7828
|
+
style: qn.style
|
|
6353
7829
|
}),
|
|
6354
|
-
|
|
6355
|
-
map:
|
|
6356
|
-
entityConfig:
|
|
6357
|
-
|
|
6358
|
-
|
|
7830
|
+
Xn && Xn.enabled !== !1 && /* @__PURE__ */ jsx(MeasureControl, {
|
|
7831
|
+
map: V,
|
|
7832
|
+
entityConfig: O,
|
|
7833
|
+
onDrawModeChange: (e) => {
|
|
7834
|
+
ht.current = e;
|
|
7835
|
+
},
|
|
7836
|
+
className: Xn.className,
|
|
7837
|
+
style: Xn.style
|
|
6359
7838
|
}),
|
|
6360
|
-
|
|
6361
|
-
map:
|
|
6362
|
-
value:
|
|
6363
|
-
onChange:
|
|
6364
|
-
rasterPaintLayerIds:
|
|
6365
|
-
className:
|
|
6366
|
-
style:
|
|
7839
|
+
Zn && Zn.enabled !== !1 && /* @__PURE__ */ jsx(RasterPaintControl, {
|
|
7840
|
+
map: V,
|
|
7841
|
+
value: T,
|
|
7842
|
+
onChange: Me,
|
|
7843
|
+
rasterPaintLayerIds: $n,
|
|
7844
|
+
className: Zn.className,
|
|
7845
|
+
style: Zn.style
|
|
6367
7846
|
}),
|
|
6368
|
-
|
|
6369
|
-
map:
|
|
7847
|
+
Jn && Jn.enabled !== !1 && /* @__PURE__ */ jsx(ResetViewControl, {
|
|
7848
|
+
map: V,
|
|
6370
7849
|
initialCenter: l,
|
|
6371
7850
|
initialZoom: u,
|
|
6372
7851
|
initialPitch: d,
|
|
6373
7852
|
initialBearing: f,
|
|
6374
|
-
duration:
|
|
6375
|
-
className:
|
|
6376
|
-
style:
|
|
7853
|
+
duration: Jn.duration,
|
|
7854
|
+
className: Jn.className,
|
|
7855
|
+
style: Jn.style
|
|
6377
7856
|
})
|
|
6378
7857
|
]
|
|
6379
7858
|
}),
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
7859
|
+
!(Qn && Qn.enabled !== !1) && /* @__PURE__ */ jsx(RoutePlanningControl, {
|
|
7860
|
+
ref: He,
|
|
7861
|
+
map: V,
|
|
7862
|
+
showButton: !1
|
|
7863
|
+
}),
|
|
7864
|
+
B && Ge.current && /* @__PURE__ */ jsx(EntityPopup, {
|
|
7865
|
+
popupState: B,
|
|
7866
|
+
onClose: () => wt(B.entityId),
|
|
7867
|
+
portalContainer: Ge.current,
|
|
7868
|
+
popupRef: Ke
|
|
6385
7869
|
}),
|
|
6386
|
-
|
|
6387
|
-
menuState:
|
|
6388
|
-
onClose:
|
|
6389
|
-
portalContainer:
|
|
6390
|
-
menuRef:
|
|
7870
|
+
Je && Xe.current && /* @__PURE__ */ jsx(ContextMenu, {
|
|
7871
|
+
menuState: Je,
|
|
7872
|
+
onClose: wn,
|
|
7873
|
+
portalContainer: Xe.current,
|
|
7874
|
+
menuRef: Ze
|
|
6391
7875
|
})
|
|
6392
7876
|
]
|
|
6393
7877
|
});
|