|
|
@ -7,8 +7,10 @@ import { delay } from "@screen/utils/common"; |
|
|
|
import { Message } from "element-ui"; |
|
|
|
import { EventTopics } from "@screen/utils/enum.js"; |
|
|
|
import { debounce } from "lodash"; |
|
|
|
import Vue from "vue"; |
|
|
|
|
|
|
|
import { markerClusterIns } from "./map"; |
|
|
|
const canvasCtx = Vue.prototype.canvasCtx; |
|
|
|
|
|
|
|
const cameraIcon = { |
|
|
|
// 球机
|
|
|
@ -75,6 +77,7 @@ export const DeviceForMap = { |
|
|
|
}, |
|
|
|
}; |
|
|
|
|
|
|
|
export const lngLatMap = {}; //优化 缩略图 + 地图 复用lngLatmap
|
|
|
|
export function getHandleDeviceType(item) { |
|
|
|
if (DeviceForMap[item.title]) return "地图路测设备/map"; |
|
|
|
if (EventTopics[item.title]) return "地图事件专题/map"; |
|
|
@ -153,11 +156,13 @@ export const eventMap = { |
|
|
|
"font-size:15px; background:#83c806; color:#c7ff4a;", |
|
|
|
removeData |
|
|
|
); |
|
|
|
|
|
|
|
addDataPreHandle(removeData); |
|
|
|
markerClusterIns.addData(removeData); |
|
|
|
|
|
|
|
cacheRemoveFunc[`地图路测设备/${item.title}`] = () => |
|
|
|
cacheRemoveFunc[`地图路测设备/${item.title}`] = () => { |
|
|
|
removeDataPreHandle(removeData); |
|
|
|
markerClusterIns.removeData(removeData); |
|
|
|
}; |
|
|
|
}, |
|
|
|
"地图路测设备/map_close"(item) { |
|
|
|
cacheRemoveFunc[`地图路测设备/${item.title}`]?.(); |
|
|
@ -204,11 +209,13 @@ export const eventMap = { |
|
|
|
isDefault |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
addDataPreHandle(removeData); |
|
|
|
markerClusterIns.addData(removeData); |
|
|
|
|
|
|
|
cacheRemoveFunc[`地图事件专题/${item.title}`] = () => |
|
|
|
cacheRemoveFunc[`地图事件专题/${item.title}`] = () => { |
|
|
|
removeDataPreHandle(removeData); |
|
|
|
markerClusterIns.removeData(removeData); |
|
|
|
}; |
|
|
|
}, |
|
|
|
"地图事件专题/map_close"(item) { |
|
|
|
cacheRemoveFunc[`地图事件专题/${item.title}`]?.(); |
|
|
@ -249,15 +256,57 @@ export const eventMap = { |
|
|
|
let removeData = data.map((item) => |
|
|
|
resolveDataOptions.call(this, item, options, "PerceiveEvent", isDefault) |
|
|
|
); |
|
|
|
|
|
|
|
addDataPreHandle(removeData); |
|
|
|
markerClusterIns.addData(removeData); |
|
|
|
|
|
|
|
loadingMessage?.close(); |
|
|
|
|
|
|
|
cacheRemoveFunc[`事件专题/${item.title}`] = () => |
|
|
|
cacheRemoveFunc[`事件专题/${item.title}`] = () => { |
|
|
|
removeDataPreHandle(removeData); |
|
|
|
markerClusterIns.removeData(removeData); |
|
|
|
}; |
|
|
|
}, |
|
|
|
"事件专题/感知事件_close"(item) { |
|
|
|
cacheRemoveFunc[`事件专题/${item.title}`]?.(); |
|
|
|
}, |
|
|
|
}; |
|
|
|
|
|
|
|
function lngLatMapHandle(markers, cb) { |
|
|
|
markers.forEach((markerData) => { |
|
|
|
const lnglat = markerData.lnglat; |
|
|
|
if (lnglat) { |
|
|
|
const getLatAndLng = () => { |
|
|
|
if (Array.isArray(lnglat)) return { lng: lnglat[0], lat: lnglat[1] }; |
|
|
|
else return lnglat; |
|
|
|
}; |
|
|
|
const { lat, lng } = getLatAndLng(); |
|
|
|
const lngLatStr = `${lng}/${lat}`; |
|
|
|
cb(lngLatStr, markerData); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function addDataPreHandle(markers) { |
|
|
|
const cb = (lngLatStr, markerData) => { |
|
|
|
if (lngLatMap[lngLatStr]) |
|
|
|
!lngLatMap[lngLatStr].includes(markerData) && |
|
|
|
lngLatMap[lngLatStr].push(markerData); |
|
|
|
else lngLatMap[lngLatStr] = [markerData]; |
|
|
|
}; |
|
|
|
lngLatMapHandle(markers, cb); |
|
|
|
} |
|
|
|
|
|
|
|
function removeDataPreHandle(markers) { |
|
|
|
const cb = (lngLatStr, markerData) => { |
|
|
|
if (lngLatMap[lngLatStr]) { |
|
|
|
if (lngLatMap[lngLatStr].length < 2) delete lngLatMap[lngLatStr]; |
|
|
|
else { |
|
|
|
const findIndex = lngLatMap[lngLatStr].findIndex( |
|
|
|
(removeData) => removeData === markerData |
|
|
|
); |
|
|
|
lngLatMap[lngLatStr].splice(findIndex, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
lngLatMapHandle(markers, cb); |
|
|
|
} |
|
|
|