1.气象效果按钮改为切换状态,点击一次显示对应天气,再点击一次取消;

This commit is contained in:
zhangquan 2025-07-22 15:34:54 +08:00
parent ed8b76fe5f
commit 2817417d19
3 changed files with 34 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -26,6 +26,7 @@
v-for="subtool in tool.subtools"
:key="subtool.id"
class="tool-wrapper"
:class="{'active': subtool.active}"
>
<!-- 二级工具按钮 -->
<div class="tool-button" @click="subtool.name && bus.emit(`toolbar_${subtool.name}`, params)">
@ -310,6 +311,7 @@ const toolbarClear = () => {
}
};
//
const mainToolClick = (tool) => {
//
tool.name && bus.emit(`toolbar_${tool.name}`, params)
@ -327,7 +329,36 @@ const mainToolClick = (tool) => {
}
}
//
const weatherSwitchClick = (name) => {
const list = options.value[2].subtools
const option = list.find(item => item.name === name)
if(option.active) {
option.active = false;
weatherParticle.destroy();
} else {
//
list.forEach(item => {
if(item.name !== name) {
item.active = false;
}
});
option.active = true;
switch(name) {
case 'rain':
weatherParticle && weatherParticle.rain()
break
case 'snow':
weatherParticle && weatherParticle.snow()
break
case 'fog':
weatherParticle && weatherParticle.fog()
break
}
}
}
watch(() => props.viewer, (v) => {
if (v) {
@ -377,10 +408,9 @@ watch(() => props.viewer, (v) => {
bus.on('toolbar_road', drawRoad);
bus.on('toolbar_keyarea', drawKeyarea);
//
bus.on('toolbar_sunny', () => weatherParticle && weatherParticle.destroy())
bus.on('toolbar_rain', () => weatherParticle && weatherParticle.rain())
bus.on('toolbar_snow', () => weatherParticle && weatherParticle.snow())
bus.on('toolbar_fog', () => weatherParticle && weatherParticle.fog())
bus.on('toolbar_rain', () => weatherSwitchClick('rain'))
bus.on('toolbar_snow', () => weatherSwitchClick('snow'))
bus.on('toolbar_fog', () => weatherSwitchClick('fog'))
//
bus.on('toolbar_clear', toolbarClear);
}

View File

@ -40,7 +40,6 @@ const initMap = (v) => {
const bus = useEventBus(viewerRef.value)
// view
bus.onScreen(Cesium.ScreenSpaceEventType.LEFT_CLICK, ({ position }) => {
console.log('左键点击屏幕位置:', position);
//
const pickedObjectList = viewerRef.value.scene.drillPick(position);
if (pickedObjectList.length > 0) {