From ed2a9d376c3846bb8d6cf838bfff9bd3ae07bc3b Mon Sep 17 00:00:00 2001 From: ZhuDongming <773644075@qq.com> Date: Mon, 12 Aug 2019 15:52:05 +0800 Subject: [PATCH] 修改多点重合下拉时第一个时间位置不变问题 --- src/main/webapp/view/map.jsp | 126 ++++++++++++++++++++++++++++++++++++------ 1 files changed, 108 insertions(+), 18 deletions(-) diff --git a/src/main/webapp/view/map.jsp b/src/main/webapp/view/map.jsp index 8ed4da8..3869532 100644 --- a/src/main/webapp/view/map.jsp +++ b/src/main/webapp/view/map.jsp @@ -278,14 +278,14 @@ <div class="charts_btn"> </div> </div> - <div class="search_box"> + <!-- <div class="search_box"> <button id="searchBtn" type="button">������</button> <input id="searchParam"/> - </div> - <div id="popup_box"> + </div> --> + <!-- <div id="popup_box"> <div id="equ_list" class="listview"> </div> - </div> + </div> --> <div id="mapCanvas"></div> <div id="mapParams" style="display: none;"> ${requestScope.mapParams} @@ -303,10 +303,11 @@ var mapType = getUrlParam("mapType"); var mapOption = {}; if(!!mapType && !!eval(mapType)) { - mapOption["mapType"] = jieval(mapType); + mapOption["mapType"] = eval(mapType); } + var showZoom = getUrlParam("showZoom"); //������������������������������ - moralMap.mapInit(params["regionName"],mapOption); + moralMap.mapInit(params["regionName"],mapOption,showZoom); //������������ var listView =moralMap.initListView({id: "#equ_list",pageSize:12}); window["listView"] = listView; @@ -315,7 +316,7 @@ var params = moralMap['params']; var mpoint = obj.currentTarget.getOption(); - $("#searchParam").val(mpoint['name']); + //$("#searchParam").val(mpoint['name']); var url = 'get-devices-by-mid-oid?mpId=' + mpoint['id'] + "&orgId=" + params['orgId']; listView.load(url); moralMap.showPopupbox("#popup_box"); @@ -356,6 +357,7 @@ var maxBounds = moralMap.getMaxBounds(); var paramMap = {}; paramMap["orgId"]= params['orgId']; + paramMap["regionCode"]= params['regionCode']; // ��������������������� paramMap["Fe"]= maxBounds.northeastLat;//��������������������������� paramMap["Ge"]= maxBounds.northeastLng;//��������������������������� @@ -374,7 +376,7 @@ obj['mouseover'] = function (type) { if(type.target.getData()==null){ //��������������������������������������������������� ������������������ - refreshAllState(); + //refreshAllState(); } } obj['click'] = function(){ @@ -394,7 +396,6 @@ } var equStr = JSON.stringify(equ); if(window["console"]!=undefined){ - console.log(equStr); } if(!!window['external']&&!!window['external']['callWin']){ window['external'].callWin(equStr); @@ -436,41 +437,106 @@ paramMap["Ke"]= bounds.southwestLat;//��������������������������������� paramMap["Le"]= bounds.southwestLng;//��������������������������������� loadLazy("getMonitorpointList",paramMap,addOverMpoints); - startRefreshPage(); + //startRefreshPage(); + showGrid(); }); //��������������������� ���������������,��������� moralMap.addEventListener("tilesloaded", function(type, target) { + showGrid(); }); + + //map��������������� + // TODO ������ + function getBounds() { + var bs = moralMap.getBounds(); //������������������������������������ + // var bssw = bs.getSouthWest(); //���������������������������(������������) + // var bsne = bs.getNorthEast(); //���������������������������(������������) + if(!getBounds.topLeftAnchor){ + getBounds.topLeftAnchor = {}; + getBounds.topLeftAnchor.x0 = bs.southwestLng; + getBounds.topLeftAnchor.y0 = bs.northeastLat; + } + return { 'x1': bs.southwestLng, 'y1': bs.southwestLat, 'x2': bs.northeastLng, 'y2': bs.northeastLat }; + } + /** + * ������������ + */ + // TODO ������ + function showGrid(){ + var isShowGrid = getUrlParam("isShowGrid"); + if(!!isShowGrid){ + $(".tools_box").hide(); + } + // if(!isShowGrid||moralMap.getZoom()<14){ + if(!isShowGrid||moralMap.getZoom()<14){ + return; + } + var XY = getBounds(); + var polygons = []; + console.log(XY); + var X1 = XY.x1; + var Y2 = XY.y2; + var X0 = getBounds.topLeftAnchor.x0; + var Y0 = getBounds.topLeftAnchor.y0; + var width = 0.0063; + var height = 0.0048; + // var multiple = 1000000; + if(!!getBounds.topLeftAnchor) { + X1=X0 + Math.ceil((X1-X0)/width-1)*width; + Y2=Y0 + Math.ceil((Y2-Y0)/height)*height; + } + for (var i = X1; i < XY.x2; i = i + width) { + for (var j = Y2; j > XY.y1; j = j - height) { + //���������������������������������������������������:������������������Point���������������������������,���������������������������,���������������������������,���������������������������������������������������������������������������������������������������������������,������������������������������������������������������������������ + var polygon = new BMap.Polygon([ + new BMap.Point(i, j), //������������������ + new BMap.Point(i, j-height), //������������������ + new BMap.Point(i+width, j-height), //������������������ + new BMap.Point(i+width, j) //������������������ + ], {strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5, fillOpacity:0.1}); + // polygon .addEventListener("click",function clickFunction(){ + // alert("������������������"); + // }); + // moralMap.addOverlay(polygon); + polygons.push(polygon); + } + } + moralMap.addOverlays(polygons); + if(!!showGrid.polygons){ + moralMap.removeOverlays(showGrid.polygons); + } + showGrid.polygons = polygons; + } // ������������������ ������������ moralMap.addEventListener("click", function(type, target) { - moralMap.closePopupbox("#popup_box"); + //moralMap.closePopupbox("#popup_box"); }); //������������������������������������������ moralMap.addEventListener('zoomstart', function(type) {}); //������������������������������������������ moralMap.addEventListener('zoomend', function(type) { var endZoom = this.getZoom(); - if(endZoom>=moralMap.getZooMConfine()){//������������������������ + if(endZoom>=moralMap.getZoomConfine()){//������������������������ loadOverlays("get-devices",addOverEquipments); }else{ loadOverlays("get-monitorpoints",addOverMpoints); } - moralMap.closePopupbox("#popup_box"); + //moralMap.closePopupbox("#popup_box"); }); moralMap.addEventListener('moveend', function(type) { var endZoom = this.getZoom(); - if(endZoom>=moralMap.getZooMConfine()){//������������������������ + if(endZoom>=moralMap.getZoomConfine()){//������������������������ loadOverlays("get-devices",addOverEquipments); }else{ loadOverlays("get-monitorpoints",addOverMpoints); } - moralMap.closePopupbox("#popup_box"); + //moralMap.closePopupbox("#popup_box"); }); //��������������������� $("#searchBtn").click( function(e) { var param = encodeURI($("#searchParam").val()); - moralMap.showPopupbox("#popup_box"); + //moralMap.showPopupbox("#popup_box"); var url = 'get-devices-for-popup?name=' + param + "&orgId=" + params['orgId']; listView.load(url); } @@ -517,12 +583,12 @@ //������������ function refreshAllState() { var parma={}; - if(moralMap.isPopupBoxShow("#popup_box")) { + /* if(moralMap.isPopupBoxShow("#popup_box")) { var popupEquMacs = moralMap.getPopupEquMacs(); if(popupEquMacs!=null&&popupEquMacs.length>0){ parma["popupEquMacs"] = popupEquMacs; } - } + } */ //������������ var oldMarkerList = moralMap.getHorizonMarkers(true); var markerKeys = []; @@ -577,6 +643,18 @@ } } } + + var equ = { + methodName : 'refreshState', + markers : markers, + layer : layer + } + var equStr = JSON.stringify(equ); + if(window["console"]!=undefined){ + } + if(!!window['external']&&!!window['external']['callWin']){ + window['external'].callWin(equStr); + } } if(resultMap["popupEquStates"]!=null){ listView.refreshState(resultMap["popupEquStates"]); @@ -586,4 +664,16 @@ }); } } + + function callJS(jsonData){ + var jsonData = JSON.parse(jsonData); + var methodName = jsonData.methodName; + if("JumpBaiduMap" == methodName){ + moralMap.callJS(jsonData); + } else if ("RefreshState" == methodName) { + //$("#searchParam").val(JSON.stringify(jsonData)); + var states = jsonData.states; + moralMap.refreshState(states); + } + } </script> -- Gitblit v1.8.0