From aa890874f3f6ee7e88134493dc29705bc6fd89a3 Mon Sep 17 00:00:00 2001 From: 81041 <81041@192.168.10.25> Date: 星期一, 22 十月 2018 16:24:27 +0800 Subject: [PATCH] 修改 --- gx_tieta/WebRoot/index.jsp | 373 +++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 321 insertions(+), 52 deletions(-) diff --git a/gx_tieta/WebRoot/index.jsp b/gx_tieta/WebRoot/index.jsp index 53f5b4b..7908d2b 100644 --- a/gx_tieta/WebRoot/index.jsp +++ b/gx_tieta/WebRoot/index.jsp @@ -75,6 +75,12 @@ .ui-resizable-s, .ui-resizable-se { display: none !important; } + + .ui-autocomplete { + height: 200px; + overflow-y: auto; + overflow-x: hidden; + } </style> <script type="text/javascript" src="js/jquery-1.8.3.js"></script> @@ -597,7 +603,6 @@ flushFourPie(); //鏇存柊鍥涚楗肩姸鍥� }); - // 璁剧疆鍙抽敭鑿滃崟 var menu = new BMap.ContextMenu(); var txtMenuItem = [ @@ -632,17 +637,7 @@ enparams:[e] }); } - }, - /* { - text: '鏈烘埧瀹氫綅', - callback: function(e) { - panel.setPanelLayout(); - panel.showPanel(); - $('#map .panel-mask').bind('click', function() { - panel.hidePanel(); - }); - } - } */ + } ]; //console.info(getPermit('taskchange_edit_permit', permits)+"*******"); if(getPermit('batt_map_edit_permit', permits)) { @@ -1344,15 +1339,6 @@ }); }); - // 鐐瑰嚮鍦板浘鐨勬悳绱㈡寜閽畾浣嶅湴鍧� - $(function() { - $('#map').on('click', '.search .search-btn', function() { - var posTxt = $('#map .search .pos-txt').val(); - addrAnalyze(posTxt); - }); - }); - - $(window).resize(function() { getMapHt(); }); @@ -1594,14 +1580,20 @@ function createMapDot(map, dotList) { // 娓呯┖瑕嗙洊鐗╁拰瀵瑰簲鐨刴k鐐� mkList = []; + // 閬嶅巻鏌ヨ鍐呭鐢熸垚瀵瑰簲鐨勫浘鏍� for(var i = 0; i < dotList.length; i++) { - var dotIcon = new BMap.Icon(getMapStateImg(mapImages, dotList[0].msg), new BMap.Size(36, 30)); // 璁剧疆鍥剧墖 + var dotIcon = new BMap.Icon(getMapStateImg(mapImages, dotList[i].msg), new BMap.Size(36, 30)); // 璁剧疆鍥剧墖 var pt = new BMap.Point(dotList[i].lng, dotList[i].lat); var mk = new BMap.Marker(pt, {icon: dotIcon}); // 瀹氫箟marker鐐� - addMenu(mk, mapDel); + + // 鍒犻櫎鎸囧畾鐨勭偣(璇ョ偣浼氬湪鏈嚱鏁板悗闈㈤噸鏂板垱寤�) deletePoint(map, dotList[i].title); + + // 缁欑偣鍙抽敭鑿滃崟娣诲姞鍒犻櫎鎸夐挳 + addMenu(mk, mapDel); + // 鍚憁k鐐规坊鍔爈abel var home_name = new BMap.Label(dotList[i].title, {offset:new BMap.Size(20,-10)}); home_name.setStyle({display: 'none', padding: '4px 2px'}); @@ -1617,15 +1609,14 @@ mk.addEventListener('click', function(e) { var target = e.target; - showMapPanel(target, dotList); + //showMapPanel(target, dotList); + searchPanelInfo(target); }); mkList.push(mk); // 鍚戝湴鍥炬坊鍔犺鐩栫墿 map.addOverlay(mk); } } - - // // 鍒犻櫎鍦板浘涓婄殑鎸囧畾鐐� function deletePoint(map, msg){ @@ -1747,6 +1738,7 @@ function showMapPanel(target, warnList) { var point = target.point; + console.log(target.getLabel()); var searchInforWin = null; for(var i = 0; i < warnList.length; i++) { if(warnList[i].lng == point.lng && warnList[i].lat == point.lat) { @@ -1776,7 +1768,6 @@ function showMapPanelByPoint(point, dataList) { var searchInforWin = null; var opts = { - //title : warnList[i].title+'<a href="javascript:loadToHomeInfo();" style="margin-left: 1em;text-decoration:none">璇︽儏>></a>', //鏍囬 title : dataList.title+'<a href="javascript:loadToHomeInfo();" style="margin-left: 1em;text-decoration:none;cursor:not-allowed">璇︽儏>></a>', //鏍囬鏈紑鍚� width : '290', //瀹藉害 height : 140, //楂樺害 @@ -1966,12 +1957,144 @@ } } - searchStation(); - var allStation; + // 璁剧疆椤甸潰涓殑鍙鍖哄煙鍥炬爣 + ;(function($, window, document, gl, undefined) { + // 璁剧疆鍛藉悕绌洪棿 + gl.namespace('BMap'); + // 鏍规嵁鍙鑼冨洿鏄剧ず鍧愭爣鐐� + var dots = []; + var currMarkers = {}; + // 鏌ヨ褰撳墠鑼冨洿鍐呭鐨勫浘鏍� + function queryInRect(map, callback) { + var cp = map.getBounds(); // 杩斿洖map鍙鍖哄煙锛屼互鍦扮悊鍧愭爣琛ㄧず + var sw = cp.getSouthWest(); // 杩斿洖鐭╁舰鍖哄煙鐨勮タ鍗楄 + var ne = cp.getNorthEast(); // 杩斿洖鐭╁舰鍖哄煙鐨勪笢鍖楄 + //var zoom = map.getZoom(); //褰撳墠缂╂斁绾у埆 + //console.log(dots); + var mapDots = getDotsList(sw, ne); + callback(map, mapDots); + } + + // 鑾峰彇dots鐨勯泦鍚� + function getDotsList(sw, ne) { + var rs = []; + swlng=sw.lng, + swlat=sw.lat, + nelng=ne.lng, + nelat=ne.lat; + + var maxLng = sw.lng>ne.lng?sw.lng:ne.lng; + var minLng = sw.lng<ne.lng?sw.lng:ne.lng; + + var maxLat = sw.lat>ne.lat?sw.lat:ne.lat; + var minLat = sw.lat<ne.lat?sw.lat:ne.lat; + + for(var i=0; i<dots.length; i++) { + var dot = dots[i]; + var lat = dot.lat; + var lng = dot.lng; + var sId = dot.sId; + var isExist = checkMarker(sId); + + // 鏈娣诲姞杩� + if(!isExist) { + // 鍒ゆ柇缁忕含搴︽槸鍚﹀瓨鍦ㄨ鍖哄煙 + if(lng<maxLng && lng>minLng && lat<maxLat && lat>minLat) { + currMarkers['markers'+sId] = sId; + rs.push(dot); + } + } + } + return rs; + } + + + // 妫�娴嬪綋鍓嶇偣鏄惁宸茬粡琚坊鍔犺繃 + function checkMarker(id) { + var flag = false; + // 閬嶅巻宸茬粡娣诲姞鐨勭偣杩斿洖鏄惁宸茬粡琚坊鍔犺繃 + Object.keys(currMarkers).forEach(function(key) { + if(currMarkers[key] == id) { + flag = true; + } + }); + + return flag; + } + + // 璁剧疆dots闆嗗悎鐨勫�� + function setDots(data) { + dots = data; + } + + // 灏嗗彉閲忕粦瀹氬埌鍛藉悕绌洪棿涓� + gl.BMap.setDots = setDots; + + // 鏇存柊dots闆嗗悎鐨勬暟鎹� + function updateDots(data) { + for(var i=0; i<dots.length; i++) { + var _dots = dots[i]; + if(_dots.sId == data.sId) { + _dots.msg = data.msg; + } + } + } + + // 灏嗗彉閲忕粦瀹氬埌鍛藉悕绌洪棿涓� + gl.BMap.updateDots = updateDots; + + // 灏嗗嚱鏁扮粦瀹氬埌鍛藉悕绌洪棿涓� + gl.BMap.queryInRect = queryInRect; + })(jQuery, window, document, GLOBAL); + + + // 鍦板浘鏈烘埧鎼滅储妯″潡 + ;(function($, window, document, gl, undefined) { + // 璁剧疆鍛藉悕绌洪棿BMap.Search妯″潡 + gl.namespace('BMap.Search'); + + var homeInfor = []; + + // 璁剧疆homeInfor鐨勫�� + function setHomeInfor(data) { + homeInfor = data; + } + // 灏嗗嚱鏁扮粦瀹氬埌鍛藉悕绌洪棿涓� + gl.BMap.Search.setHomeInfor = setHomeInfor; + + // 鏍规嵁homeInfor鐨勫�艰繑鍥瀐ome鍒楄〃 + function getHomeList() { + var rs = []; + // 閬嶅巻homeInfor鐨勫�� + for(var i=0; i<homeInfor.length; i++) { + rs.push(homeInfor[i].title); + } + return rs; + } + // 灏嗗嚱鏁扮粦瀹氬埌鍛藉悕绌洪棿涓� + gl.BMap.Search.getHomeList = getHomeList; + })(jQuery, window, document, GLOBAL); + + // 鏌ヨ骞惰缃満鎴跨殑鍥炬爣 + $(function () { + searchStation(true); + }); + + + var allStation = []; + var mapPages = { + pageSize:100, // 姣忛〉鐨勮鏁� + pageCurr:1, // 褰撳墠椤电爜鏁� + pageAll:1, // 鏁扮洰 + pageNum: 0, + pageNew: true + }; //鏌ヨ鏈烘埧 - function searchStation(){ + function searchStation(setRect){ var temp = createSearchParam(); var json = JSON.stringify(temp); + var bmap = GLOBAL.BMap; // BMap鐨勫懡鍚嶇┖闂� + var bmap_s = bmap.Search; // Search鐨勫懡鍚嶇┖闂� commonDot = new Array(); warnDotList = new Array(); dischargeDotList = []; @@ -1980,39 +2103,178 @@ type: "post", //url: "BattMap_informationAction!searchAll", url: "BattMap_informationAction!searchUserManageStation", - async:true, + async: true, dataType:'text', data:"json="+json, success: function(data){ data = eval('('+data+')'); - var list = eval('('+data.result+')'); - console.log(list.length); + // 鑾峰彇缁撴灉闆� + var rs = JSON.parse(data.result); + var list = rs.data; + // console.log(list); allStation = new Array(); if(list!=undefined && list.length>0){ - for(var i=0;i<list.length;i++){ - var tmp = { - binformation:list[i].data, - alarm_num:list[i].code, //鍛婅鏁扮洰 - low_num:list[i].sum, //钀藉悗鏁扮洰 - delay_num:list[i].newsum, //寤舵椂鏁扮洰 - msg: list[i].msg - }; - allStation.push(analyzeData(tmp)); - } - //console.info(allStation); - createMapDot(map, allStation); + // 璁剧疆鍒嗛〉淇℃伅 + mapPages.pageAll = list.length; + setMapPages(); - //setTimeout(searchStation, 4000); + // 閬嶅巻鏌ヨ缁撴灉 + for(var i=0;i<list.length;i++){ + var _list = list[i]; + allStation.push(formatAllStation(_list)); + } + + // 鏄剧ず鍖哄煙鐨勫浘鏍� + bmap.setDots(allStation); + bmap.queryInRect(map, createMapDot); + // 鏄惁绗竴娆℃墽琛� + if(setRect) { + map.addEventListener("moveend", bmap.queryInRect.bind({},map, createMapDot)); // 鎷栧姩 + map.addEventListener("zoomend", bmap.queryInRect.bind({},map, createMapDot)); // 缂╂斁 + updateStation(); + } } } }); } + // 鏍煎紡鍖栨煡璇㈢粨鏋� + function formatAllStation(list) { + var obj = new Object(); + // 鏋勯�犵粨鏋滈泦 + obj.lng = list.longitude; + obj.lat = list.latitude; + obj.title = list.StationName; + obj.sId = list.StationId; + obj.fbsId = list.FBSDeviceId; + obj.addr = list.Address; + obj.msg = ""; + obj.num = list.num; + return obj; + } + + // 璁剧疆鍒嗛〉鐨勪俊鎭� + function setMapPages() { + var pageNum = Math.ceil(mapPages.pageAll/mapPages.pageSize); + mapPages.pageNum = pageNum; + mapPages.pageNew= true; + } + + // 杞鏇存柊鍦板浘鐨勭偣鏌ヨ + function updateStation() { + var bmap = GLOBAL.BMap; // BMap鐨勫懡鍚嶇┖闂� + var updateStationData = []; + $.ajax({ + type: "post", + url: "BattMap_informationAction!searchUserManageStation2", + async: true, + dataType:'json', + data: "json="+JSON.stringify(mapPages), + success: function(result) { + var data = JSON.parse(result.result); + for(var i=0; i<data.length; i++) { + var _data = data[i]; + var _list = formatUpdateStation(_data); + updateStationData.push(_list); + //_list.msg = 'item-nuclear_cap'; + // 鍒ゆ柇鏄惁鏇存柊 + if(mapPages.pageNew) { + bmap.updateDots(_list); + } + } + + createMapDot(map, updateStationData); + + // 鏇存柊鍒嗛〉淇℃伅 + mapPages.pageCurr++; + if(mapPages.pageCurr>mapPages.pageNum) { + mapPages.pageCurr=1; + mapPages.pageNew=false; + } + + setTimeout(updateStation, 4000); + } + }); + } + + // 鏍煎紡鍖栨煡璇㈢粨鏋� + function formatUpdateStation(list) { + var obj = {}; + var data = list.data; + // 鏋勯�犵粨鏋滈泦 + obj.lng = data.longitude; + obj.lat = data.latitude; + obj.title = data.StationName; + obj.sId = data.StationId; + obj.fbsId = data.FBSDeviceId; + obj.addr = data.Address; + obj.msg = list.msg; + obj.num = list.num; + return obj; + } + + // 鏌ヨ鏈烘埧闈㈡澘淇℃伅 + function searchPanelInfo(data) { + var point = data.point; + var stationInfo = getStaionByPoint(point); + if(!stationInfo) { + alert('闈㈡澘淇℃伅鏌ヨ澶辫触锛�'); + return; + } + + var temp = { + StationId: stationInfo.sId + }; + // 鏌ヨ闈㈡澘淇℃伅 + $.ajax({ + type: 'post', + async: true, + url: 'BattMap_informationAction!searchUserManageStation3', + data: 'json='+JSON.stringify(temp), + dataType: 'json', + success: function(result) { + var rs = JSON.parse(result.result); + if(rs.length != 0) { + var data = rs[0]; + console.info(data); + var content = '<div style="padding:6px;"><span>钃勭數姹犵粍鍛婅鏁扮洰锛�</span>'+data.code+'<a style="margin-left: 14px" href="javascript:loadToWarnPage();">璇︽儏>></a></div>'+ + '<div style="padding:6px;"><span>钃勭數姹犵粍钀藉悗鏁扮洰锛�</span>'+data.sum+'<a style="margin-left: 14px" href="javascript:loadToBehindPage();">璇︽儏>></a></div>'+ + '<div style="padding:6px;"><span>钃勭數姹犵粍寤舵椂鏁扮洰锛�</span>'+data.newsum+'<a style="margin-left: 14px" href="javascript:loadToDischargeDelay();">璇︽儏>></a></div>'+ + '<div style="padding:6px"><a href="javascript:loadToRealTime();">瀹炴椂鏁版嵁</a><a style="margin-left: 20px" href="javascript:loadToOldTime();">鍘嗗彶鏁版嵁</a></div>'+ + '<div style="padding:6px;"><span>鍦板潃锛�</span>'+data.data.Address+'</div>'+ + '<input type="hidden" class="ipt-hide" value="">'+ + '<input type="hidden" class="ipt-hide" value="'+data.data.StationId+'">'; + + var list = { + title: data.data.StationName, + content: content + }; + + showMapPanelByPoint(point, list); + } + + } + }); + } + + + // 鏍规嵁缁忕含搴﹁幏鍙栨満鎴跨殑淇℃伅 + function getStaionByPoint(point) { + var stationInfo = false; + // 閬嶅巻鎵�鏈夋満鎴� + for(var i=0; i<allStation.length; i++) { + var info = allStation[i]; + if(info.lng == point.lng && info.lat == point.lat) { + stationInfo = info; + } + } + return stationInfo; + } function setAllStation(obj,allstation){ //console.info(allstation); var flag = false; var index = 0; - for(var i = 0;i < allstation.length;i++){ + for(var i = 0;i < allStation.length;i++){ //console.info(obj.binformation.num + "==" + allstation[i].binformation.num); if(obj.binformation.num == allstation[i].binformation.num){ flag = true; @@ -2262,11 +2524,10 @@ text: '鍒犻櫎', callback: function(e) { //console.info(allStation); - console.info(mk); + console.info(allStation); var temp = getStationMap(allStation, mk.point); - if(confirm("纭浠庡湴鍥句笂鍒犻櫎'"+temp.StationName+"'鐨勪綅缃俊鎭悧锛�")){ + if(confirm("纭浠庡湴鍥句笂鍒犻櫎'"+temp.title+"'鐨勪綅缃俊鎭悧锛�")){ if(temp != undefined){ - //console.info(temp); var json = JSON.stringify(temp); $.ajax({ type: "post", @@ -2308,8 +2569,8 @@ function getStationMap(list,localposi){ if(list != undefined){ for(var i = 0 ; i < list.length ; i++){ - if(list[i].binformation.latitude == localposi.lat && list[i].binformation.longitude == localposi.lng){ - return list[i].binformation; + if(list[i].lat == localposi.lat && list[i].lng == localposi.lng){ + return list[i]; } } } @@ -3039,5 +3300,13 @@ img.attr('src', navImg); } } + + // 鐐瑰嚮鍦板浘鐨勬悳绱㈡寜閽畾浣嶅湴鍧� + $(function() { + $('#map').on('click', '.search .search-btn', function() { + var posTxt = $('#map .search .pos-txt').val(); + addrAnalyze(posTxt); + }); + }); </script> </html> -- Gitblit v1.9.1