anxiao_web/pages/newIntelligenceEarlyWarning/js/marker/schoolMarker.js

163 lines
5.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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: `<div class="polyMarker-cusmarker">
<img src="./image/wb_ipc.png">
<span> ${cluster.getChildCount()}</span>
</div>` });
}});
personSignMarkers_cus = L.markerClusterGroup({iconCreateFunction: function(cluster) {
return L.divIcon({ html: `<div class="polyMarker-cusmarker">
<img src="./image/wb_baoan.png">
<span> ${cluster.getChildCount()}</span>
</div>` });
}});
}
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(
` <p><span style="color:#E7B554;">[${alarmCode}]</span>${address}</p>
<div class="warnEventInfoWindow">
<p>
<img src="${pic}">
</p>
<div>
<p>
<span>${blackType}</span>
<span>${blackName}/${idNumber}</span>
</p>
<p>
<span>学校名称:</span>
<span>${station}</span>
</p>
<p>
<span>时间:${alarmTime}</span>
</p>
</div>
</div>`,
).openPopup();
}
export {
drawAlarmEventMarker,
drawPersonEventMarker
}