|
|
@@ -17,7 +17,8 @@
|
|
|
<div class="btn-common smart-farm-btn yes-events" @click="handleSmartFarmClick">智慧农场</div>
|
|
|
<!-- 地图图例 -->
|
|
|
<!-- <map-legend></map-legend> -->
|
|
|
- <land-use-legend @change="handleLegendChange"></land-use-legend>
|
|
|
+ <!-- <land-use-legend @change="handleLegendChange"></land-use-legend> -->
|
|
|
+ <landUseLegend ref="legendRef"></landUseLegend>
|
|
|
<div class="show-point yes-events" v-show="showPoint" @click="handleShowPointClick"></div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -31,7 +32,8 @@ import StaticMapLayers from "@/components/static_map_change/Layers.js";
|
|
|
import StaticMapPointLayers from "@/components/static_map_change/pointLayer.js"
|
|
|
import { onMounted, onUnmounted, ref, nextTick } from "vue";
|
|
|
import fnHeader from "@/components/fnHeader.vue";
|
|
|
-import landUseLegend from "./components/landUseLegend.vue";
|
|
|
+// import landUseLegend from "./components/landUseLegend.vue";
|
|
|
+import landUseLegend from "./components/legend.vue";
|
|
|
import WarningMap from "./warningMap";
|
|
|
import trackDialog from "./components/trackDialog.vue";
|
|
|
import AlarmLayer from "./map/alarmLayer";
|
|
|
@@ -72,9 +74,22 @@ const isLandRecognition = ref(false);
|
|
|
const baseTabs = ["物候期分布", "长势等级", "水利", "灌渠与泵站", "资源", "导出报告"];
|
|
|
const activeBaseTab = ref("物候期分布");
|
|
|
|
|
|
+const legendKeys = {
|
|
|
+ "物候期分布": "phenology",
|
|
|
+ "长势等级": "growth_status",
|
|
|
+ "水利": "water_conservancy",
|
|
|
+ "资源": "facility",
|
|
|
+}
|
|
|
+
|
|
|
const warningLayers = ref({});
|
|
|
const showPoint = ref(false)
|
|
|
const handleBaseTabClick = (tab) => {
|
|
|
+ const legendKey = legendKeys[tab];
|
|
|
+ if (legendKey) {
|
|
|
+ nextTick(() => {
|
|
|
+ getLegendData(legendKey);
|
|
|
+ });
|
|
|
+ }
|
|
|
activeBaseTab.value = tab;
|
|
|
showPoint.value = false
|
|
|
staticMapPointLayers.hidePoint()
|
|
|
@@ -104,6 +119,20 @@ const handleShowPointClick = () => {
|
|
|
eventBus.emit("chat:showTrackDialog")
|
|
|
}
|
|
|
|
|
|
+const legendRef = ref(null);
|
|
|
+const getLegendData = async (code) => {
|
|
|
+ const { data } = await VE_API.layer.legendList({ code });
|
|
|
+ // 接口返回的是带有 content 字段的对象,content 为 JSON 字符串,这里需要先解析
|
|
|
+ try {
|
|
|
+ const list = data && data.content ? JSON.parse(data.content) : [];
|
|
|
+ console.log('list', list);
|
|
|
+ legendRef.value && legendRef.value.updateData(Array.isArray(list) ? list : []);
|
|
|
+ } catch (e) {
|
|
|
+ console.error("解析图例 content 失败:", e, data);
|
|
|
+ legendRef.value && legendRef.value.updateData([]);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
onMounted(async () => {
|
|
|
// 使用 nextTick 确保 DOM 已经渲染完成,地图容器有正确的尺寸
|
|
|
await nextTick();
|
|
|
@@ -234,7 +263,7 @@ const getWaterData = async () => {
|
|
|
const { data } = await VE_API.layer.waterList();
|
|
|
waterLayer.initData(data);
|
|
|
|
|
|
- const { data: riverData } = await VE_API.layer.riverList();
|
|
|
+ const { data: riverData } = await VE_API.layer.riverList({}, {global: false});
|
|
|
waterLayer.initRiver(riverData);
|
|
|
};
|
|
|
|