From 728b1eb711d9405f8cddfae0cdcbf479ae3c3190 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Tue, 14 Aug 2018 09:04:13 +0800 Subject: [PATCH] 百度地图网格固定 --- src/main/webapp/view/map.jsp | 33 ++++++++++++++++++++++++--------- 1 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/main/webapp/view/map.jsp b/src/main/webapp/view/map.jsp index aaf60a6..6ccc96b 100644 --- a/src/main/webapp/view/map.jsp +++ b/src/main/webapp/view/map.jsp @@ -391,11 +391,10 @@ longitude: _obj['longitude'], latitude: _obj['latitude'], monitorPointId: _obj['monitorPointId'], - version:_obj['deviceVersion']['version'] + version:_obj['deviceVersion']['vers\t\t\t\t\t\t\t\t\t\tconsole.log(equStr);\nion'] } var equStr = JSON.stringify(equ); if(window["console"]!=undefined){ - console.log(equStr); } if(!!window['external']&&!!window['external']['callWin']){ window['external'].callWin(equStr); @@ -447,10 +446,15 @@ //map��������������� // TODO ������ - function bs() { + 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 }; } /** @@ -466,17 +470,28 @@ if(!isShowGrid||moralMap.getZoom()<14){ return; } - var XY = bs(); + var XY = getBounds(); var polygons = []; console.log(XY); - for (var i = XY.x1; i < XY.x2; i = i + 0.0063) { - for (var j = XY.y2; j > XY.y1; j = j - 0.0048) { + 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-0.0048), //������������������ - new BMap.Point(i+0.0063, j-0.0048), //������������������ - new BMap.Point(i+0.0063, 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("������������������"); -- Gitblit v1.8.0