人口网格

This commit is contained in:
wzy-warehouse
2026-04-21 15:49:56 +08:00
parent 8863fafc69
commit d71112e1d3
12 changed files with 149 additions and 43 deletions
@@ -38,6 +38,14 @@
useStatusStore().poiLayers.showReservePoint.loading
"
/>
<!-- 人口网格 -->
<PopulationGridComponent
v-if="
useStatusStore().appLoadingCompleted &&
useStatusStore().poiLayers.showPopulationGrid.loading
"
/>
</template>
<script lang="ts" setup>
@@ -47,6 +55,7 @@
import EmergencyShelterComponent from './EmergencyShelterComponent.vue';
import FireStationComponent from './FireStationComponent.vue';
import StorePointsComponent from './StorePointsComponent.vue';
import PopulationGridComponent from './PopulationGridComponent.vue';
</script>
<style scoped lang="less"></style>
@@ -0,0 +1,48 @@
<!-- 加载geoserver图层 -->
<template>
<div></div>
</template>
<script lang="ts" setup>
import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils';
import type { ImageryLayer } from 'cesium';
import { onMounted } from 'vue';
const props = defineProps<{
id: string;
layers: string;
}>();
const emits = defineEmits<{
(e: 'provideLayers', layer: ImageryLayer): void;
}>();
onMounted(() => {
// 从环境变量获取 GeoServer 地址
const geoserverBaseUrl = import.meta.env.VITE_GEOSERVER_BASE_URL;
const wmsUrl = `${geoserverBaseUrl}/wms`;
// 创建 WMS 图层并保存引用
const layers = CesiumUtilsSingleton.createLayersBatch([
{
id: props.id,
type: 'wms',
provider: 'xian',
url: wmsUrl,
layers: props.layers,
parameters: {
service: 'WMS',
version: '1.1.0',
request: 'GetMap',
transparent: true,
format: 'image/png',
srs: 'EPSG:4326',
},
},
]);
emits('provideLayers', layers[0]!);
});
</script>
<style scoped></style>
@@ -0,0 +1,38 @@
<template>
<!-- 加载人口网格 -->
<LoadingGeoserverLayer
:id="`people`"
:layers="`xian:xian_people`"
@provide-layers="provideLayers"
/>
</template>
<script lang="ts" setup>
import { useStatusStore } from '@/stores/useStatusStore';
import type { ImageryLayer } from 'cesium';
import { onMounted, watch } from 'vue';
import LoadingGeoserverLayer from './LoadingGeoserverLayer.vue';
// 保存图层引用
let populationLayer: ImageryLayer | null = null;
onMounted(() => {
// 监听显示隐藏风险点
watch(
() => useStatusStore().poiLayers.showPopulationGrid.show,
(newValue: boolean) => {
populationLayer!.show = newValue;
}
);
});
/**
* 提供图层
* @param layer 图层
*/
function provideLayers(layer: ImageryLayer) {
populationLayer = layer;
}
</script>
<style scoped></style>