import { stationInfoTableList,mainMap} from "../index.js"; import { getSchoolInfoDiv,showSchoolBaseInfo} from "../schoolBaseInfo.js"; var schoolMarkerHash={}; var school_y_arr=[]; var school_x_arr=[]; var school_z_arr=[]; var cusSchoolMarkers_y = null; var cusSchoolMarkers_x = null; var cusSchoolMarkers_z = null; function addSchoolMarkerHash(id,marker){ schoolMarkerHash[id]=marker; } function deleteSchoolMarker_y(){ if(cusSchoolMarkers_y!=null){ cusSchoolMarkers_y.clearLayers(); cusSchoolMarkers_y=null; } } function deleteSchoolMarker_x(){ if(cusSchoolMarkers_x!=null){ cusSchoolMarkers_x.clearLayers(); cusSchoolMarkers_x=null; } } function deleteSchoolMarker_z(){ if(cusSchoolMarkers_z!=null){ cusSchoolMarkers_z.clearLayers(); cusSchoolMarkers_z=null; } } function addSchoolMarker_y(){ //标记绑定弹窗显示 cusSchoolMarkers_y = L.markerClusterGroup({iconCreateFunction: function(cluster) { return L.divIcon({ html: `
${cluster.getChildCount()}
` }); }}); school_y_arr.forEach(item=>{ let longitude=item["longitude"]; let latitude=item["latitude"]; let deviceid=item["device_id"]; var iconObj=L.icon({ iconUrl:"./pages/cmddispatch/image/wb_school_y.png",//图片路径 iconSize: [24, 24]//图片大小设置 }); let marker=L.marker([latitude,longitude],{ icon: iconObj,//将marker设置为上面引用的图形 }); marker.bindTooltip(item["name"]).openTooltip(); marker.on('click',function(e){ showSchoolBaseInfo(item) }) addSchoolMarkerHash(deviceid,marker); cusSchoolMarkers_y.addLayer(marker); }) mainMap.addLayer(cusSchoolMarkers_y); } function addSchoolMarker_x(){ cusSchoolMarkers_x= L.markerClusterGroup({iconCreateFunction: function(cluster) { return L.divIcon({ html: `
${cluster.getChildCount()}
` }); }}); school_x_arr.forEach(item=>{ let longitude=item["longitude"]; let latitude=item["latitude"]; let deviceid=item["device_id"]; var iconObj=L.icon({ iconUrl:"./pages/cmddispatch/image/wb_school_x.png",//图片路径 iconSize: [24, 24]//图片大小设置 }); let marker=L.marker([latitude,longitude],{ icon: iconObj,//将marker设置为上面引用的图形 }); marker.bindTooltip(item["name"]).openTooltip(); marker.on('click',function(e){ showSchoolBaseInfo(item) }) addSchoolMarkerHash(deviceid,marker); cusSchoolMarkers_x.addLayer(marker); }) mainMap.addLayer(cusSchoolMarkers_x); } function addSchoolMarker_z(){ cusSchoolMarkers_z = L.markerClusterGroup({iconCreateFunction: function(cluster) { return L.divIcon({ html: `
${cluster.getChildCount()}
` }); }}); school_z_arr.forEach(item=>{ let longitude=item["longitude"]; let latitude=item["latitude"]; let deviceid=item["device_id"]; var iconObj=L.icon({ iconUrl:"./pages/cmddispatch/image/wb_school_z.png",//图片路径 iconSize: [24, 24]//图片大小设置 }); let marker=L.marker([latitude,longitude],{ icon: iconObj,//将marker设置为上面引用的图形 }); marker.bindTooltip(item["name"]).openTooltip(); marker.on('click',function(e){ showSchoolBaseInfo(item) }) addSchoolMarkerHash(deviceid,marker); cusSchoolMarkers_z.addLayer(marker); }) mainMap.addLayer(cusSchoolMarkers_z); } function drawSchoolMarker(){ school_y_arr=[]; school_x_arr=[]; school_z_arr=[]; deleteSchoolMarker_y(); deleteSchoolMarker_x(); deleteSchoolMarker_z(); stationInfoTableList.forEach(item=>{ var type=item["type"]; if(type=="幼儿园"){ school_y_arr.push(item); }else if(type=="小学"){ school_x_arr.push(item); }else{ school_z_arr.push(item); } }) addSchoolMarker_y() addSchoolMarker_x() addSchoolMarker_z() $(".school_y_number").html(school_y_arr.length); $(".school_x_number").html(school_x_arr.length); $(".school_z_number").html(school_z_arr.length); } function showSchoolMarkerInfo(obj){ var device_id=obj["device_id"]; if(device_id in schoolMarkerHash){ schoolMarkerHash[device_id].unbindPopup(); schoolMarkerHash[device_id].bindPopup(`
${getSchoolInfoDiv(obj)}
`,{className:"schoolWindowInfo"}).openPopup(); var lnglat=schoolMarkerHash[device_id].getLatLng() mainMap.setView(lnglat, 18); } } export { drawSchoolMarker, addSchoolMarker_y, addSchoolMarker_x, addSchoolMarker_z, showSchoolMarkerInfo, deleteSchoolMarker_y, deleteSchoolMarker_x, deleteSchoolMarker_z, schoolMarkerHash }