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.
@@ -188,4 +188,4 @@ export async function captureFenceScreenshotByMapId(mapId, positions, options =
188
188
  return null
189
189
  }
190
190
  return captureFenceScreenshot(map, positions, options)
191
- }
191
+ }
@@ -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
 
@@ -618,24 +618,28 @@ export function drawFenceNew() {
618
618
  }
619
619
  })
620
620
 
621
- const labelEntity = map.entities.add({
622
- id: `${options.id}_fence_name_label`,
623
- position: centerCartesian,
624
- label: {
625
- text: fenceName,
626
- font: BaseConfig.fenceLabelFont,
627
- fillColor: Cesium.Color.WHITE,
628
- style: Cesium.LabelStyle.FILL,
629
- showBackground: true,
630
- backgroundColor: Cesium.Color.fromCssColorString(BaseConfig.fenceLabelBgColor),
631
- backgroundPadding: new Cesium.Cartesian2(5, 3),
632
- verticalOrigin: Cesium.VerticalOrigin.CENTER,
633
- horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
634
- pixelOffset: new Cesium.Cartesian2(0, 0),
635
- disableDepthTestDistance: Number.POSITIVE_INFINITY,
636
- distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, Number.POSITIVE_INFINITY)
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.show = false
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 labelEntity = map.entities.add({
828
- id: `${options.id}_fence_name_label`,
829
- position: centerCartesian,
830
- label: {
831
- text: fenceName,
832
- font: BaseConfig.fenceLabelFont,
833
- fillColor: Cesium.Color.WHITE,
834
- style: Cesium.LabelStyle.FILL,
835
- showBackground: true,
836
- backgroundColor: Cesium.Color.fromCssColorString(BaseConfig.fenceLabelBgColor),
837
- backgroundPadding: new Cesium.Cartesian2(5, 3),
838
- verticalOrigin: Cesium.VerticalOrigin.CENTER,
839
- horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
840
- pixelOffset: new Cesium.Cartesian2(0, 0),
841
- disableDepthTestDistance: Number.POSITIVE_INFINITY,
842
- distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, Number.POSITIVE_INFINITY)
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huweili-cesium",
3
- "version": "1.2.38",
3
+ "version": "1.2.41",
4
4
  "description": "基于 Cesium 的地图工具库(无人机态势、轨迹、围栏、工具栏等)",
5
5
  "type": "module",
6
6
  "main": "./index.js",