import {eventMap} from "../index.js";
import { timestampFormatTime } from "../../../../public/js/timestamp.js";
import { setFaceAlarmRead } from "../../api/setFaceAlarmRead.js";
import { emptyPoygon } from "../showPoliceAlarm.js";
import { showPoliceAlarm } from "../showPoliceAlarm.js";
var schoolSignMarkers_cus=null;
var personSignMarkers_cus=null;
var clockMarkerHash={};
function addClockMarkerHash(eventId,marker){
clockMarkerHash[eventId]=marker;
}
function initSchoolClockCus(){
schoolSignMarkers_cus = L.markerClusterGroup({iconCreateFunction: function(cluster) {
return L.divIcon({ html: `
${cluster.getChildCount()}
` });
}});
personSignMarkers_cus = L.markerClusterGroup({iconCreateFunction: function(cluster) {
return L.divIcon({ html: `
${cluster.getChildCount()}
` });
}});
}
function emptySignMarkers_cus(){
if(schoolSignMarkers_cus!=null){
schoolSignMarkers_cus.clearLayers();
schoolSignMarkers_cus=null;
}
if(personSignMarkers_cus!=null){
personSignMarkers_cus.clearLayers();
personSignMarkers_cus=null;
}
for(var eventId in clockMarkerHash){
eventMap.removeLayer(clockMarkerHash[eventId]);
delete clockMarkerHash[eventId];
}
initSchoolClockCus()
}
function drawAlarmEventMarker(eventArr){
console.log(eventArr);
emptySignMarkers_cus();
eventArr.forEach(item => {
let longitude=item["longitude"];
let latitude=item["latitude"];
let alarmId=item["alarmId"];
let cameraName=item["cameraName"];
var iconObj=L.icon({
iconUrl:"./image/wb_ipc.png",//图片路径
iconSize: [24, 24]//图片大小设置
});
let marker=L.marker([latitude,longitude],{
icon: iconObj,//将marker设置为上面引用的图形
});
marker.bindTooltip(cameraName).openTooltip();
marker.on('click',function(e){
showSchoolBaseInfo(item);
})
addClockMarkerHash(alarmId,marker);
schoolSignMarkers_cus.addLayer(marker);
});
eventMap.addLayer(schoolSignMarkers_cus);
eventMap.setView([eventArr[0]["latitude"],eventArr[0]["longitude"]], 18);
}
function drawPersonEventMarker(eventArr){
emptySignMarkers_cus();
eventArr.forEach(item => {
let longitude=item["longitude"];
let latitude=item["latitude"];
let alarmId=item["alarmId"];
let cameraName=item["cameraName"];
var iconObj=L.icon({
iconUrl:"./image/wb_baoan.png",//图片路径
iconSize: [24, 24]//图片大小设置
});
let marker=L.marker([latitude,longitude],{
icon: iconObj,//将marker设置为上面引用的图形
});
marker.bindTooltip(cameraName).openTooltip();
marker.on('click',function(e){
showSchoolBaseInfo(item);
})
addClockMarkerHash(alarmId,marker);
personSignMarkers_cus.addLayer(marker);
});
eventMap.addLayer(personSignMarkers_cus);
eventMap.setView([eventArr[0]["latitude"],eventArr[0]["longitude"]], 18);
}
window.ipcAlarmSetRead=function(that){
var alarmId=$(that).parent().attr("alarmId");
setFaceAlarmRead(alarmId).then(res=>{
var code=res["data"]["code"];
if(code==0){
layer.msg('请求成功')
resetAlarmEventMap(alarmId);
}else{
layer.msg('请求失败')
}
})
}
function resetAlarmEventMap(alarmId){
emptySignMarkers_cus();
emptyPoygon();
showPoliceAlarm();
$(".schoolInfoBox").html("");
$(".currentSchoolAlarmListAllBox").html("");
$(".schoolAlarmInfo .titleBg").html("预警信息")
}
function showSchoolBaseInfo(item){
var alarmCode=item["personLibName"];
var station=item["station"];
var alarmTime=timestampFormatTime(new Date(item["alarmTime"]).getTime());
var address=item["cameraName"];
var eventId=item["alarmId"];
var pic=item["snappedPicUrl"]
var blackType=item["certificateTypeName"]
var idNumber=item["certificateNumber"];
var blackName=item["personName"];
var groupType=item["groupType"];
clockMarkerHash[eventId].unbindPopup();
clockMarkerHash[eventId].bindPopup(
` [${alarmCode}]${address}
${blackType}:
${blackName}/${idNumber}
学校名称:
${station}
时间:${alarmTime}
`,
).openPopup();
}
export {
drawAlarmEventMarker,
drawPersonEventMarker
}