|
|
@ -1,14 +1,18 @@ |
|
|
|
import { axiosIns } from "@screen/utils/axios/auth.js"; |
|
|
|
import { Message } from "element-ui"; |
|
|
|
|
|
|
|
const PilePointJSON = require(`@screen/pages/Home/components/AMapContainer/data/lcz.json`); |
|
|
|
|
|
|
|
import { setMarkerCluster } from "./map"; |
|
|
|
|
|
|
|
// 0 有 可控(球机)ControlCamera | 1 ⽆ 不可控(枪机)Camera
|
|
|
|
const cameraCtrlMap = { |
|
|
|
0: "ControlCamera", |
|
|
|
1: "Camera", |
|
|
|
}; |
|
|
|
|
|
|
|
const cacheData = { |
|
|
|
DriveTestEquipment_Camera: null, |
|
|
|
export const cacheRemoveFunc = { |
|
|
|
DriveTestEquipment_Camera_Remove: null, |
|
|
|
}; |
|
|
|
|
|
|
|
export const eventMap = { |
|
|
@ -18,15 +22,32 @@ export const eventMap = { |
|
|
|
|
|
|
|
if (!mapIns) return Message.error("地图加载失败!"); |
|
|
|
|
|
|
|
// const { code, data } = await axiosIns
|
|
|
|
// .get("/system/camera/camList")
|
|
|
|
// // .get("/system/dept/camTreeselect")
|
|
|
|
// .catch(() => ({}));
|
|
|
|
const { code, data } = { code: 200 }; |
|
|
|
// {
|
|
|
|
// camId: "57937",
|
|
|
|
// camLat: "0",
|
|
|
|
// camLong: "0",
|
|
|
|
// camName: "G35 K055+565 (可控)",
|
|
|
|
// camOrientation: "2",
|
|
|
|
// camStatus: "0",
|
|
|
|
// camType: "1",
|
|
|
|
// deptId: "1751",
|
|
|
|
// deptName: "G35济菏改扩建",
|
|
|
|
// firmType: "2",
|
|
|
|
// pileNum: "K055+565",
|
|
|
|
// ptzCtrl: "0",
|
|
|
|
// road: "G35",
|
|
|
|
// status: "0",
|
|
|
|
// };
|
|
|
|
|
|
|
|
const { code, data } = await axiosIns |
|
|
|
.get("/system/camera/camList") |
|
|
|
// .get("/system/dept/camTreeselect")
|
|
|
|
.catch(() => ({})); |
|
|
|
// const { code, data } = { code: 200 };
|
|
|
|
|
|
|
|
if (code != 200) return Message.error("摄像机加载失败!"); |
|
|
|
|
|
|
|
// cacheData.DriveTestEquipment_Camera?.clear();
|
|
|
|
cacheRemoveFunc.DriveTestEquipment_Camera_Remove?.(); |
|
|
|
|
|
|
|
const normal = require(`@screen/images/layer${item.id.replace(".", "")}`); |
|
|
|
const fault = require(`@screen/images/layer${item.id.replace( |
|
|
@ -34,85 +55,52 @@ export const eventMap = { |
|
|
|
(data) => (data === "." ? "" : `${data}_fault`) |
|
|
|
)}`);
|
|
|
|
|
|
|
|
const size = 42; |
|
|
|
const markers = []; |
|
|
|
|
|
|
|
const markerClick = (e) => { |
|
|
|
const { |
|
|
|
target: { |
|
|
|
w: { extData }, |
|
|
|
}, |
|
|
|
} = e; |
|
|
|
|
|
|
|
this.cameraDialogConfig = { |
|
|
|
// 0 有(球机) 1 ⽆(枪机)
|
|
|
|
component: cameraCtrlMap[extData.ptzCtrl], |
|
|
|
data: extData, |
|
|
|
}; |
|
|
|
|
|
|
|
const iconOption = { |
|
|
|
type: "image", |
|
|
|
size: [size, size], |
|
|
|
anchor: "center", |
|
|
|
console.log(this.cameraDialogConfig); |
|
|
|
}; |
|
|
|
|
|
|
|
const layer = |
|
|
|
cacheData.DriveTestEquipment_Camera || |
|
|
|
(cacheData.DriveTestEquipment_Camera = new AMap.LabelsLayer({ |
|
|
|
zooms: [3, 20], |
|
|
|
zIndex: 1000, |
|
|
|
collision: false, |
|
|
|
})); |
|
|
|
|
|
|
|
mapIns.add(layer); |
|
|
|
|
|
|
|
const fitViewOverlays = []; |
|
|
|
|
|
|
|
[ |
|
|
|
{ |
|
|
|
camLong: 116.471814, |
|
|
|
camLat: 39.995856, |
|
|
|
status: 0, |
|
|
|
camName: "名称1", |
|
|
|
camId: "666", |
|
|
|
ptzCtrl: 0, |
|
|
|
}, |
|
|
|
{ |
|
|
|
camLong: 116.456474, |
|
|
|
camLat: 39.991563, |
|
|
|
status: 1, |
|
|
|
camName: "名称2", |
|
|
|
camId: "333", |
|
|
|
ptzCtrl: 1, |
|
|
|
}, |
|
|
|
].forEach((item) => { |
|
|
|
iconOption.image = item.status ? fault : normal; |
|
|
|
|
|
|
|
const labelMarker = new AMap.LabelMarker({ |
|
|
|
position: [item.camLong, item.camLat], |
|
|
|
icon: { ...iconOption }, |
|
|
|
name: item.camId, |
|
|
|
zooms: [3, 20], |
|
|
|
zIndex: 36, |
|
|
|
opacity: 1, |
|
|
|
text: { |
|
|
|
content: item.camName, |
|
|
|
direction: "right", |
|
|
|
offset: [(size / 2 + 18) * -1, (size / 2 + 12) * -1], |
|
|
|
style: { |
|
|
|
fontSize: 12, |
|
|
|
fontWeight: "normal", |
|
|
|
fillColor: "#fff", |
|
|
|
strokeColor: "#fff", |
|
|
|
strokeWidth: 1, |
|
|
|
fold: true, |
|
|
|
padding: "3, 6", |
|
|
|
}, |
|
|
|
}, |
|
|
|
}); |
|
|
|
data.forEach((item) => { |
|
|
|
const { lng, lat } = PilePointJSON[item.pileNum] || {}; |
|
|
|
|
|
|
|
fitViewOverlays.push(labelMarker); |
|
|
|
if (!lat || !lng) return; |
|
|
|
|
|
|
|
labelMarker.on("click", (e) => { |
|
|
|
this.cameraDialogConfig = { |
|
|
|
// 0 有(球机) 1 ⽆(枪机)
|
|
|
|
component: cameraCtrlMap[item.ptzCtrl], |
|
|
|
data: item, |
|
|
|
}; |
|
|
|
const marker = new AMap.Marker({ |
|
|
|
position: [lng, lat], |
|
|
|
content: `<img style="width: 36px; height: 36px" src='${ |
|
|
|
item.status !== "0" ? fault : normal |
|
|
|
}'>`,
|
|
|
|
offset: new AMap.Pixel(-15, -15), |
|
|
|
extData: item, |
|
|
|
clickable: true, |
|
|
|
}); |
|
|
|
|
|
|
|
layer.add(labelMarker); |
|
|
|
marker.on("click", markerClick); |
|
|
|
|
|
|
|
markers.push(marker); |
|
|
|
}); |
|
|
|
|
|
|
|
mapIns.setFitView(fitViewOverlays, false, [360, 360, 360, 360]); |
|
|
|
const markerCluster = await setMarkerCluster(mapIns, markers); |
|
|
|
|
|
|
|
cacheRemoveFunc.DriveTestEquipment_Camera_Remove = () => |
|
|
|
markerCluster.clearMarkers(); |
|
|
|
|
|
|
|
mapIns.setFitView(markers, false, [360, 360, 360, 360]); |
|
|
|
}, |
|
|
|
async "路测设备/摄像机_close"() { |
|
|
|
cacheData.DriveTestEquipment_Camera?.clear(); |
|
|
|
cacheRemoveFunc.DriveTestEquipment_Camera_Remove?.(); |
|
|
|
}, |
|
|
|
}; |
|
|
|