|
|
|
@ -4,13 +4,11 @@ |
|
|
|
<div id="mapContainer" class="map" style="height: calc(100vh - 50px);"> |
|
|
|
<div id="mapContainer" class="map" style="height: calc(100vh - 50px);"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script setup name="Index"> |
|
|
|
<script setup name="Index"> |
|
|
|
import { onMounted, ref, reactive, nextTick } from "vue"; |
|
|
|
import { onMounted, ref, reactive, nextTick, onUnmounted } from "vue"; |
|
|
|
import _ from "lodash"; |
|
|
|
import _ from "lodash"; |
|
|
|
import L from 'leaflet' |
|
|
|
import L from 'leaflet' |
|
|
|
import dayjs from 'dayjs' |
|
|
|
import dayjs from 'dayjs' |
|
|
|
@ -19,7 +17,6 @@ |
|
|
|
|
|
|
|
|
|
|
|
const { proxy } = getCurrentInstance() |
|
|
|
const { proxy } = getCurrentInstance() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import qtGeojsonData from '@/assets/data/qingtian.json' |
|
|
|
import qtGeojsonData from '@/assets/data/qingtian.json' |
|
|
|
const tdtKey = 'e0d855b509f09b891605c4dc5f29868b' |
|
|
|
const tdtKey = 'e0d855b509f09b891605c4dc5f29868b' |
|
|
|
|
|
|
|
|
|
|
|
@ -84,7 +81,6 @@ |
|
|
|
const TownGov = [28.205423, 120.165288] // 青田县 |
|
|
|
const TownGov = [28.205423, 120.165288] // 青田县 |
|
|
|
|
|
|
|
|
|
|
|
const initMap = () => { |
|
|
|
const initMap = () => { |
|
|
|
|
|
|
|
|
|
|
|
// 初始底图和注记 |
|
|
|
// 初始底图和注记 |
|
|
|
const defaultBase = '影像' |
|
|
|
const defaultBase = '影像' |
|
|
|
tiandituMap = L.map('mapContainer', { |
|
|
|
tiandituMap = L.map('mapContainer', { |
|
|
|
@ -153,6 +149,7 @@ |
|
|
|
// 确保遮罩层在最上层 |
|
|
|
// 确保遮罩层在最上层 |
|
|
|
maskLayer.bringToFront(); |
|
|
|
maskLayer.bringToFront(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
let MapData = [] |
|
|
|
let MapData = [] |
|
|
|
// 获取地图初始化数据 |
|
|
|
// 获取地图初始化数据 |
|
|
|
const getIndexData = async () => { |
|
|
|
const getIndexData = async () => { |
|
|
|
@ -162,7 +159,7 @@ |
|
|
|
if (res.code == 0) { |
|
|
|
if (res.code == 0) { |
|
|
|
let rawData = res.data |
|
|
|
let rawData = res.data |
|
|
|
rawData = _.filter(rawData, function (o) { |
|
|
|
rawData = _.filter(rawData, function (o) { |
|
|
|
return !o.longitude == "" || !o.latitude == ''; |
|
|
|
return o.longitude !== "" && o.latitude !== ""; |
|
|
|
}); |
|
|
|
}); |
|
|
|
MapData = _.map(rawData, item => { |
|
|
|
MapData = _.map(rawData, item => { |
|
|
|
item.position_xy = [item.latitude, item.longitude] |
|
|
|
item.position_xy = [item.latitude, item.longitude] |
|
|
|
@ -178,12 +175,12 @@ |
|
|
|
addMarkers() |
|
|
|
addMarkers() |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
console.error(error) |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
mapLoading.value = false |
|
|
|
mapLoading.value = false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
let dialogVisible = ref(false) // 弹窗 |
|
|
|
let dialogVisible = ref(false) // 弹窗 |
|
|
|
let popupData = ref([]) |
|
|
|
let popupData = ref([]) |
|
|
|
let pinMarkers = []; // 所有单个marker |
|
|
|
let pinMarkers = []; // 所有单个marker |
|
|
|
@ -191,6 +188,35 @@ |
|
|
|
let autoPlayInterval = null; // 自动播放定时器 |
|
|
|
let autoPlayInterval = null; // 自动播放定时器 |
|
|
|
let isPaused = false; // 是否暂停状态 |
|
|
|
let isPaused = false; // 是否暂停状态 |
|
|
|
let currentPopup = null; // 当前打开的弹窗 |
|
|
|
let currentPopup = null; // 当前打开的弹窗 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 显示标记点弹窗的通用方法 |
|
|
|
|
|
|
|
const showMarkerPopup = (e) => { |
|
|
|
|
|
|
|
popupData.value = e.target.options; |
|
|
|
|
|
|
|
const popupContent = ` |
|
|
|
|
|
|
|
<div style="color: white; padding: 10px; font-size: 14px;"> |
|
|
|
|
|
|
|
<h3 style="margin-top: 0;">${popupData.value.stnm}</h3> |
|
|
|
|
|
|
|
<table class='dialog-table' style="width: 100%; border-collapse: collapse;"> |
|
|
|
|
|
|
|
${popupData.value.data ? popupData.value.data.map(row => ` |
|
|
|
|
|
|
|
<tr> |
|
|
|
|
|
|
|
<td style="padding: 5px; width: 50%;">${row.name}${row.unit ? `(${row.unit})` : ''}</td> |
|
|
|
|
|
|
|
<td style="padding: 5px; width: 50%;">${row.value || row.latestValue || ''}</td> |
|
|
|
|
|
|
|
</tr> |
|
|
|
|
|
|
|
`).join('') : ''} |
|
|
|
|
|
|
|
</table> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
`; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建 popup 并设置位置 |
|
|
|
|
|
|
|
if (currentPopup) { |
|
|
|
|
|
|
|
tiandituMap.closePopup(currentPopup); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
currentPopup = L.popup() |
|
|
|
|
|
|
|
.setLatLng(e.target._latlng) |
|
|
|
|
|
|
|
.setContent(popupContent) |
|
|
|
|
|
|
|
.openOn(tiandituMap); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 开始自动播放 |
|
|
|
// 开始自动播放 |
|
|
|
const startAutoPlay = () => { |
|
|
|
const startAutoPlay = () => { |
|
|
|
if (autoPlayInterval) { |
|
|
|
if (autoPlayInterval) { |
|
|
|
@ -234,7 +260,7 @@ |
|
|
|
// 清除旧的 |
|
|
|
// 清除旧的 |
|
|
|
pinMarkers.forEach(m => tiandituMap.removeLayer(m)); |
|
|
|
pinMarkers.forEach(m => tiandituMap.removeLayer(m)); |
|
|
|
pinMarkers = []; |
|
|
|
pinMarkers = []; |
|
|
|
MapData.forEach(item => { |
|
|
|
MapData.forEach((item, index) => { |
|
|
|
let marker; |
|
|
|
let marker; |
|
|
|
const markerIcon = L.icon({ |
|
|
|
const markerIcon = L.icon({ |
|
|
|
iconUrl: item.icon || rain0, |
|
|
|
iconUrl: item.icon || rain0, |
|
|
|
@ -245,7 +271,7 @@ |
|
|
|
icon: markerIcon, |
|
|
|
icon: markerIcon, |
|
|
|
data: item.data, |
|
|
|
data: item.data, |
|
|
|
stnm: item.stnm, |
|
|
|
stnm: item.stnm, |
|
|
|
stnmId:item.stnmId |
|
|
|
stnmId: item.stnmId |
|
|
|
}); |
|
|
|
}); |
|
|
|
// 添加鼠标事件监听 |
|
|
|
// 添加鼠标事件监听 |
|
|
|
marker.on('mouseover', (e) => { |
|
|
|
marker.on('mouseover', (e) => { |
|
|
|
@ -265,6 +291,7 @@ |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
marker.on('click', (e) => { |
|
|
|
marker.on('click', (e) => { |
|
|
|
|
|
|
|
currentIndex = index; // 更新当前索引 |
|
|
|
showMarkerPopup(e); |
|
|
|
showMarkerPopup(e); |
|
|
|
}); |
|
|
|
}); |
|
|
|
pinMarkers.push(marker); |
|
|
|
pinMarkers.push(marker); |
|
|
|
@ -280,7 +307,6 @@ |
|
|
|
firstMarker.fire('click'); |
|
|
|
firstMarker.fire('click'); |
|
|
|
} |
|
|
|
} |
|
|
|
// 启动自动播放 |
|
|
|
// 启动自动播放 |
|
|
|
/**************************** CodeGeeX Inline Diff ****************************/ |
|
|
|
|
|
|
|
startAutoPlay(); |
|
|
|
startAutoPlay(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, 1000); |
|
|
|
}, 1000); |
|
|
|
@ -289,42 +315,20 @@ |
|
|
|
tiandituMap.on('click', () => { |
|
|
|
tiandituMap.on('click', () => { |
|
|
|
if (currentPopup) { |
|
|
|
if (currentPopup) { |
|
|
|
tiandituMap.closePopup(currentPopup); |
|
|
|
tiandituMap.closePopup(currentPopup); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
// 显示标记点弹窗的通用方法 |
|
|
|
|
|
|
|
const showMarkerPopup = (e) => { |
|
|
|
|
|
|
|
/******************** 49ec4b3d-3bf0-41fc-a821-48f719365cbd ********************/ |
|
|
|
|
|
|
|
popupData.value = e.target.options; |
|
|
|
|
|
|
|
const popupContent = ` |
|
|
|
|
|
|
|
<div style="color: white; padding: 10px; font-size: 14px;"> |
|
|
|
|
|
|
|
<h3 style="margin-top: 0;">${popupData.value.stnm}</h3> |
|
|
|
|
|
|
|
<table class='dialog-table' style="width: 100%; border-collapse: collapse;"> |
|
|
|
|
|
|
|
${popupData.value.data.map(row => ` |
|
|
|
|
|
|
|
<tr> |
|
|
|
|
|
|
|
<td style="padding: 5px; width: 50%;">${row.name}${row.unit ? `(${row.unit})` : ''}</td> |
|
|
|
|
|
|
|
<td style="padding: 5px; width: 50%;">${row.value || row.latestValue}</td> |
|
|
|
|
|
|
|
</tr> |
|
|
|
|
|
|
|
`).join('')} |
|
|
|
|
|
|
|
</table> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
`; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建 popup 并设置位置 |
|
|
|
|
|
|
|
currentPopup = L.popup() |
|
|
|
|
|
|
|
.setLatLng(e.target._latlng) |
|
|
|
|
|
|
|
.setContent(popupContent) |
|
|
|
|
|
|
|
.openOn(tiandituMap); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
/*********************************************************** 弹窗 *****************************************/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
onMounted(() => { |
|
|
|
initMap() |
|
|
|
initMap() |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// 组件卸载时清理定时器 |
|
|
|
// 组件卸载时清理定时器 |
|
|
|
onUnmounted(() => { |
|
|
|
onUnmounted(() => { |
|
|
|
if (autoPlayInterval) { |
|
|
|
if (autoPlayInterval) { |
|
|
|
clearInterval(autoPlayInterval); |
|
|
|
clearInterval(autoPlayInterval); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}) |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss"> |
|
|
|
<style scoped lang="scss"> |
|
|
|
@ -343,8 +347,6 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.el-table, |
|
|
|
.el-table, |
|
|
|
.el-table__expanded-cell, |
|
|
|
.el-table__expanded-cell, |
|
|
|
.el-table tr, |
|
|
|
.el-table tr, |
|
|
|
@ -375,8 +377,6 @@ |
|
|
|
color: skyblue; |
|
|
|
color: skyblue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* 隐藏popup的关闭按钮 */ |
|
|
|
/* 隐藏popup的关闭按钮 */ |
|
|
|
|