155 lines
5.4 KiB
JavaScript
155 lines
5.4 KiB
JavaScript
|
import { schoolPushButtonList } from "../showPushButtonInfo.js";
|
||
|
import { mainMap } from "../index.js";
|
||
|
import { popSosVideo } from "../popSosVideo.js";
|
||
|
import { popSosAudio } from "../popSosAudio.js";
|
||
|
import { pushButtonEventFindId } from "./pushButtonEventMarker.js";
|
||
|
let pushButtonMarkerHash={};
|
||
|
let cusPushButtonMarkers=null;
|
||
|
function deletePushButtonMarker(){
|
||
|
for(var i in pushButtonMarkerHash){
|
||
|
delete pushButtonMarkerHash[i]
|
||
|
}
|
||
|
cusPushButtonMarkers.clearLayers();
|
||
|
}
|
||
|
function addPushButtonMarkerHash(id,marker){
|
||
|
pushButtonMarkerHash[id]=marker;
|
||
|
}
|
||
|
function drawPushButtonMarker(){
|
||
|
cusPushButtonMarkers = L.markerClusterGroup({
|
||
|
maxClusterRadius: 50,
|
||
|
spiderfyOnMaxZoom: true,
|
||
|
showCoverageOnHover: true,
|
||
|
zoomToBoundsOnClick: true,
|
||
|
iconCreateFunction: function(cluster) {
|
||
|
return L.divIcon({ html: `<div class="polyMarker-cusmarker">
|
||
|
<img src="./pages/cmddispatch/image/pushbutton.png">
|
||
|
<span> ${cluster.getChildCount()}</span>
|
||
|
</div>`});
|
||
|
}});
|
||
|
//标记绑定弹窗显示
|
||
|
schoolPushButtonList.forEach(item=>{
|
||
|
var deviceId=item["deviceId"];
|
||
|
var pointAddress=item["pointAddress"];
|
||
|
let longitude=item["longitude"];
|
||
|
let latitude=item["latitude"];
|
||
|
var iconObj=getPushButtonNormalIcon(item);
|
||
|
let marker=L.marker([latitude,longitude],{
|
||
|
icon: iconObj,//将marker设置为上面引用的图形
|
||
|
title:pointAddress,
|
||
|
riseOnHover:true
|
||
|
});
|
||
|
marker.bindTooltip(item["pointAddress"]).openTooltip();
|
||
|
marker.on('click',function(e){
|
||
|
showPushButtonInfoWindow(item);
|
||
|
})
|
||
|
addPushButtonMarkerHash(deviceId,marker)
|
||
|
cusPushButtonMarkers.addLayer(marker);
|
||
|
})
|
||
|
mainMap.addLayer(cusPushButtonMarkers);
|
||
|
}
|
||
|
function showPushButtonInfoWindow(obj){
|
||
|
var deviceId=obj["deviceId"];
|
||
|
if(deviceId in pushButtonMarkerHash){
|
||
|
pushButtonMarkerHash[deviceId].unbindPopup();
|
||
|
pushButtonMarkerHash[deviceId].bindPopup(`<div class="skynetIpcInfoWindow">${getPushButtonInfoWindowDiv(obj)}</div>`,{maxHeight:260}).openPopup();
|
||
|
var lnglat= pushButtonMarkerHash[deviceId].getLatLng()
|
||
|
mainMap.setView(lnglat, 18);
|
||
|
}
|
||
|
}
|
||
|
function getPushButtonInfoWindowDiv(item){
|
||
|
var user1Name=item["user1Name"]==null?"":item["user1Name"];
|
||
|
var user1Phone=item["user1Phone"]==null?"":item["user1Phone"];;
|
||
|
var user2Name=item["user2Name"]==null?"":item["user2Name"];;
|
||
|
var user2Phone=item["user2Phone"]==null?"":item["user2Phone"];;
|
||
|
var user3Name=item["user3Name"]==null?"":item["user3Name"];;
|
||
|
var user3Phone=item["user3Phone"]==null?"":item["user3Phone"];;
|
||
|
var devicetype=item["deviceType"];
|
||
|
var deviceId=item["deviceId"];
|
||
|
var div="";
|
||
|
if(devicetype=="asr_av"){
|
||
|
div=`<div>
|
||
|
<p>
|
||
|
<button deviceid="${deviceId}" class="layui-btn layui-btn-normal deviceopearbtn" onclick="sosVideo(this)">
|
||
|
视频
|
||
|
</button>
|
||
|
<button deviceid="${deviceId}" class="layui-btn layui-btn-normal deviceopearbtn" onclick="sosAudio(this)">
|
||
|
对讲
|
||
|
</button>
|
||
|
</p>
|
||
|
</div>`;
|
||
|
}
|
||
|
if(devicetype=="asr_a"){
|
||
|
div=`<div>
|
||
|
<p>
|
||
|
<button deviceid="${deviceId}" class="layui-btn layui-btn-normal deviceopearbtn" onclick="sosAudio(this)">
|
||
|
对讲
|
||
|
</button>
|
||
|
</p>
|
||
|
</div>`;
|
||
|
}
|
||
|
return `<div>
|
||
|
<div class="skynetIpcTop">
|
||
|
<div>
|
||
|
<p>
|
||
|
<span>点位名称</span>
|
||
|
<span title="${item["pointAddress"]}">${item["pointAddress"]}</span>
|
||
|
</p>
|
||
|
<p>
|
||
|
<span>学校名称</span>
|
||
|
<span title="${item["station"]}">${item["station"]}</span>
|
||
|
</p>
|
||
|
</div>
|
||
|
<div>
|
||
|
<p>
|
||
|
<span>所属分局</span>
|
||
|
<span>长沙芙蓉分局</span>
|
||
|
</p>
|
||
|
<p>
|
||
|
<span>所属派出所</span>
|
||
|
<span title="${item["borough"]}">${item["borough"]}</span>
|
||
|
</p>
|
||
|
</div>
|
||
|
<div>
|
||
|
<p>
|
||
|
<span>联系人</span>
|
||
|
<span>${user1Name}/${user1Phone}</span>
|
||
|
</p>
|
||
|
</div>
|
||
|
<div>
|
||
|
<p>
|
||
|
<span>联系人2</span>
|
||
|
<span>${user2Name}/${user2Phone}</span>
|
||
|
</p>
|
||
|
<p>
|
||
|
<span>联系人3</span>
|
||
|
<span>${user3Name}/${user3Phone}</span>
|
||
|
</p>
|
||
|
</div>
|
||
|
<div>
|
||
|
${div}
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>`
|
||
|
}
|
||
|
window.sosVideo=function(that){
|
||
|
var deviceId=$(that).attr("deviceid");
|
||
|
var obj=pushButtonEventFindId(deviceId)
|
||
|
popSosVideo(obj);
|
||
|
}
|
||
|
window.sosAudio=function(that){
|
||
|
var deviceId=$(that).attr("deviceid");
|
||
|
var obj=pushButtonEventFindId(deviceId)
|
||
|
popSosAudio(obj);
|
||
|
}
|
||
|
//获取移动设备的Icon
|
||
|
function getPushButtonNormalIcon(){
|
||
|
return L.icon({
|
||
|
iconUrl:"./pages/cmddispatch/image/pushbutton.png",//图片路径
|
||
|
iconSize: [24, 24]//图片大小设置
|
||
|
});
|
||
|
}
|
||
|
export {
|
||
|
drawPushButtonMarker,
|
||
|
deletePushButtonMarker,
|
||
|
getPushButtonInfoWindowDiv
|
||
|
}
|