|
@@ -1,5 +1,15 @@
|
|
<template>
|
|
<template>
|
|
<div class="map-container">
|
|
<div class="map-container">
|
|
|
|
+ <div class="status-info">
|
|
|
|
+ <div class="status-item">
|
|
|
|
+ <span class="online-icon"></span>
|
|
|
|
+ <span style="font-weight: bold;font-size: 17px">在线数量 {{ inlineCount }}</span>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="status-item">
|
|
|
|
+ <span class="offline-icon"></span>
|
|
|
|
+ <span style="font-weight: bold;font-size: 17px">离线数量 {{ outlineCount }}</span>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
<div id="baidu-map" ref="mapContainer"></div>
|
|
<div id="baidu-map" ref="mapContainer"></div>
|
|
<div class="map-controls">
|
|
<div class="map-controls">
|
|
<button @click="zoomIn">{{t('map.amplify')}}</button>
|
|
<button @click="zoomIn">{{t('map.amplify')}}</button>
|
|
@@ -32,8 +42,6 @@ const drawerVisible = ref<boolean>(false)
|
|
const mapContainer = ref<HTMLElement | null>(null)
|
|
const mapContainer = ref<HTMLElement | null>(null)
|
|
const map = ref<any>(null)
|
|
const map = ref<any>(null)
|
|
const mapType = ref<'BMAP_NORMAL_MAP' | 'BMAP_SATELLITE_MAP'>('BMAP_NORMAL_MAP')
|
|
const mapType = ref<'BMAP_NORMAL_MAP' | 'BMAP_SATELLITE_MAP'>('BMAP_NORMAL_MAP')
|
|
-const selectedDevice = ref<IotDeviceVO | null>(null)
|
|
|
|
-const hoverDevice = ref<IotDeviceVO | null>(null)
|
|
|
|
const clusters = ref<Cluster[]>([])
|
|
const clusters = ref<Cluster[]>([])
|
|
const deviceId = ref()
|
|
const deviceId = ref()
|
|
const deviceName = ref('')
|
|
const deviceName = ref('')
|
|
@@ -42,6 +50,8 @@ const ifLine = ref()
|
|
const dept = ref('')
|
|
const dept = ref('')
|
|
const deviceCode = ref('')
|
|
const deviceCode = ref('')
|
|
const { t } = useI18n() // 国际化
|
|
const { t } = useI18n() // 国际化
|
|
|
|
+const inlineCount = ref(0)
|
|
|
|
+const outlineCount = ref(0)
|
|
// 设备数据示例
|
|
// 设备数据示例
|
|
const devices = ref<IotDeviceVO[]>()
|
|
const devices = ref<IotDeviceVO[]>()
|
|
|
|
|
|
@@ -56,7 +66,7 @@ const initMap = () => {
|
|
if ((window as any).BMap) {
|
|
if ((window as any).BMap) {
|
|
map.value = new (window as any).BMap.Map(mapContainer.value)
|
|
map.value = new (window as any).BMap.Map(mapContainer.value)
|
|
const point = new (window as any).BMap.Point(104.114129, 37.550339)
|
|
const point = new (window as any).BMap.Point(104.114129, 37.550339)
|
|
- map.value.centerAndZoom(point, 5.5)
|
|
|
|
|
|
+ map.value.centerAndZoom(point, 5)
|
|
|
|
|
|
map.value.enableScrollWheelZoom(true)
|
|
map.value.enableScrollWheelZoom(true)
|
|
map.value.setMapType((window as any)[mapType.value])
|
|
map.value.setMapType((window as any)[mapType.value])
|
|
@@ -84,7 +94,8 @@ const initDeviceMarkers = () => {
|
|
map.value.clearOverlays()
|
|
map.value.clearOverlays()
|
|
|
|
|
|
const zoomLevel = map.value.getZoom()
|
|
const zoomLevel = map.value.getZoom()
|
|
- if (zoomLevel > 9) {
|
|
|
|
|
|
+ if (zoomLevel > 8) {
|
|
|
|
+ debugger
|
|
// 高缩放级别下显示单个设备标记
|
|
// 高缩放级别下显示单个设备标记
|
|
devices.value.forEach((device) => {
|
|
devices.value.forEach((device) => {
|
|
const point = new (window as any).BMap.Point(device.lng, device.lat)
|
|
const point = new (window as any).BMap.Point(device.lng, device.lat)
|
|
@@ -92,6 +103,7 @@ const initDeviceMarkers = () => {
|
|
map.value.addOverlay(marker)
|
|
map.value.addOverlay(marker)
|
|
})
|
|
})
|
|
} else {
|
|
} else {
|
|
|
|
+ debugger
|
|
// 低缩放级别下进行聚合
|
|
// 低缩放级别下进行聚合
|
|
clusters.value = clusterDevices(devices.value, map.value)
|
|
clusters.value = clusterDevices(devices.value, map.value)
|
|
clusters.value.forEach((cluster) => {
|
|
clusters.value.forEach((cluster) => {
|
|
@@ -116,9 +128,9 @@ const initDeviceMarkers = () => {
|
|
const createDeviceMarker = (device: IotDeviceVO, point: any) => {
|
|
const createDeviceMarker = (device: IotDeviceVO, point: any) => {
|
|
// 根据设备是否在线选择不同的图标
|
|
// 根据设备是否在线选择不同的图标
|
|
const iconUrl = device.ifInline === 3
|
|
const iconUrl = device.ifInline === 3
|
|
- ? import.meta.env.VITE_BASE_URL + '/images/newding.svg'
|
|
|
|
- : import.meta.env.VITE_BASE_URL + '/images/newfail.svg';
|
|
|
|
-
|
|
|
|
|
|
+ ? 'https://iot.deepoil.cc' + '/images/newding.svg'
|
|
|
|
+ : 'https://iot.deepoil.cc' + '/images/newfail.svg';
|
|
|
|
+debugger
|
|
const marker = new (window as any).BMap.Marker(point, {
|
|
const marker = new (window as any).BMap.Marker(point, {
|
|
icon: new (window as any).BMap.Icon(
|
|
icon: new (window as any).BMap.Icon(
|
|
iconUrl,
|
|
iconUrl,
|
|
@@ -198,8 +210,8 @@ const createClusterLabel = (cluster: Cluster, point: any) => {
|
|
label.addEventListener('click', () => {
|
|
label.addEventListener('click', () => {
|
|
if (map.value) {
|
|
if (map.value) {
|
|
const currentZoom = map.value.getZoom();
|
|
const currentZoom = map.value.getZoom();
|
|
- const MAX_ZOOM = 19; // 手动设定最大缩放级别
|
|
|
|
- const newZoom = Math.min(currentZoom + 3, MAX_ZOOM);
|
|
|
|
|
|
+ const MAX_ZOOM = 12; // 手动设定最大缩放级别
|
|
|
|
+ const newZoom = Math.min(currentZoom + 2, MAX_ZOOM);
|
|
map.value.setZoom(newZoom);
|
|
map.value.setZoom(newZoom);
|
|
map.value.panTo(point);
|
|
map.value.panTo(point);
|
|
initDeviceMarkers(); // 重新计算并显示标记和聚合标签
|
|
initDeviceMarkers(); // 重新计算并显示标记和聚合标签
|
|
@@ -237,9 +249,10 @@ const clusterDevices = (devices: IotDeviceVO[], map: any): Cluster[] => {
|
|
}
|
|
}
|
|
|
|
|
|
const getGridSize = (zoom: number): number => {
|
|
const getGridSize = (zoom: number): number => {
|
|
- if (zoom <= 5) return 2
|
|
|
|
- if (zoom <= 8) return 1
|
|
|
|
- if (zoom < 10) return 0.03
|
|
|
|
|
|
+ debugger
|
|
|
|
+ if (zoom <= 5) return 5
|
|
|
|
+ if (zoom <= 8) return 3
|
|
|
|
+ if (zoom < 10) return 0.1
|
|
return 0.1
|
|
return 0.1
|
|
}
|
|
}
|
|
|
|
|
|
@@ -313,6 +326,8 @@ const toggleMapType = () => {
|
|
const getData = async () => {
|
|
const getData = async () => {
|
|
await IotDeviceApi.getMapDevice().then((res) => {
|
|
await IotDeviceApi.getMapDevice().then((res) => {
|
|
devices.value = res.filter((item)=> item.lat!=0&&item.lng!=0)
|
|
devices.value = res.filter((item)=> item.lat!=0&&item.lng!=0)
|
|
|
|
+ outlineCount.value = devices.value.filter((item)=> item.ifInline===4).length
|
|
|
|
+ inlineCount.value = devices.value.filter((item)=> item.ifInline===3).length
|
|
initMap()
|
|
initMap()
|
|
})
|
|
})
|
|
}
|
|
}
|
|
@@ -374,4 +389,44 @@ onBeforeUnmount(() => {
|
|
border-radius: 3px;
|
|
border-radius: 3px;
|
|
cursor: pointer;
|
|
cursor: pointer;
|
|
}
|
|
}
|
|
|
|
+.status-info {
|
|
|
|
+ position: absolute;
|
|
|
|
+ top: 20px;
|
|
|
|
+ left: 40%;
|
|
|
|
+ z-index: 1000;
|
|
|
|
+ background: white;
|
|
|
|
+ padding: 10px 15px;
|
|
|
|
+ border-radius: 6px;
|
|
|
|
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
|
|
|
+ display: flex;
|
|
|
|
+ gap: 20px;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.status-item {
|
|
|
|
+ display: flex;
|
|
|
|
+ align-items: center;
|
|
|
|
+ gap: 8px;
|
|
|
|
+ font-size: 14px;
|
|
|
|
+ height: 50px;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.online-icon {
|
|
|
|
+ display: inline-block;
|
|
|
|
+ width: 25px;
|
|
|
|
+ height: 25px;
|
|
|
|
+ background-image: url('https://aims.deepoil.cc/images/newding.svg');
|
|
|
|
+ background-size: contain;
|
|
|
|
+ background-repeat: no-repeat;
|
|
|
|
+ background-position: center;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.offline-icon {
|
|
|
|
+ display: inline-block;
|
|
|
|
+ width: 25px;
|
|
|
|
+ height: 25px;
|
|
|
|
+ background-image: url('https://aims.deepoil.cc/images/newfail.svg');
|
|
|
|
+ background-size: contain;
|
|
|
|
+ background-repeat: no-repeat;
|
|
|
|
+ background-position: center;
|
|
|
|
+}
|
|
</style>
|
|
</style>
|