anxiao_web/pages/cmddispatch/js/marker/moveDeviceEventMarker.js

119 lines
4.2 KiB
JavaScript
Raw Normal View History

2024-07-24 09:22:32 +08:00
import { mainMap,layuiObj } from "../index.js";
import { stopDeviceSosAudio } from "../../audio/audio.js";
import { setMdevAlarmResive } from "../showAlarmListTable.js";
import { mdevAlarmHandleDrawCircle, getMoveDeviceInfoWindowDiv } from "./moveDeviceMarker.js";
var moveDeviceAlarmMarker={};
function delMoveDeviceAlarmMarker(id){
if(id in moveDeviceAlarmMarker){
mainMap.removeLayer(moveDeviceAlarmMarker[id]);
delete moveDeviceAlarmMarker[id]
}
}
function addMoveDeviceAlarmMarker(obj){
var deviceid=obj['deviceid'];
var longitude=obj["longitude"];
var latitude=obj["latitude"];
var address=obj["address"];
var iconObj=getMoveDeviceAlarmIcon(obj)
let marker=L.marker([latitude,longitude],{
icon: iconObj,//将marker设置为上面引用的图形
title:address,
riseOnHover:false,
zIndexOffset:1000
})
if(!(deviceid in moveDeviceAlarmMarker)){
moveDeviceAlarmMarker[deviceid]=marker
}
marker.bindTooltip(address).openTooltip();
marker.on('click',function(e){
showAlarmMoveDeviceInfoWindow(obj);
})
//把 Marker 添加到图层
mainMap.addLayer(marker);
setMdevMarkerCenter();
}
//设置中心点
function setMdevMarkerCenter(){
let length = Object.keys(moveDeviceAlarmMarker).length;
if(length<2){
for(var i in moveDeviceAlarmMarker){
var lnglat=moveDeviceAlarmMarker[i].getLatLng();
mainMap.setView(lnglat, 18);
}
}
}
function showAlarmMoveDeviceInfoWindow(obj){
var deviceid=obj["deviceid"];
if(deviceid in moveDeviceAlarmMarker){
moveDeviceAlarmMarker[deviceid].unbindPopup();
moveDeviceAlarmMarker[deviceid].bindPopup(`<div class="moveDeviceInfoWindow">${getMoveDeviceInfoWindowDiv(obj)}</div>`,{maxHeight:260}).openPopup();
mainMap.setView([obj["latitude"],obj["longitude"]], 18);
}
}
function getMoveDeviceAlarmIcon(obj){
var deviceid=obj["deviceid"];
return L.divIcon({
className: "my-div-icon",
html: `
<div class="markerClass">
<div></div>
<div></div>
<div></div>
</div>
<div class="moveDeviceAlarmOpear">
<div>
<p>
<img src="./pages/cmddispatch/infowindow/alarm.png">
姓名${obj["showname"]}
</p>
<p>
联系方式${obj["username"]}/${obj["userphone"]}
</p>
</div>
<div>
<p>
<button type="button" devicid="${deviceid}" class="layui-btn layui-btn-normal deviceopearbtn" onclick="moveDeviceAlarmMute(this)">
<img src="./pages/cmddispatch/infowindow/mute.png">消音
</button>
<button type="button" alarmid="${obj["alarmid"]}" devicid="${deviceid}" class="layui-btn layui-btn-normal deviceopearbtn" onclick="moveDeviceAlarmRelive(this)">
<img src="./pages/cmddispatch/infowindow/removeAlarm.png">解除
</button>
<button type="button" devicid="${deviceid}" class="layui-btn layui-btn-normal deviceopearbtn" onclick="moveDeviceAlarmHandle(this)">
<img src="./pages/cmddispatch/infowindow/handle.png">处置
</button>
</p>
</div>
</div>`
})
}
//消音
window.moveDeviceAlarmMute=function(that){
var deviceid=$(that).attr("devicid");
stopDeviceSosAudio(deviceid)
}
//解除
window.moveDeviceAlarmRelive=function(that){
var deviceid=$(that).attr("devicid");
var alarmid=$(that).attr("alarmid");
layer.confirm('确定需要解除吗?', {icon: 3, title:'提示'}, function(index){
setMdevAlarmResive(alarmid,deviceid);
layuiObj.layer.close(index);
})
}
//处置
window.moveDeviceAlarmHandle=function(that){
var deviceid=$(that).attr("devicid");
mdevAlarmHandleDrawCircle(deviceid)
}
export {
addMoveDeviceAlarmMarker,
delMoveDeviceAlarmMarker
}