huweili-cesium 1.2.38 → 1.2.41
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/js/captureFenceScreenshot.js +1 -1
- package/js/customToolbarButtons.js +13 -0
- package/js/drawFenceNew.js +65 -37
- package/package.json +1 -1
|
@@ -79,6 +79,19 @@ export function createCustomToolbarButtons() {
|
|
|
79
79
|
* @returns {HTMLButtonElement[]} 创建的按钮元素数组
|
|
80
80
|
*/
|
|
81
81
|
const addToolbarButtons = (viewer, buttons) => {
|
|
82
|
+
const toolbar = viewer.container.querySelector('.cesium-viewer-toolbar')
|
|
83
|
+
if (!toolbar) return []
|
|
84
|
+
|
|
85
|
+
const direction = buttons?.direction || buttons?.[0]?.direction || 'row'
|
|
86
|
+
const isRow = direction !== 'column'
|
|
87
|
+
toolbar.style.display = 'flex'
|
|
88
|
+
toolbar.style.flexDirection = isRow ? 'row' : 'column'
|
|
89
|
+
toolbar.style.alignItems = 'center'
|
|
90
|
+
toolbar.style.gap = '4px'
|
|
91
|
+
toolbar.style.width = isRow ? 'fit-content' : 'auto'
|
|
92
|
+
toolbar.style.minWidth = 'unset'
|
|
93
|
+
toolbar.style.flexWrap = 'nowrap'
|
|
94
|
+
|
|
82
95
|
return buttons.map(opt => addToolbarButton(viewer, opt)).filter(Boolean)
|
|
83
96
|
}
|
|
84
97
|
|
package/js/drawFenceNew.js
CHANGED
|
@@ -618,24 +618,28 @@ export function drawFenceNew() {
|
|
|
618
618
|
}
|
|
619
619
|
})
|
|
620
620
|
|
|
621
|
-
const
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
621
|
+
const withLabel = options.withLabel !== false
|
|
622
|
+
let labelEntity = null
|
|
623
|
+
if (withLabel) {
|
|
624
|
+
labelEntity = map.entities.add({
|
|
625
|
+
id: `${options.id}_fence_name_label`,
|
|
626
|
+
position: centerCartesian,
|
|
627
|
+
label: {
|
|
628
|
+
text: fenceName,
|
|
629
|
+
font: BaseConfig.fenceLabelFont,
|
|
630
|
+
fillColor: Cesium.Color.WHITE,
|
|
631
|
+
style: Cesium.LabelStyle.FILL,
|
|
632
|
+
showBackground: true,
|
|
633
|
+
backgroundColor: Cesium.Color.fromCssColorString(BaseConfig.fenceLabelBgColor),
|
|
634
|
+
backgroundPadding: new Cesium.Cartesian2(5, 3),
|
|
635
|
+
verticalOrigin: Cesium.VerticalOrigin.CENTER,
|
|
636
|
+
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
|
|
637
|
+
pixelOffset: new Cesium.Cartesian2(0, 0),
|
|
638
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
639
|
+
distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, Number.POSITIVE_INFINITY)
|
|
640
|
+
}
|
|
641
|
+
})
|
|
642
|
+
}
|
|
639
643
|
|
|
640
644
|
fenceEntity._labelEntity = labelEntity
|
|
641
645
|
fenceEntity._originalOptions = {
|
|
@@ -651,7 +655,9 @@ export function drawFenceNew() {
|
|
|
651
655
|
|
|
652
656
|
if (options.show === false) {
|
|
653
657
|
fenceEntity.show = false
|
|
654
|
-
labelEntity
|
|
658
|
+
if (labelEntity) {
|
|
659
|
+
labelEntity.show = false
|
|
660
|
+
}
|
|
655
661
|
}
|
|
656
662
|
|
|
657
663
|
if (options.zoomTo) {
|
|
@@ -671,6 +677,15 @@ export function drawFenceNew() {
|
|
|
671
677
|
}
|
|
672
678
|
}
|
|
673
679
|
|
|
680
|
+
/**
|
|
681
|
+
* 显示多边形电子围栏(无名称标签版本)
|
|
682
|
+
* @param {Object} options 围栏选项
|
|
683
|
+
* @returns {Object}
|
|
684
|
+
*/
|
|
685
|
+
const showPolygonFenceNoLabel = (options = {}) => {
|
|
686
|
+
return showPolygonFence({ ...options, withLabel: false })
|
|
687
|
+
}
|
|
688
|
+
|
|
674
689
|
/**
|
|
675
690
|
* 删除多边形电子围栏
|
|
676
691
|
* @param {string} id 围栏ID
|
|
@@ -824,24 +839,28 @@ export function drawFenceNew() {
|
|
|
824
839
|
}
|
|
825
840
|
})
|
|
826
841
|
|
|
827
|
-
const
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
842
|
+
const withLabel = options.withLabel !== false
|
|
843
|
+
let labelEntity = null
|
|
844
|
+
if (withLabel) {
|
|
845
|
+
labelEntity = map.entities.add({
|
|
846
|
+
id: `${options.id}_fence_name_label`,
|
|
847
|
+
position: centerCartesian,
|
|
848
|
+
label: {
|
|
849
|
+
text: fenceName,
|
|
850
|
+
font: BaseConfig.fenceLabelFont,
|
|
851
|
+
fillColor: Cesium.Color.WHITE,
|
|
852
|
+
style: Cesium.LabelStyle.FILL,
|
|
853
|
+
showBackground: true,
|
|
854
|
+
backgroundColor: Cesium.Color.fromCssColorString(BaseConfig.fenceLabelBgColor),
|
|
855
|
+
backgroundPadding: new Cesium.Cartesian2(5, 3),
|
|
856
|
+
verticalOrigin: Cesium.VerticalOrigin.CENTER,
|
|
857
|
+
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
|
|
858
|
+
pixelOffset: new Cesium.Cartesian2(0, 0),
|
|
859
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
860
|
+
distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, Number.POSITIVE_INFINITY)
|
|
861
|
+
}
|
|
862
|
+
})
|
|
863
|
+
}
|
|
845
864
|
|
|
846
865
|
fenceEntity._labelEntity = labelEntity
|
|
847
866
|
fenceEntity._originalOptions = {
|
|
@@ -858,6 +877,9 @@ export function drawFenceNew() {
|
|
|
858
877
|
|
|
859
878
|
if (options.show === false) {
|
|
860
879
|
fenceEntity.show = false
|
|
880
|
+
if (labelEntity) {
|
|
881
|
+
labelEntity.show = false
|
|
882
|
+
}
|
|
861
883
|
}
|
|
862
884
|
|
|
863
885
|
if (options.zoomTo) {
|
|
@@ -876,6 +898,10 @@ export function drawFenceNew() {
|
|
|
876
898
|
}
|
|
877
899
|
}
|
|
878
900
|
|
|
901
|
+
const showCircleFenceNoLabel = (options = {}) => {
|
|
902
|
+
return showCircleFence({ ...options, withLabel: false })
|
|
903
|
+
}
|
|
904
|
+
|
|
879
905
|
/**
|
|
880
906
|
* 交互式创建圆形电子围栏(带高度)
|
|
881
907
|
*
|
|
@@ -1508,10 +1534,12 @@ export function drawFenceNew() {
|
|
|
1508
1534
|
drawPolygonFence,
|
|
1509
1535
|
drawPolygonFenceNoLabel,
|
|
1510
1536
|
showPolygonFence,
|
|
1537
|
+
showPolygonFenceNoLabel,
|
|
1511
1538
|
updatePolygonFenceName,
|
|
1512
1539
|
destroyPolygonFence,
|
|
1513
1540
|
destroyPolygonFenceNoLabel,
|
|
1514
1541
|
showCircleFence,
|
|
1542
|
+
showCircleFenceNoLabel,
|
|
1515
1543
|
drawCircleFence,
|
|
1516
1544
|
updateCircleFenceName,
|
|
1517
1545
|
destroyCircleFence,
|