huweili-cesium 1.2.48 → 1.2.50
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/basis.js +63 -4
- package/package.json +1 -1
package/js/basis.js
CHANGED
|
@@ -760,12 +760,60 @@ export function basicConfig() {
|
|
|
760
760
|
zoomOutDefault(mapId, factor)
|
|
761
761
|
}
|
|
762
762
|
|
|
763
|
+
const defaultVisibleTitles = ['指北针', '2D/3D视角切换', '降低视角', '抬升视角', '更多']
|
|
764
|
+
let isMoreExpanded = false
|
|
765
|
+
|
|
766
|
+
const isDefaultVisibleToolbarItem = (item) => {
|
|
767
|
+
const title = item?.getAttribute?.('title') || item?.title || item?.textContent?.trim()
|
|
768
|
+
return defaultVisibleTitles.includes(title)
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
const applyMoreVisible = (toolbar, expanded) => {
|
|
772
|
+
if (!toolbar) return
|
|
773
|
+
|
|
774
|
+
Array.from(toolbar.children).forEach((item) => {
|
|
775
|
+
const isDefaultVisible = isDefaultVisibleToolbarItem(item)
|
|
776
|
+
item.style.display = expanded || isDefaultVisible ? '' : 'none'
|
|
777
|
+
})
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
const setupDefaultMoreVisible = (retryCount = 0) => {
|
|
781
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') return
|
|
782
|
+
|
|
783
|
+
const moreBtn = document.querySelector('[title="更多"]')
|
|
784
|
+
const toolbar = moreBtn?.parentElement
|
|
785
|
+
|
|
786
|
+
if (toolbar) {
|
|
787
|
+
applyMoreVisible(toolbar, isMoreExpanded)
|
|
788
|
+
return
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
if (retryCount < 20) {
|
|
792
|
+
window.setTimeout(() => setupDefaultMoreVisible(retryCount + 1), 100)
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
if (typeof window !== 'undefined') {
|
|
797
|
+
window.requestAnimationFrame(() => setupDefaultMoreVisible())
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
const toggleMoreButtons = (_viewer, btn) => {
|
|
801
|
+
const toolbar = btn?.parentElement
|
|
802
|
+
if (!toolbar) return
|
|
803
|
+
|
|
804
|
+
isMoreExpanded = !isMoreExpanded
|
|
805
|
+
applyMoreVisible(toolbar, isMoreExpanded)
|
|
806
|
+
btn.title = isMoreExpanded ? '收起更多' : '更多'
|
|
807
|
+
btn.setAttribute('aria-expanded', String(isMoreExpanded))
|
|
808
|
+
}
|
|
809
|
+
|
|
763
810
|
return [
|
|
764
811
|
{
|
|
765
812
|
index: 0,
|
|
766
813
|
title: '指北针',
|
|
767
814
|
text: 'N',
|
|
768
815
|
isCompass: true,
|
|
816
|
+
isDefaultVisible: true,
|
|
769
817
|
onClick: () => resetCompassDirection(),
|
|
770
818
|
},
|
|
771
819
|
{
|
|
@@ -792,9 +840,10 @@ export function basicConfig() {
|
|
|
792
840
|
},
|
|
793
841
|
},
|
|
794
842
|
{
|
|
795
|
-
index:
|
|
843
|
+
index: 4,
|
|
796
844
|
title: '2D/3D视角切换',
|
|
797
845
|
text: '2D',
|
|
846
|
+
isDefaultVisible: true,
|
|
798
847
|
onClick: (_v, btn) => {
|
|
799
848
|
const result = toggleViewAtViewportCenter(mapId, {
|
|
800
849
|
distance2D,
|
|
@@ -806,23 +855,33 @@ export function basicConfig() {
|
|
|
806
855
|
},
|
|
807
856
|
},
|
|
808
857
|
{
|
|
809
|
-
index:
|
|
858
|
+
index: 5,
|
|
810
859
|
title: '降低视角',
|
|
811
860
|
iconSrc: `${baseUrl}/images/new/jia.svg`,
|
|
861
|
+
isDefaultVisible: true,
|
|
812
862
|
onClick: () => zoomIn(),
|
|
813
863
|
},
|
|
814
864
|
{
|
|
815
|
-
index:
|
|
865
|
+
index: 6,
|
|
816
866
|
title: '抬升视角',
|
|
817
867
|
iconSrc: `${baseUrl}/images/new/jian.svg`,
|
|
868
|
+
isDefaultVisible: true,
|
|
818
869
|
onClick: () => zoomOut(),
|
|
819
870
|
},
|
|
820
871
|
{
|
|
821
|
-
index:
|
|
872
|
+
index: 7,
|
|
822
873
|
title: '切换底图',
|
|
823
874
|
iconSrc: `${baseUrl}/images/new/map.svg`,
|
|
824
875
|
onClick: (v, btn) => toggleBasemapPickerPanel(v, btn || null),
|
|
825
876
|
},
|
|
877
|
+
{
|
|
878
|
+
index: 1000,
|
|
879
|
+
title: '更多',
|
|
880
|
+
text: '更多',
|
|
881
|
+
isDefaultVisible: true,
|
|
882
|
+
isMoreToggle: true,
|
|
883
|
+
onClick: (v, btn) => toggleMoreButtons(v, btn),
|
|
884
|
+
},
|
|
826
885
|
]
|
|
827
886
|
}
|
|
828
887
|
|