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: `
${cluster.getChildCount()}
`}); }}); //标记绑定弹窗显示 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(`
${getPushButtonInfoWindowDiv(obj)}
`,{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=`

`; } if(devicetype=="asr_a"){ div=`

`; } return `

点位名称 ${item["pointAddress"]}

学校名称 ${item["station"]}

所属分局 长沙芙蓉分局

所属派出所 ${item["borough"]}

联系人 ${user1Name}/${user1Phone}

联系人2 ${user2Name}/${user2Phone}

联系人3 ${user3Name}/${user3Phone}

${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 }