From 6fe80eb8fad34c8d4b0183b120b6fa975ba5966c Mon Sep 17 00:00:00 2001 From: chenglu Date: Sat, 20 May 2023 19:23:20 +0800 Subject: [PATCH 1/9] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81circle=E5=9B=BE?= =?UTF-8?q?=E5=BD=A2=E7=BB=98=E5=88=B6=E5=AE=8C=E6=88=90=E5=90=8E=E7=BC=96?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrawingManager/src/DrawingManager.js | 43 ++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/DrawingManager/src/DrawingManager.js b/DrawingManager/src/DrawingManager.js index da39502..b482f48 100644 --- a/DrawingManager/src/DrawingManager.js +++ b/DrawingManager/src/DrawingManager.js @@ -825,6 +825,20 @@ var BMAP_DRAWING_MARKER = "marker", // 鼠标画点模式 this.overlays.length = 0; }; + /** + * 使overlay重新进入edit模式 + * overlay可从overlaycomplete事件中获取 + * @example drawingManager.setOverlayEdit('circle',overlay) + */ + DrawingManager.prototype.setOverlayEdit = function(drawingMode, overlay) { + // TODO:适配各种类型的编辑模式 + if( drawingMode === 'circle'){ + this.clearOverlay(overlay) + this._drawingType = 'circle' + this._open(true, overlay) + } + }; + /** * 鼠标绘制完成后,派发总事件的接口 * @name DrawingManager#overlaycomplete @@ -1021,9 +1035,11 @@ var BMAP_DRAWING_MARKER = "marker", // 鼠标画点模式 /** * 开启地图的绘制状态 + * @param {Boolean} isEdit 是否为编辑状态打开 + * @param {BMapGL.Overlay} overlay 要编辑的覆盖物 * @return {Boolean},开启绘制状态成功,返回true;否则返回false。 */ - DrawingManager.prototype._open = function () { + DrawingManager.prototype._open = function (isEdit, overlay) { this._isOpen = true; @@ -1033,15 +1049,17 @@ var BMAP_DRAWING_MARKER = "marker", // 鼠标画点模式 } this._map.addOverlay(this._mask); - this._setDrawingMode(this._drawingType); + this._setDrawingMode(this._drawingType, isEdit, overlay); }; /** * 设置当前的绘制模式 * @param {DrawingType} + * @param {Boolean} isEdit 是否为编辑模式 + * @param {BMapGL.Overlay} overlay 要编辑的覆盖物 */ - DrawingManager.prototype._setDrawingMode = function (drawingType) { + DrawingManager.prototype._setDrawingMode = function (drawingType, isEdit, overlay) { this._drawingType = drawingType; @@ -1058,7 +1076,7 @@ var BMAP_DRAWING_MARKER = "marker", // 鼠标画点模式 this._bindMarker(); break; case BMAP_DRAWING_CIRCLE: - this._bindCircle(); + this._bindCircle(isEdit, overlay); break; case BMAP_DRAWING_POLYLINE: case BMAP_DRAWING_POLYGON: @@ -1148,9 +1166,12 @@ var BMAP_DRAWING_MARKER = "marker", // 鼠标画点模式 /** * 绑定鼠标画圆的事件 + * 默认为开启鼠标进行circle绘制,传入edit时进入编辑模式,编辑模式下需要传递初始值 + * @param {Boolean | undefined} isEdit 是否为编辑模式 + * @param {BMapGL.Overlay | undefined} initialOverlay overlay初始值 */ var tip_label = null; - DrawingManager.prototype._bindCircle = function () { + DrawingManager.prototype._bindCircle = function (isEdit, initialOverlay) { var me = this, map = this._map, @@ -1354,6 +1375,18 @@ var BMAP_DRAWING_MARKER = "marker", // 鼠标画点模式 mask.addEventListener('mousedown', mousedownAction); mask.addEventListener('mousemove', mousemoveAction); + + /** + * 如果是编辑模式,设置初始值 + */ + if(isEdit){ + var initialCenterPoint = initialOverlay.getCenter() + var initialEndPoint = new BMapGL.Point(initialOverlay.getBounds().getNorthEast().lng, initialCenterPoint.lat); + + startAction({ point : initialCenterPoint}) + moveAction({ point: initialEndPoint }) + endAction({}) + } }; /** From 0080a9e76322d281b62a4174c6059e9ad04ad2fb Mon Sep 17 00:00:00 2001 From: chenglu Date: Sat, 20 May 2023 19:36:32 +0800 Subject: [PATCH 2/9] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81rectangle?= =?UTF-8?q?=E5=9B=BE=E5=BD=A2=E7=BB=98=E5=88=B6=E5=AE=8C=E6=88=90=E5=90=8E?= =?UTF-8?q?=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrawingManager/src/DrawingManager.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/DrawingManager/src/DrawingManager.js b/DrawingManager/src/DrawingManager.js index b482f48..f43d1b3 100644 --- a/DrawingManager/src/DrawingManager.js +++ b/DrawingManager/src/DrawingManager.js @@ -836,6 +836,10 @@ var BMAP_DRAWING_MARKER = "marker", // 鼠标画点模式 this.clearOverlay(overlay) this._drawingType = 'circle' this._open(true, overlay) + }else if( drawingMode === 'rectangle'){ + this.clearOverlay(overlay) + this._drawingType = 'rectangle' + this._open(true, overlay) } }; @@ -1083,7 +1087,7 @@ var BMAP_DRAWING_MARKER = "marker", // 鼠标画点模式 this._bindPolylineOrPolygon(); break; case BMAP_DRAWING_RECTANGLE: - this._bindRectangle(); + this._bindRectangle(isEdit, overlay); break; } } @@ -1595,9 +1599,12 @@ var BMAP_DRAWING_MARKER = "marker", // 鼠标画点模式 /** * 绑定鼠标画矩形的事件 + * 默认为开启鼠标进行circle绘制,传入edit时进入编辑模式,编辑模式下需要传递初始值 + * @param {Boolean | undefined} isEdit 是否为编辑模式 + * @param {BMapGL.Overlay | undefined} initialOverlay overlay初始值 */ - DrawingManager.prototype._bindRectangle = function () { + DrawingManager.prototype._bindRectangle = function (isEdit, initialOverlay) { var me = this, map = this._map, @@ -1799,6 +1806,19 @@ var BMAP_DRAWING_MARKER = "marker", // 鼠标画点模式 mask.addEventListener('mousedown', startAction); mask.addEventListener('mousemove', mousemoveAction); + + /** + * 如果是编辑模式,设置初始值 + */ + if(isEdit){ + var initialBounds = initialOverlay.getBounds() + var southWestPoint = initialBounds.getSouthWest() + var northEastPoint = initialBounds.getNorthEast() + + startAction({ point : southWestPoint}) + moveAction({ point: northEastPoint }) + endAction({ point: northEastPoint }) + } }; /** From ec731ee0b7f27ad41ff1701de7fae35e7d290c0b Mon Sep 17 00:00:00 2001 From: chenglu Date: Sat, 20 May 2023 19:47:59 +0800 Subject: [PATCH 3/9] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81polygon=E7=BB=98?= =?UTF-8?q?=E5=88=B6=E5=AE=8C=E6=88=90=E5=90=8E=E8=BF=9B=E8=A1=8C=E7=BC=96?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrawingManager/src/DrawingManager.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/DrawingManager/src/DrawingManager.js b/DrawingManager/src/DrawingManager.js index f43d1b3..b3407f9 100644 --- a/DrawingManager/src/DrawingManager.js +++ b/DrawingManager/src/DrawingManager.js @@ -840,6 +840,10 @@ var BMAP_DRAWING_MARKER = "marker", // 鼠标画点模式 this.clearOverlay(overlay) this._drawingType = 'rectangle' this._open(true, overlay) + }else if( drawingMode === 'polygon'){ + this.clearOverlay(overlay) + this._drawingType = 'polygon' + this._open(true, overlay) } }; @@ -1084,7 +1088,7 @@ var BMAP_DRAWING_MARKER = "marker", // 鼠标画点模式 break; case BMAP_DRAWING_POLYLINE: case BMAP_DRAWING_POLYGON: - this._bindPolylineOrPolygon(); + this._bindPolylineOrPolygon(isEdit, overlay); break; case BMAP_DRAWING_RECTANGLE: this._bindRectangle(isEdit, overlay); @@ -1395,8 +1399,11 @@ var BMAP_DRAWING_MARKER = "marker", // 鼠标画点模式 /** * 画线和画多边形相似性比较大,公用一个方法 + * 默认为开启鼠标进行polyline绘制,传入edit时进入编辑模式,编辑模式下需要传递初始值 + * @param {Boolean | undefined} isEdit 是否为编辑模式 + * @param {BMapGL.Overlay | undefined} initialOverlay overlay初始值 */ - DrawingManager.prototype._bindPolylineOrPolygon = function () { + DrawingManager.prototype._bindPolylineOrPolygon = function (isEdit, initialOverlay) { var me = this, map = this._map, @@ -1595,6 +1602,19 @@ var BMAP_DRAWING_MARKER = "marker", // 鼠标画点模式 baidu.stopBubble(e); }); + + /** + * 如果是编辑模式,设置初始值 + */ + if(isEdit){ + /** @type {Array} */ + var initialStartPaths = initialOverlay.getPath(); + initialStartPaths.forEach(function (point) { + startAction({ point }) + }) + + dblclickAction({point: initialStartPaths[initialStartPaths.length - 1]}) + } }; /** From 339a8019045ce84a55af87fadd60345cfd52aa93 Mon Sep 17 00:00:00 2001 From: chenglu Date: Sat, 20 May 2023 19:50:05 +0800 Subject: [PATCH 4/9] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81polyline=E7=BB=98?= =?UTF-8?q?=E5=88=B6=E5=AE=8C=E6=88=90=E5=90=8E=E8=BF=9B=E8=A1=8C=E7=BC=96?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrawingManager/src/DrawingManager.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/DrawingManager/src/DrawingManager.js b/DrawingManager/src/DrawingManager.js index b3407f9..4a2b587 100644 --- a/DrawingManager/src/DrawingManager.js +++ b/DrawingManager/src/DrawingManager.js @@ -844,6 +844,10 @@ var BMAP_DRAWING_MARKER = "marker", // 鼠标画点模式 this.clearOverlay(overlay) this._drawingType = 'polygon' this._open(true, overlay) + }else if( drawingMode === 'polyline'){ + this.clearOverlay(overlay) + this._drawingType = 'polyline' + this._open(true, overlay) } }; From e9a2b4450dcdd98a04dec8206d39fdb4eed33dd0 Mon Sep 17 00:00:00 2001 From: chenglu Date: Sat, 20 May 2023 19:53:15 +0800 Subject: [PATCH 5/9] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrawingManager/src/DrawingManager.js | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/DrawingManager/src/DrawingManager.js b/DrawingManager/src/DrawingManager.js index 4a2b587..8878cf8 100644 --- a/DrawingManager/src/DrawingManager.js +++ b/DrawingManager/src/DrawingManager.js @@ -831,23 +831,12 @@ var BMAP_DRAWING_MARKER = "marker", // 鼠标画点模式 * @example drawingManager.setOverlayEdit('circle',overlay) */ DrawingManager.prototype.setOverlayEdit = function(drawingMode, overlay) { - // TODO:适配各种类型的编辑模式 - if( drawingMode === 'circle'){ + if(['circle','rectangle','polygon','polyline'].includes(drawingMode)){ this.clearOverlay(overlay) - this._drawingType = 'circle' - this._open(true, overlay) - }else if( drawingMode === 'rectangle'){ - this.clearOverlay(overlay) - this._drawingType = 'rectangle' - this._open(true, overlay) - }else if( drawingMode === 'polygon'){ - this.clearOverlay(overlay) - this._drawingType = 'polygon' - this._open(true, overlay) - }else if( drawingMode === 'polyline'){ - this.clearOverlay(overlay) - this._drawingType = 'polyline' + this._drawingType = drawingMode this._open(true, overlay) + }else{ + console.error('暂不支持的编辑类型',drawingMode) } }; From 566f601682b11235c610faaa35c4d230bf181796 Mon Sep 17 00:00:00 2001 From: chenglu Date: Sat, 20 May 2023 20:01:29 +0800 Subject: [PATCH 6/9] =?UTF-8?q?fix:=20polyline=E8=BF=9B=E5=85=A5=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E7=8A=B6=E6=80=81=E6=97=B6=E4=B8=A2=E5=A4=B1=E6=9C=80?= =?UTF-8?q?=E5=90=8E=E4=B8=80=E4=B8=AA=E7=82=B9=E4=BD=8D=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrawingManager/src/DrawingManager.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/DrawingManager/src/DrawingManager.js b/DrawingManager/src/DrawingManager.js index 8878cf8..959977d 100644 --- a/DrawingManager/src/DrawingManager.js +++ b/DrawingManager/src/DrawingManager.js @@ -1602,11 +1602,16 @@ var BMAP_DRAWING_MARKER = "marker", // 鼠标画点模式 if(isEdit){ /** @type {Array} */ var initialStartPaths = initialOverlay.getPath(); + var lastPoint = initialStartPaths[initialStartPaths.length - 1]; initialStartPaths.forEach(function (point) { startAction({ point }) }) - dblclickAction({point: initialStartPaths[initialStartPaths.length - 1]}) + if(me._drawingType === 'polyline'){ + startAction({ point:lastPoint }) + } + + dblclickAction({point: lastPoint}) } }; From b02bebba2c40561e798b7b67824706cd3bef1973 Mon Sep 17 00:00:00 2001 From: chenglu Date: Sat, 20 May 2023 23:29:42 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E2=9C=A8=20feat:=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=8E=8B=E7=BC=A9=E5=90=8E=E7=9A=84min.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrawingManager/src/DrawingManager.js | 7 ++++--- DrawingManager/src/DrawingManager.min.js | 14 +++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/DrawingManager/src/DrawingManager.js b/DrawingManager/src/DrawingManager.js index 959977d..997d4cd 100644 --- a/DrawingManager/src/DrawingManager.js +++ b/DrawingManager/src/DrawingManager.js @@ -1603,9 +1603,10 @@ var BMAP_DRAWING_MARKER = "marker", // 鼠标画点模式 /** @type {Array} */ var initialStartPaths = initialOverlay.getPath(); var lastPoint = initialStartPaths[initialStartPaths.length - 1]; - initialStartPaths.forEach(function (point) { - startAction({ point }) - }) + + for(var i=0; i松开完成绘制",{position:K.point,offset:new BMapGL.Size(10,10)});b.setStyle(H.labelOptions);G.addOverlay(b)};var C=function(N){var O=G.getViewport(s.getBounds());O.zoom-=1;G.setViewport(O);G.removeOverlay(b);var M=new BMapGL.Point(s.getBounds().getNorthEast().lng,A.lat);D.hide();q=new BMapGL.Marker(M);q.setIcon(B);q.enableDragging();x=new BMapGL.Polyline([A,M],y);var P=new BMapGL.Point((s.getBounds().getNorthEast().lng+A.lng)/2,A.lat);o=new l("circle",P,r,s,H);J=J.concat([q,x,o]);var K=null;if(H.limit){K=H.limit.area}var L={limit:K,type:"circle",point:M,overlay:s,overlays:J};u=new c(L,H);G.addOverlay(q);G.addOverlay(x);G.addOverlay(o);G.addOverlay(u);H._skipEditing();o.addEventListener("radiuschange",function(V){var Q=V.radius;s.setRadius(Q);var U=i(A,Q,"east");var R=new BMapGL.Point(U.lng,A.lat);var T=U.lng>A.lng?(s.getBounds().getNorthEast().lng+A.lng)/2:(s.getBounds().getSouthWest().lng+A.lng)/2; -var S=new BMapGL.Point(T,A.lat);q.setPosition(R);o.setInfo(S,Q);u.setPosition(R,true);u.updateWindow();x.setPath([A,R])});q.addEventListener("dragging",function(U){var R=new BMapGL.Point(U.latLng.lng,A.lat);var T=U.latLng.lng>A.lng?(s.getBounds().getNorthEast().lng+A.lng)/2:(s.getBounds().getSouthWest().lng+A.lng)/2;var Q=U.latLng.lng>A.lng?true:false;var S=new BMapGL.Point(T,A.lat);U.target.setPosition(R);o.setInfo(S,H._map.getDistance(A,U.latLng).toFixed(0));u.setPosition(R,Q);x.setPath([A,R]);r=H._map.getDistance(A,U.latLng).toFixed(0);s.setRadius(H._map.getDistance(A,U.latLng))});q.addEventListener("dragend",function(Q){u.updateWindow()});D.disableEdgeMove();D.removeEventListener("mousemove",w);D.removeEventListener("mousemove",F);e.un(document,"mouseup",C);G.removeOverlay(D)};var F=function(K){e.preventDefault(K);e.stopBubble(K);if(H.controlButton=="right"&&K.button==1){return}if(A==null){E(K)}};var p=function(K){e.preventDefault(K);e.stopBubble(K);G.removeOverlay(b);b=new BMapGL.Label("按下确认中心点,拖拽确认半径",{position:K.point,offset:new BMapGL.Size(10,10)});b.setStyle(H.labelOptions);G.addOverlay(b)};var z=function(K){G.removeOverlay(q);G.removeOverlay(x);G.removeOverlay(o);G.removeOverlay(u)};var v=function(K){A=K.latLng;s.setCenter(K.latLng)};var I=function(K){A=K.latLng;C(K)};D.addEventListener("mousedown",F);D.addEventListener("mousemove",p)};j.prototype._bindPolylineOrPolygon=function(){var v=this,o=this._map,A=this._mask,x=[],u=null,r=null,s=null,p=false;function w(){var D=arguments[0];var E=0;var C=0;for(var B=0;B0){s=D[0].point;r.setPositionAt(u.length-1,D[0].point);return}}s=null;r.setPositionAt(u.length-1,C.point);o.removeOverlay(b);b=new BMapGL.Label("单击绘制下一个点,双击完成绘制",{position:C.point,offset:new BMapGL.Size(10,10)});b.setStyle(v.labelOptions);o.addOverlay(b)};var t=function(H){e.stopBubble(H);p=false;o.removeOverlay(b);A.disableEdgeMove();A.removeEventListener("mousedown",q);A.removeEventListener("mousemove",z);A.removeEventListener("mousemove",y);A.removeEventListener("dblclick",t);if(v.controlButton=="right"){x.push(H.point)}else{if(e.ie<=8){}else{x.pop()}}try{if(v._enableGpc&&window.gpcas&&"polygon"===v._drawingType){var J=new gpcas.geometry.PolyDefault();for(var E=0;E松开结束绘制",{position:C.point,offset:new BMapGL.Size(10,10)});b.setStyle(u.labelOptions);p.addOverlay(b)};var s=function(K){y.hide();var L=null;var F=[];var M=t(q,K.point);var J=[];var C=p.getViewport(M);C.zoom-=1;p.setViewport(C);p.removeOverlay(b);var B=u._map.getDistance(q,M[2]).toFixed(0);var N=u._map.getDistance(q,M[6]).toFixed(0);var A=new l("rectangle",M[0],{width:B,height:N},v,u);for(var H=0;H0?C:null;return T};j.prototype.mc2ll=function(o){var q=this._map;var p=q.mercatorToLnglat(o.lng,o.lat); -return new BMapGL.Point(p[0],p[1])};j.prototype.ll2mc=function(o){var q=this._map;var p=q.lnglatToMercator(o.lng,o.lat);return new BMapGL.Point(p[0],p[1])};function c(o,p){this.limit=o.limit;this.type=o.type;this.point=o.point;this.overlay=o.overlay;this.overlays=o.overlays;this.DrawingManager=p}c.prototype=new BMapGL.Overlay();c.prototype.dispatchEvent=e.lang.Class.prototype.dispatchEvent;c.prototype.addEventListener=e.lang.Class.prototype.addEventListener;c.prototype.removeEventListener=e.lang.Class.prototype.removeEventListener;c.prototype.initialize=function(s){var r=this;this._map=s;var o=(this.type==="polyline"?"长度":"面积");var q=(this.type==="polyline"?"万米":"万平方米");var t=this.div=document.createElement("div");t.className="operateWindow";var p='
'+o+"不超过"+this.limit/10000+q+"!
";t.innerHTML=p;this._map.getPanes().markerPane.appendChild(t);this.updateWindow();this._bind();return t};c.prototype._bind=function(){var q=this;var r=this._map;var o=this.overlay;var p=this.overlays;document.getElementById("confirmOperate").addEventListener("click",function(v){r.removeOverlay(q);if(q.type=="rectangle"){var u=q.DrawingManager._calculate(o,o.getPath());q.DrawingManager.overlays.push(o)}else{if(q.type=="circle"){var u=q.DrawingManager._calculate(o,q.point);q.DrawingManager.overlays.push(o)}else{if(q.type=="polygon"){var u=q.DrawingManager._calculate(o,(o.getPath()));q.DrawingManager.overlays.push(o);o.disableEditing()}else{if(q.type=="polyline"){var u=q.DrawingManager._calculate(o,(o.getPath()));q.DrawingManager.overlays.push(o);o.disableEditing()}}}}q.DrawingManager._dispatchOverlayComplete(o,u);for(var t=0;to){document.getElementById("confirmOperate").style.display="none";document.getElementById("warnOperate").style.display="block"}else{document.getElementById("confirmOperate").style.display="block";document.getElementById("warnOperate").style.display="none"}};c.prototype.setPosition=function(p,o){this.point=p;var r=this._map,q=r.pointToOverlayPixel(this.point);if(o){this.div.classList.remove("operateLeft");this.div.style.left=q.x+15+"px"}else{this.div.classList.add("operateLeft");this.div.style.left=q.x-105+"px"}this.div.style.top=q.y-16+"px"};c.prototype.draw=function(){var p=this._map,o=p.pointToOverlayPixel(this.point);this.div.style.left=o.x+15+"px";this.div.style.top=o.y-16+"px"};function l(q,o,r,p,s){this.type=q;this.point=o;this.number=r;this.overlay=p;this.DrawingManager=s}l.prototype=new BMapGL.Overlay();l.prototype.dispatchEvent=e.lang.Class.prototype.dispatchEvent;l.prototype.addEventListener=e.lang.Class.prototype.addEventListener;l.prototype.removeEventListener=e.lang.Class.prototype.removeEventListener;l.prototype.initialize=function(q){var p=this;this._map=q;var r=this.div=document.createElement("div");r.className="screenshot";if(this.type=="circle"){var o='
'+this.number+'
'}else{if(this.type=="rectangle"){var o='
'+this.number.width+'
x
'+this.number.height+'
'}}r.innerHTML=o;this._map.getPanes().markerPane.appendChild(r);this._bind();return r};l.prototype._bind=function(){this.setNumber(this.number);if(this.type=="circle"){this.bindCircleEvent()}else{this.bindRectEvent()}};l.prototype.bindCircleEvent=function(){var p=this;var o=document.getElementById("screenshotNum");var q=document.getElementById("circleInput");o.addEventListener("click",function(r){var s=o.innerText;o.style.display="none";q.value=s;q.style.display="inline-block";q.focus()});q.addEventListener("click",function(r){q.focus()});q.addEventListener("keydown",function(s){if(s.keyCode===13){var t=q.value;q.style.display="none";o.style.display="inline-block"; -o.innerText=t;var r={radius:t,overlay:p.overlay};p._dispatchRadiusChange(r)}});q.addEventListener("blur",function(s){var t=q.value;q.style.display="none";o.style.display="inline-block";o.innerText=t;var r={radius:t,overlay:p.overlay};p._dispatchRadiusChange(r)})};l.prototype.bindRectEvent=function(){var q=this;var p=document.getElementById("rectWidth");var s=document.getElementById("rectWidthInput");var o=document.getElementById("rectHeight");var r=document.getElementById("rectHeightInput");s.value=p.innerText;r.value=o.innerText;p.addEventListener("click",function(t){var u=p.innerText;p.style.display="none";s.value=u;s.style.display="inline-block";s.focus()});o.addEventListener("click",function(t){var u=o.innerText;o.style.display="none";r.value=u;r.style.display="inline-block";r.focus()});s.addEventListener("click",function(t){s.focus()});r.addEventListener("click",function(t){r.focus()});s.addEventListener("keydown",function(w){if(w.keyCode===13){var u=s.value;var v=r.value;s.style.display="none";r.style.display="none";p.style.display="inline-block";o.style.display="inline-block";p.innerText=u;o.innerText=v;var t={width:u,height:v,overlay:q.overlay};q._dispatchRectWHChange(t)}});r.addEventListener("keydown",function(w){if(w.keyCode===13){var u=s.value;var v=r.value;s.style.display="none";r.style.display="none";p.style.display="inline-block";o.style.display="inline-block";p.innerText=u;o.innerText=v;var t={width:u,height:v,overlay:q.overlay};q._dispatchRectWHChange(t)}})};l.prototype.setInfo=function(o,p){this.setNumber(p);this.setPosition(o)};l.prototype.setNumber=function(o){if(this.type=="circle"){document.getElementById("screenshotNum").textContent=o}else{document.getElementById("rectWidth").textContent=o.width;document.getElementById("rectHeight").textContent=o.height}};l.prototype.setPosition=function(o){this.point=o;var r=this._map,q=this.type,p=r.pointToOverlayPixel(this.point);if(q=="circle"){this.div.style.left=p.x-30+"px";this.div.style.top=p.y-40+"px"}else{if(q=="rectangle"){this.div.style.left=p.x+"px";this.div.style.top=p.y-45+"px"}}};l.prototype.draw=function(){var q=this._map,p=this.type,o=q.pointToOverlayPixel(this.point);if(p=="circle"){this.div.style.left=o.x-30+"px";this.div.style.top=o.y-40+"px"}else{if(p=="rectangle"){this.div.style.left=o.x+"px";this.div.style.top=o.y-45+"px"}}};l.prototype._dispatchRadiusChange=function(o){this.dispatchEvent("radiuschange",o)};l.prototype._dispatchRectWHChange=function(o){this.dispatchEvent("rectwhchange",o)};function h(){this._enableEdgeMove=false}h.prototype=new BMapGL.Overlay();h.prototype.dispatchEvent=e.lang.Class.prototype.dispatchEvent;h.prototype.addEventListener=e.lang.Class.prototype.addEventListener;h.prototype.removeEventListener=e.lang.Class.prototype.removeEventListener;h.prototype.initialize=function(q){var p=this;this._map=q;var r=this.container=document.createElement("div");var o=this._map.getSize();r.style.cssText="position:absolute;background:transparent;cursor:crosshair;width:"+o.width+"px;height:"+o.height+"px";this._map.addEventListener("resize",function(s){p._adjustSize(s.size)});this._map.getPanes().floatPane.appendChild(r);this._bind();return r};h.prototype.draw=function(){var q=this._map,o=q.pixelToPoint(new BMapGL.Pixel(0,0)),p=q.pointToOverlayPixel(o);this.container.style.left=p.x+"px";this.container.style.top=p.y+"px"};h.prototype.enableEdgeMove=function(){this._enableEdgeMove=true};h.prototype.disableEdgeMove=function(){clearInterval(this._edgeMoveTimer);this._enableEdgeMove=false};h.prototype._bind=function(){var t=this,o=this._map,p=this.container,u=null,v=null;var s=function(x){return{x:x.clientX,y:x.clientY}};var r=function(z){var y=z.type;z=e.getEvent(z);point=t.getDrawPoint(z);var A=function(B){z.point=point;t.dispatchEvent(z)};if(y=="mousedown"){u=s(z)}var x=s(z);if(y=="click"){if(Math.abs(x.x-u.x)<5&&Math.abs(x.y-u.y)<5){if(!v||!(Math.abs(x.x-v.x)<5&&Math.abs(x.y-v.y)<5)){A("click");v=s(z)}else{v=null}}}else{A(y)}};var w=["click","mousedown","mousemove","mouseup","dblclick"],q=w.length;while(q--){e.on(p,w[q],r)}e.on(p,"mousemove",function(x){if(t._enableEdgeMove){t.mousemoveAction(x)}})};h.prototype.mousemoveAction=function(v){function o(A){var z=A.clientX,y=A.clientY;if(A.changedTouches){z=A.changedTouches[0].clientX;y=A.changedTouches[0].clientY}return new BMapGL.Pixel(z,y)}var p=this._map,w=this,q=p.pointToPixel(this.getDrawPoint(v)),s=o(v),t=s.x-q.x,r=s.y-q.y;q=new BMapGL.Pixel((s.x-t),(s.y-r));this._draggingMovePixel=q;var x=p.pixelToPoint(q),u={pixel:q,point:x};this._panByX=this._panByY=0;if(q.x<=20||q.x>=p.width-20||q.y<=50||q.y>=p.height-10){if(q.x<=20){this._panByX=8}else{if(q.x>=p.width-20){this._panByX=-8}}if(q.y<=50){this._panByY=8}else{if(q.y>=p.height-10){this._panByY=-8}}if(!this._edgeMoveTimer){this._edgeMoveTimer=setInterval(function(){p.panBy(w._panByX,w._panByY,{noAnimation:true})},30)}}else{if(this._edgeMoveTimer){clearInterval(this._edgeMoveTimer);this._edgeMoveTimer=null}}};h.prototype._adjustSize=function(o){this.container.style.width=o.width+"px"; -this.container.style.height=o.height+"px"};h.prototype.getDrawPoint=function(t){var s=this._map,r=e.getTarget(t),p=t.offsetX||t.layerX||0,u=t.offsetY||t.layerY||0;if(r.nodeType!=1){r=r.parentNode}while(r&&r!=s.getContainer()){if(!(r.clientWidth==0&&r.clientHeight==0&&r.offsetParent&&r.offsetParent.nodeName=="TD")){p+=r.offsetLeft||0;u+=r.offsetTop||0}r=r.offsetParent}var q=new BMapGL.Pixel(p,u);var o=s.pixelToPoint(q);return o};function g(p,o){this.drawingManager=p;o=this.drawingToolOptions=o||{};this._opts={};this.defaultAnchor=BMAP_ANCHOR_TOP_LEFT;this.defaultOffset=new BMapGL.Size(10,10);this.defaultDrawingModes=[BMAP_DRAWING_MARKER,BMAP_DRAWING_CIRCLE,BMAP_DRAWING_POLYLINE,BMAP_DRAWING_POLYGON,BMAP_DRAWING_RECTANGLE];if(o.drawingModes){this.drawingModes=o.drawingModes}else{this.drawingModes=this.defaultDrawingModes}if(o.hasCustomStyle){if(o.anchor){this.setAnchor(o.anchor)}if(o.offset){this.setOffset(o.offset)}}}g.prototype=new BMapGL.Control();g.prototype.initialize=function(s){var p=this.container=document.createElement("div");p.className="BMapGLLib_Drawing";var o=this.panel=document.createElement("div");o.className="BMapGLLib_Drawing_panel";if(this.drawingToolOptions&&this.drawingToolOptions.hasCustomStyle&&this.drawingToolOptions.scale){this._setScale(this.drawingToolOptions.scale)}p.appendChild(o);var q=this._generalHtml();o.appendChild(q);var r=this.tip=document.createElement("div");r.className="BMapGLLib_tip";r.innerHTML='

';if(this.drawingToolOptions.enableTips===true){o.appendChild(r)}this._bind(o);if(this.drawingToolOptions.customContainer){e.g(this.drawingToolOptions.customContainer).appendChild(p)}else{s.getContainer().appendChild(p)}return p};g.prototype._generalHtml=function(u){var t=this;var p={};p.hander="拖动地图";p[BMAP_DRAWING_MARKER]="画点";p[BMAP_DRAWING_CIRCLE]="圆形工具";p[BMAP_DRAWING_POLYLINE]="画折线";p[BMAP_DRAWING_POLYGON]="多边形工具";p[BMAP_DRAWING_RECTANGLE]="矩形工具";var v=function(x,w){var y=document.createElement("a");y.className=x;y.href="javascript:void(0)";y.setAttribute("drawingType",w);y.setAttribute("onfocus","this.blur()");y.addEventListener("mouseenter",function(A){var z=A.target.getAttribute("drawingType");var B=p[z];if(z==="hander"){t.tip.children[0].innerText=B;t.tip.children[1].innerText="使用鼠标拖动地图"}else{t.tip.className+=" "+z;t.tip.children[0].innerText=B;t.tip.children[1].innerText="使用"+B+"选出目标区域"}t.tip.style.display="block"});y.addEventListener("mouseleave",function(B){var z=B.target.getAttribute("drawingType");var A=" "+t.tip.className.replace(/[\t\r\n]/g,"")+" ";while(A.indexOf(" "+z+" ")>=0){A=A.replace(" "+z+" "," ")}t.tip.className=A.replace(/^\s+|\s+$/g,"");t.tip.style.display="none"});return y};var q=document.createDocumentFragment();for(var r=0,o=this.drawingModes.length;r松开完成绘制",{position:O.point,offset:new BMapGL.Size(10,10)});b.setStyle(L.labelOptions);K.addOverlay(b)};var G=function(R){var S=K.getViewport(t.getBounds());S.zoom-=1;K.setViewport(S);K.removeOverlay(b);var Q=new BMapGL.Point(t.getBounds().getNorthEast().lng,E.lat);H.hide();q=new BMapGL.Marker(Q);q.setIcon(F);q.enableDragging();A=new BMapGL.Polyline([E,Q],B);var T=new BMapGL.Point((t.getBounds().getNorthEast().lng+E.lng)/2,E.lat);o=new l("circle",T,s,t,L);N=N.concat([q,A,o]);var O=null;if(L.limit){O=L.limit.area}var P={limit:O,type:"circle",point:Q,overlay:t,overlays:N};w=new c(P,L);K.addOverlay(q);K.addOverlay(A);K.addOverlay(o);K.addOverlay(w); +L._skipEditing();o.addEventListener("radiuschange",function(Z){var U=Z.radius;t.setRadius(U);var Y=i(E,U,"east");var V=new BMapGL.Point(Y.lng,E.lat);var X=Y.lng>E.lng?(t.getBounds().getNorthEast().lng+E.lng)/2:(t.getBounds().getSouthWest().lng+E.lng)/2;var W=new BMapGL.Point(X,E.lat);q.setPosition(V);o.setInfo(W,U);w.setPosition(V,true);w.updateWindow();A.setPath([E,V])});q.addEventListener("dragging",function(Y){var V=new BMapGL.Point(Y.latLng.lng,E.lat);var X=Y.latLng.lng>E.lng?(t.getBounds().getNorthEast().lng+E.lng)/2:(t.getBounds().getSouthWest().lng+E.lng)/2;var U=Y.latLng.lng>E.lng?true:false;var W=new BMapGL.Point(X,E.lat);Y.target.setPosition(V);o.setInfo(W,L._map.getDistance(E,Y.latLng).toFixed(0));w.setPosition(V,U);A.setPath([E,V]);s=L._map.getDistance(E,Y.latLng).toFixed(0);t.setRadius(L._map.getDistance(E,Y.latLng))});q.addEventListener("dragend",function(U){w.updateWindow()});H.disableEdgeMove();H.removeEventListener("mousemove",z);H.removeEventListener("mousemove",J);e.un(document,"mouseup",G);K.removeOverlay(H)};var J=function(O){e.preventDefault(O);e.stopBubble(O);if(L.controlButton=="right"&&O.button==1){return}if(E==null){I(O)}};var p=function(O){e.preventDefault(O);e.stopBubble(O);K.removeOverlay(b);b=new BMapGL.Label("按下确认中心点,拖拽确认半径",{position:O.point,offset:new BMapGL.Size(10,10)});b.setStyle(L.labelOptions);K.addOverlay(b)};var C=function(O){K.removeOverlay(q);K.removeOverlay(A);K.removeOverlay(o);K.removeOverlay(w)};var y=function(O){E=O.latLng;t.setCenter(O.latLng)};var M=function(O){E=O.latLng;G(O)};H.addEventListener("mousedown",J);H.addEventListener("mousemove",p);if(D){var v=x.getCenter();var r=new BMapGL.Point(x.getBounds().getNorthEast().lng,v.lat);I({point:v});z({point:r});G({})}};j.prototype._bindPolylineOrPolygon=function(w,u){var F=this,E=this._map,y=this._mask,z=[],B=null,C=null,t=null,q=false;function s(){var I=arguments[0];var J=0;var H=0;for(var G=0;G0){t=I[0].point;C.setPositionAt(B.length-1,I[0].point);return}}t=null;C.setPositionAt(B.length-1,H.point);E.removeOverlay(b);b=new BMapGL.Label("单击绘制下一个点,双击完成绘制",{position:H.point,offset:new BMapGL.Size(10,10)});b.setStyle(F.labelOptions);E.addOverlay(b)};var p=function(M){e.stopBubble(M);q=false;E.removeOverlay(b);y.disableEdgeMove();y.removeEventListener("mousedown",A);y.removeEventListener("mousemove",v);y.removeEventListener("mousemove",o);y.removeEventListener("dblclick",p);if(F.controlButton=="right"){z.push(M.point)}else{if(e.ie<=8){}else{z.pop()}}try{if(F._enableGpc&&window.gpcas&&"polygon"===F._drawingType){var O=new gpcas.geometry.PolyDefault();for(var J=0;J松开结束绘制",{position:H.point,offset:new BMapGL.Size(10,10)});b.setStyle(x.labelOptions);p.addOverlay(b)};var v=function(P){D.hide();var Q=null;var K=[];var R=w(q,P.point);var O=[];var H=p.getViewport(R);H.zoom-=1;p.setViewport(H);p.removeOverlay(b);var G=x._map.getDistance(q,R[2]).toFixed(0);var S=x._map.getDistance(q,R[6]).toFixed(0);var F=new l("rectangle",R[0],{width:G,height:S},z,x);for(var M=0;M0?C:null;return T};j.prototype.mc2ll=function(o){var q=this._map;var p=q.mercatorToLnglat(o.lng,o.lat);return new BMapGL.Point(p[0],p[1])};j.prototype.ll2mc=function(o){var q=this._map;var p=q.lnglatToMercator(o.lng,o.lat);return new BMapGL.Point(p[0],p[1])};function c(o,p){this.limit=o.limit;this.type=o.type;this.point=o.point;this.overlay=o.overlay;this.overlays=o.overlays;this.DrawingManager=p}c.prototype=new BMapGL.Overlay();c.prototype.dispatchEvent=e.lang.Class.prototype.dispatchEvent;c.prototype.addEventListener=e.lang.Class.prototype.addEventListener;c.prototype.removeEventListener=e.lang.Class.prototype.removeEventListener;c.prototype.initialize=function(s){var r=this;this._map=s;var o=(this.type==="polyline"?"长度":"面积");var q=(this.type==="polyline"?"万米":"万平方米");var t=this.div=document.createElement("div");t.className="operateWindow";var p='
'+o+"不超过"+this.limit/10000+q+"!
";t.innerHTML=p;this._map.getPanes().markerPane.appendChild(t);this.updateWindow();this._bind();return t};c.prototype._bind=function(){var q=this;var r=this._map;var o=this.overlay;var p=this.overlays;document.getElementById("confirmOperate").addEventListener("click",function(v){r.removeOverlay(q);if(q.type=="rectangle"){var u=q.DrawingManager._calculate(o,o.getPath());q.DrawingManager.overlays.push(o)}else{if(q.type=="circle"){var u=q.DrawingManager._calculate(o,q.point);q.DrawingManager.overlays.push(o)}else{if(q.type=="polygon"){var u=q.DrawingManager._calculate(o,(o.getPath()));q.DrawingManager.overlays.push(o);o.disableEditing()}else{if(q.type=="polyline"){var u=q.DrawingManager._calculate(o,(o.getPath()));q.DrawingManager.overlays.push(o);o.disableEditing()}}}}q.DrawingManager._dispatchOverlayComplete(o,u);for(var t=0;to){document.getElementById("confirmOperate").style.display="none";document.getElementById("warnOperate").style.display="block"}else{document.getElementById("confirmOperate").style.display="block";document.getElementById("warnOperate").style.display="none"}};c.prototype.setPosition=function(p,o){this.point=p;var r=this._map,q=r.pointToOverlayPixel(this.point);if(o){this.div.classList.remove("operateLeft");this.div.style.left=q.x+15+"px"}else{this.div.classList.add("operateLeft");this.div.style.left=q.x-105+"px"}this.div.style.top=q.y-16+"px"};c.prototype.draw=function(){var p=this._map,o=p.pointToOverlayPixel(this.point);this.div.style.left=o.x+15+"px";this.div.style.top=o.y-16+"px"};function l(q,o,r,p,s){this.type=q;this.point=o;this.number=r;this.overlay=p;this.DrawingManager=s}l.prototype=new BMapGL.Overlay();l.prototype.dispatchEvent=e.lang.Class.prototype.dispatchEvent;l.prototype.addEventListener=e.lang.Class.prototype.addEventListener;l.prototype.removeEventListener=e.lang.Class.prototype.removeEventListener;l.prototype.initialize=function(q){var p=this;this._map=q;var r=this.div=document.createElement("div");r.className="screenshot";if(this.type=="circle"){var o='
'+this.number+'
'}else{if(this.type=="rectangle"){var o='
'+this.number.width+'
x
'+this.number.height+'
'}}r.innerHTML=o;this._map.getPanes().markerPane.appendChild(r); +this._bind();return r};l.prototype._bind=function(){this.setNumber(this.number);if(this.type=="circle"){this.bindCircleEvent()}else{this.bindRectEvent()}};l.prototype.bindCircleEvent=function(){var p=this;var o=document.getElementById("screenshotNum");var q=document.getElementById("circleInput");o.addEventListener("click",function(r){var s=o.innerText;o.style.display="none";q.value=s;q.style.display="inline-block";q.focus()});q.addEventListener("click",function(r){q.focus()});q.addEventListener("keydown",function(s){if(s.keyCode===13){var t=q.value;q.style.display="none";o.style.display="inline-block";o.innerText=t;var r={radius:t,overlay:p.overlay};p._dispatchRadiusChange(r)}});q.addEventListener("blur",function(s){var t=q.value;q.style.display="none";o.style.display="inline-block";o.innerText=t;var r={radius:t,overlay:p.overlay};p._dispatchRadiusChange(r)})};l.prototype.bindRectEvent=function(){var q=this;var p=document.getElementById("rectWidth");var s=document.getElementById("rectWidthInput");var o=document.getElementById("rectHeight");var r=document.getElementById("rectHeightInput");s.value=p.innerText;r.value=o.innerText;p.addEventListener("click",function(t){var u=p.innerText;p.style.display="none";s.value=u;s.style.display="inline-block";s.focus()});o.addEventListener("click",function(t){var u=o.innerText;o.style.display="none";r.value=u;r.style.display="inline-block";r.focus()});s.addEventListener("click",function(t){s.focus()});r.addEventListener("click",function(t){r.focus()});s.addEventListener("keydown",function(w){if(w.keyCode===13){var u=s.value;var v=r.value;s.style.display="none";r.style.display="none";p.style.display="inline-block";o.style.display="inline-block";p.innerText=u;o.innerText=v;var t={width:u,height:v,overlay:q.overlay};q._dispatchRectWHChange(t)}});r.addEventListener("keydown",function(w){if(w.keyCode===13){var u=s.value;var v=r.value;s.style.display="none";r.style.display="none";p.style.display="inline-block";o.style.display="inline-block";p.innerText=u;o.innerText=v;var t={width:u,height:v,overlay:q.overlay};q._dispatchRectWHChange(t)}})};l.prototype.setInfo=function(o,p){this.setNumber(p);this.setPosition(o)};l.prototype.setNumber=function(o){if(this.type=="circle"){document.getElementById("screenshotNum").textContent=o}else{document.getElementById("rectWidth").textContent=o.width;document.getElementById("rectHeight").textContent=o.height}};l.prototype.setPosition=function(o){this.point=o;var r=this._map,q=this.type,p=r.pointToOverlayPixel(this.point);if(q=="circle"){this.div.style.left=p.x-30+"px";this.div.style.top=p.y-40+"px"}else{if(q=="rectangle"){this.div.style.left=p.x+"px";this.div.style.top=p.y-45+"px"}}};l.prototype.draw=function(){var q=this._map,p=this.type,o=q.pointToOverlayPixel(this.point);if(p=="circle"){this.div.style.left=o.x-30+"px";this.div.style.top=o.y-40+"px"}else{if(p=="rectangle"){this.div.style.left=o.x+"px";this.div.style.top=o.y-45+"px"}}};l.prototype._dispatchRadiusChange=function(o){this.dispatchEvent("radiuschange",o)};l.prototype._dispatchRectWHChange=function(o){this.dispatchEvent("rectwhchange",o)};function h(){this._enableEdgeMove=false}h.prototype=new BMapGL.Overlay();h.prototype.dispatchEvent=e.lang.Class.prototype.dispatchEvent;h.prototype.addEventListener=e.lang.Class.prototype.addEventListener;h.prototype.removeEventListener=e.lang.Class.prototype.removeEventListener;h.prototype.initialize=function(q){var p=this;this._map=q;var r=this.container=document.createElement("div");var o=this._map.getSize();r.style.cssText="position:absolute;background:transparent;cursor:crosshair;width:"+o.width+"px;height:"+o.height+"px";this._map.addEventListener("resize",function(s){p._adjustSize(s.size)});this._map.getPanes().floatPane.appendChild(r);this._bind();return r};h.prototype.draw=function(){var q=this._map,o=q.pixelToPoint(new BMapGL.Pixel(0,0)),p=q.pointToOverlayPixel(o);this.container.style.left=p.x+"px";this.container.style.top=p.y+"px"};h.prototype.enableEdgeMove=function(){this._enableEdgeMove=true};h.prototype.disableEdgeMove=function(){clearInterval(this._edgeMoveTimer);this._enableEdgeMove=false};h.prototype._bind=function(){var t=this,o=this._map,p=this.container,u=null,v=null;var s=function(x){return{x:x.clientX,y:x.clientY}};var r=function(z){var y=z.type;z=e.getEvent(z);point=t.getDrawPoint(z);var A=function(B){z.point=point;t.dispatchEvent(z)};if(y=="mousedown"){u=s(z)}var x=s(z);if(y=="click"){if(Math.abs(x.x-u.x)<5&&Math.abs(x.y-u.y)<5){if(!v||!(Math.abs(x.x-v.x)<5&&Math.abs(x.y-v.y)<5)){A("click");v=s(z)}else{v=null}}}else{A(y)}};var w=["click","mousedown","mousemove","mouseup","dblclick"],q=w.length;while(q--){e.on(p,w[q],r)}e.on(p,"mousemove",function(x){if(t._enableEdgeMove){t.mousemoveAction(x)}})};h.prototype.mousemoveAction=function(v){function o(A){var z=A.clientX,y=A.clientY;if(A.changedTouches){z=A.changedTouches[0].clientX;y=A.changedTouches[0].clientY}return new BMapGL.Pixel(z,y)}var p=this._map,w=this,q=p.pointToPixel(this.getDrawPoint(v)),s=o(v),t=s.x-q.x,r=s.y-q.y; +q=new BMapGL.Pixel((s.x-t),(s.y-r));this._draggingMovePixel=q;var x=p.pixelToPoint(q),u={pixel:q,point:x};this._panByX=this._panByY=0;if(q.x<=20||q.x>=p.width-20||q.y<=50||q.y>=p.height-10){if(q.x<=20){this._panByX=8}else{if(q.x>=p.width-20){this._panByX=-8}}if(q.y<=50){this._panByY=8}else{if(q.y>=p.height-10){this._panByY=-8}}if(!this._edgeMoveTimer){this._edgeMoveTimer=setInterval(function(){p.panBy(w._panByX,w._panByY,{noAnimation:true})},30)}}else{if(this._edgeMoveTimer){clearInterval(this._edgeMoveTimer);this._edgeMoveTimer=null}}};h.prototype._adjustSize=function(o){this.container.style.width=o.width+"px";this.container.style.height=o.height+"px"};h.prototype.getDrawPoint=function(t){var s=this._map,r=e.getTarget(t),p=t.offsetX||t.layerX||0,u=t.offsetY||t.layerY||0;if(r.nodeType!=1){r=r.parentNode}while(r&&r!=s.getContainer()){if(!(r.clientWidth==0&&r.clientHeight==0&&r.offsetParent&&r.offsetParent.nodeName=="TD")){p+=r.offsetLeft||0;u+=r.offsetTop||0}r=r.offsetParent}var q=new BMapGL.Pixel(p,u);var o=s.pixelToPoint(q);return o};function g(p,o){this.drawingManager=p;o=this.drawingToolOptions=o||{};this._opts={};this.defaultAnchor=BMAP_ANCHOR_TOP_LEFT;this.defaultOffset=new BMapGL.Size(10,10);this.defaultDrawingModes=[BMAP_DRAWING_MARKER,BMAP_DRAWING_CIRCLE,BMAP_DRAWING_POLYLINE,BMAP_DRAWING_POLYGON,BMAP_DRAWING_RECTANGLE];if(o.drawingModes){this.drawingModes=o.drawingModes}else{this.drawingModes=this.defaultDrawingModes}if(o.hasCustomStyle){if(o.anchor){this.setAnchor(o.anchor)}if(o.offset){this.setOffset(o.offset)}}}g.prototype=new BMapGL.Control();g.prototype.initialize=function(s){var p=this.container=document.createElement("div");p.className="BMapGLLib_Drawing";var o=this.panel=document.createElement("div");o.className="BMapGLLib_Drawing_panel";if(this.drawingToolOptions&&this.drawingToolOptions.hasCustomStyle&&this.drawingToolOptions.scale){this._setScale(this.drawingToolOptions.scale)}p.appendChild(o);var q=this._generalHtml();o.appendChild(q);var r=this.tip=document.createElement("div");r.className="BMapGLLib_tip";r.innerHTML='

';if(this.drawingToolOptions.enableTips===true){o.appendChild(r)}this._bind(o);if(this.drawingToolOptions.customContainer){e.g(this.drawingToolOptions.customContainer).appendChild(p)}else{s.getContainer().appendChild(p)}return p};g.prototype._generalHtml=function(u){var t=this;var p={};p.hander="拖动地图";p[BMAP_DRAWING_MARKER]="画点";p[BMAP_DRAWING_CIRCLE]="圆形工具";p[BMAP_DRAWING_POLYLINE]="画折线";p[BMAP_DRAWING_POLYGON]="多边形工具";p[BMAP_DRAWING_RECTANGLE]="矩形工具";var v=function(x,w){var y=document.createElement("a");y.className=x;y.href="javascript:void(0)";y.setAttribute("drawingType",w);y.setAttribute("onfocus","this.blur()");y.addEventListener("mouseenter",function(A){var z=A.target.getAttribute("drawingType");var B=p[z];if(z==="hander"){t.tip.children[0].innerText=B;t.tip.children[1].innerText="使用鼠标拖动地图"}else{t.tip.className+=" "+z;t.tip.children[0].innerText=B;t.tip.children[1].innerText="使用"+B+"选出目标区域"}t.tip.style.display="block"});y.addEventListener("mouseleave",function(B){var z=B.target.getAttribute("drawingType");var A=" "+t.tip.className.replace(/[\t\r\n]/g,"")+" ";while(A.indexOf(" "+z+" ")>=0){A=A.replace(" "+z+" "," ")}t.tip.className=A.replace(/^\s+|\s+$/g,"");t.tip.style.display="none"});return y};var q=document.createDocumentFragment();for(var r=0,o=this.drawingModes.length;r Date: Sun, 21 May 2023 08:59:22 +0800 Subject: [PATCH 8/9] =?UTF-8?q?fix:=20=E8=BF=9B=E5=85=A5=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=B8=85=E9=99=A4=E6=97=A7=E6=9C=89overlay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrawingManager/src/DrawingManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/DrawingManager/src/DrawingManager.js b/DrawingManager/src/DrawingManager.js index 997d4cd..119c5c5 100644 --- a/DrawingManager/src/DrawingManager.js +++ b/DrawingManager/src/DrawingManager.js @@ -833,6 +833,7 @@ var BMAP_DRAWING_MARKER = "marker", // 鼠标画点模式 DrawingManager.prototype.setOverlayEdit = function(drawingMode, overlay) { if(['circle','rectangle','polygon','polyline'].includes(drawingMode)){ this.clearOverlay(overlay) + this._map.removeOverlay(overlay); this._drawingType = drawingMode this._open(true, overlay) }else{ From fcf16f4ae648a55a14f0351b21da4073166a03f8 Mon Sep 17 00:00:00 2001 From: chenglu Date: Sun, 21 May 2023 09:42:59 +0800 Subject: [PATCH 9/9] chore: update min.js --- DrawingManager/src/DrawingManager.min.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DrawingManager/src/DrawingManager.min.js b/DrawingManager/src/DrawingManager.min.js index 1a2ab45..7da22ee 100644 --- a/DrawingManager/src/DrawingManager.min.js +++ b/DrawingManager/src/DrawingManager.min.js @@ -1,8 +1,8 @@ var BMapGLLib=window.BMapGLLib=BMapGLLib||{};var BMAP_DRAWING_MARKER="marker",BMAP_DRAWING_POLYLINE="polyline",BMAP_DRAWING_CIRCLE="circle",BMAP_DRAWING_RECTANGLE="rectangle",BMAP_DRAWING_POLYGON="polygon";(function(){var d="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAAXNSR0IArs4c6QAAAs1JREFUWAnNmb9v01AQx989SzVI8dIBJNZ27Mb/QRpExMiOKAW1Mw3MRVCB2BlRECF/CBtjuwbBwGJL1JXs474vtuU4Tkho4tyTGr9ffvfxvV93VzL/mfYPLndSumqT4buG6Y4MI3+MpyQayc/IEI/Y0DfLW8Ov725cuKYlf2iZ/p3j8FZylT4hQx1m3lvmXSL6zoYH3pZ9PzgNfi367kKA3R634t/REXF6zMa0Fh28rp8IjJjsqb/det3vUVTXp1z3T8DOs/B+kvIHw3y7/OK180Q/PUuPB2+DL/PGsrMaZQrp3tPwJEn488rhIFQ+GGNDBmTN4qht6D7nm3ESfpRBurNeXGk9Ud/3gkf9N/SnOu6UBvE1jcKBSBQBmXWanAJsH0YvGtNcWV0C6WSX6yQ/McVuQ2DNycFW6ddQkdjz6EF54xQg46MkPMfibYimXozsbn872M2PoGKKcc5tHA7IoiDHkuE7DeKGSOP04rqHcL1Klq8VqMj6dgc3jtMgx+mBFjh8DlhwpSI/BiTaR0FTwn0PHnJWiYnPNcHlLNb4uxYmU16h7Qk26+w5bWQZD9hsZmzqRBRDGJsks4JVMgIwN9M1ArIAykRrRHNMwoY1+EMtoLBhDcID05pGMsWsF1DYLPxWrepzPjWcaq2AYLPw+OFUa4MEE9jG1ox4/NoAEYUAkwNEOAJGohZIsICpAITlinCEFkCw5PEbp0GAIVZixGHZOKRzmoQlSwUgvCjESsSG3eDVJ26nMOQeHRgLQBScP0r0EvmNJJFd9onBIOtxMiH80D4MPzUeXZD4zPAseCjHy8QMTmgQqOiAQI5k+pPoayxlwaMqnOOZJXasSRenOVlfKES0JdM6PGu9qoObC5iDqw1g5oBYtIiVGLK9VRzmbgwZC2NWN0Qus/yc2iTlxmoeIRIXhRBHX5bAXrV9XlmmcH1B9DrBTf0b4i99lUEMOuku/wAAAABJRU5ErkJggg==";var n="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IArs4c6QAAAd9JREFUOBGtVc8rRFEUPufOvELMguTHwkbKjxRlo9gqNpjyFyhTit3I8i1ldpQa5S9QmA1lS9koSn6UZmMxSCyGkPlx3O+9mTe8Zl4zw7eZ7rnn++aee893HlMRzEXFeLh6m2LJTpHwEJG022mcIJZTYbXX2lu/txnilJvO7sDkYnJaC0REqNO993PNTHEiDsfWAru/4vmFaYo6e35dEZIwYh1tPhobNmig20/NjcpKe3rJ0vlNmg5PUnR3n7FiTBwZbGpYNk3OIuCccHIhuQoxv49lNljD4yMG6VMUhT49HRynaGvnU9IZ0Wkcia0HlhxBlCkiOxAz5+u4v8tXVMgdvLjNkLnxbosyB1E+4wEeL5PXuLPQTC1NjBpunud6/yhF0e0PVBNv6Qv0KLwmxHBnKLNSgAMuNKClrNbQKniAUnfm9SfggAtAS9l9RtZrehG99tAJFnTP6n6wmzbfGl7EUnsFrrTbDVYqs4q4FtR20kDTVosClxMK3oQQHFAtHK7WUjA6hGAnOKBSgAMuAC2FqYGmhDdhp0oBDrjQgJayRxBbAwHehJ3KBXLBsfM5DC3H/v81HHIdSYQRpMcX6ekRhjcPjr/KGV+6Unt8xXJlOSfMl/lvAzYviN+/fAK+AW5jAVefzjWGAAAAAElFTkSuQmCC";var k="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAAAXNSR0IArs4c6QAABcdJREFUeAHtm0FoHFUYx7+ZbDfJJiZUqcEgBU3BqtGKRdGLHsSTSGxL8agUT230YtGTDQl6EKt4CD1JqPQkastSPImIvVSUQINRK1jrQVNSRRGz3WST3fH/f5k3THY3mmzejLub74Mv8/bNzJv3fnwz773v+yKiogSUgBJQAkpACSgBJaAElIASUAJKQAkoASWgBJSAElACSkAJKIH2J+A1OsQgCIZw7wh0P3Qwpr0oN7MsoHNzMZ1GOe953pVGOr0pgIB2Kx4yCj0AHW7kgU18zyz6dg46CZjXN9rPDQEEOFrVy9DjUGNhhaIEX8+WvEuXy/LbnxX5468AWpHF0kYf/f9c190psrPPl5v7Pdm105cH9nbIQ8PZoKdbLAta6Eno2wDJ8r+KvWndiwDvIE6egg7wooszy/LJhZJ8e6UslQprWl98X+TeoQ556rGsPLpvhx3QPApHAfGsrah3XBcgwPHcCegY1Pv+pxU5nV+Sy1fL9dppm7q9d3TI8yOdcvedGY4pgI5DJwCS5RqpCxDwunHl+9DDlUCCqbOL3vkvmvzdrBna1iqefjwrRw52Bb5nXu0P0dpzgFisbrUGYGh5H+DCw4ViELw5dcOb+aG9ra4aiv29764OefVIDt9Hj5wI8dlqS8TbXyN8bQ28V94pbFt4pELDIQMaEplAyWaNrAEYThhjfG1peb/Mt8kssWbIm/tBBmRBJrhzLGQUNRIBxAkuTzjbevzmbdfXNiITK5AFmZAN9FTIylwRAcQvrvMGONtutwnDkPiPP2RCNmQEJSsjBiCIcofBRbJZqpgzjv88cn8GC1azNHDW8qEns7L7trgNOGu6bkNcxoVyPGQm9ukv4kQvF8lJrfN6cx5mtG6nEG/p9+X10VxqEMmGjMgKOsqCBfgMf3CHkZQsw/p3ZNxCLOPL3n9TuhBjjOgPEB+mSK/KMPe23J4lJdPfLcvfhcApxM++XJZyOV2IZERWZEZ2tEC6pOSrb0peknvbhRsir00WnEL8ea4ib50upgqRjMiKzCAjBEh/nlxKYbdx9deKc4gXZ1ZShxhb4u0nQDpD5Xe4pNKQdoBI910ogxFA+vPSklaHGGMVBxhRTYVjK0Ok4zgUA9CYnvE32OqUjoSIfaZ5ml3i3D7Al6Jx4TfRLni5xJk4lpPObOPt1bszxipgb6/xIrq50xa40eG87Ioem/+8JFt1YAzu8uXAE6vEuE6cOrcoS46XtzFW10iNESoTI4hGkkKB8CaO9cie3R3maR99uiRnzkdbpYZ6QHhvvJTDWHwhvHfPFOXCtNm/NtTeejcxnhLKXASQAZa0pJXhkVGMlQHIuKjQ+5qGtDo8MmIkL5Rpml2ePx6+LxswOpWktAM8MmIYNOSU9+HjZ0R+FoPzGNpLSjJo2vU3r6/XS+WbF2dCRmRFZmRnbY4ReRMXjV/ssvzgPRmnEwb7xshZ0hNGNQPGjkMxzCzASVQuMKjMuGgS0tezOnO5mG1t/xAtS3S2tc+xR7IJA+/MWCCzVX8gTJG5IExnMEFlHl0L41ou4bF/SS5V6o2fAfdQTobMonwQgW+LXtYfoQPvfbzoPC6SgTd/xfGSLIssjJJxENtxJXfk5+KFQ2bRP4+n7AFAWmHkkZaw4ijqAkbkXS9rXMNj59OCRxZkQjZQ5ssYeOyD/QayTIhMpBlnOgMj8lvdl5pGW/wPGZBFmOIxHjKKRhXtSWwNXmXWaWoHIGwktaMGIEECInaqmlzUUHIRAVJCSzyB4hhU09s2k95GgFYAUhMsLYw6x7qvcPV1gMglTk2KL6NTDEYxntIqKb5d2Ehw92JTfPmdox8g3J5x6JxhuSZ2k+LLFq0AJFNAmMXAQPywrW+T4yzGkUySeT1AgDmEesaUGRZlZM8qrbWZhRZGJ7LVLf2bQzMPVPumBJSAElACSkAJKAEloASUgBJQAkpACSgBJaAElIASUAJKQAkoAVcE/gG4Wba8Vno8+QAAAABJRU5ErkJggg==";var e=e||{guid:"$BAIDU$"};(function(){window[e.guid]={};e.extend=function(r,o){for(var q in o){if(o.hasOwnProperty(q)){r[q]=o[q]}}return r};e.lang=e.lang||{};e.lang.guid=function(){return"TANGRAM__"+(window[e.guid]._counter++).toString(36)};window[e.guid]._counter=window[e.guid]._counter||1;window[e.guid]._instances=window[e.guid]._instances||{};e.lang.Class=function(o){this.guid=o||e.lang.guid();window[e.guid]._instances[this.guid]=this};window[e.guid]._instances=window[e.guid]._instances||{};e.lang.isString=function(o){return"[object String]"==Object.prototype.toString.call(o)};e.lang.isFunction=function(o){return"[object Function]"==Object.prototype.toString.call(o)};e.lang.Class.prototype.toString=function(){return"[object "+(this._className||"Object")+"]"};e.lang.Class.prototype.dispose=function(){delete window[e.guid]._instances[this.guid]; for(var o in this){if(!e.lang.isFunction(this[o])){delete this[o]}}this.disposed=true};e.lang.Event=function(o,p){this.type=o;this.returnValue=true;this.target=p||null;this.currentTarget=null};e.lang.Class.prototype.addEventListener=function(r,q,p){if(!e.lang.isFunction(q)){return}!this.__listeners&&(this.__listeners={});var o=this.__listeners,s;if(typeof p=="string"&&p){if(/[^\w\-]/.test(p)){throw ("nonstandard key:"+p)}else{q.hashCode=p;s=p}}r.indexOf("on")!=0&&(r="on"+r);typeof o[r]!="object"&&(o[r]={});s=s||e.lang.guid();q.hashCode=s;o[r][s]=q};e.lang.Class.prototype.removeEventListener=function(q,p){if(e.lang.isFunction(p)){p=p.hashCode}else{if(!e.lang.isString(p)){return}}!this.__listeners&&(this.__listeners={});q.indexOf("on")!=0&&(q="on"+q);var o=this.__listeners;if(!o[q]){return}o[q][p]&&delete o[q][p]};e.lang.Class.prototype.dispatchEvent=function(s,o){if(e.lang.isString(s)){s=new e.lang.Event(s)}!this.__listeners&&(this.__listeners={});o=o||{};for(var r in o){s[r]=o[r]}var r,q=this.__listeners,u=s.type;s.target=s.target||this;s.currentTarget=this;u.indexOf("on")!=0&&(u="on"+u);e.lang.isFunction(this[u])&&this[u].apply(this,arguments);if(typeof q[u]=="object"){for(r in q[u]){q[u][r].apply(this,arguments)}}return s.returnValue};e.lang.inherits=function(u,s,r){var q,t,o=u.prototype,p=new Function();p.prototype=s.prototype;t=u.prototype=new p();for(q in o){t[q]=o[q]}u.prototype.constructor=u;u.superClass=s.prototype;if("string"==typeof r){t._className=r}};e.dom=e.dom||{};e._g=e.dom._g=function(o){if(e.lang.isString(o)){return document.getElementById(o)}return o};e.g=e.dom.g=function(o){if("string"==typeof o||o instanceof String){return document.getElementById(o)}else{if(o&&o.nodeName&&(o.nodeType==1||o.nodeType==9)){return o}}return null};e.insertHTML=e.dom.insertHTML=function(r,o,q){r=e.dom.g(r);var p,s;if(r.insertAdjacentHTML){r.insertAdjacentHTML(o,q)}else{p=r.ownerDocument.createRange();o=o.toUpperCase();if(o=="AFTERBEGIN"||o=="BEFOREEND"){p.selectNodeContents(r);p.collapse(o=="AFTERBEGIN")}else{s=o=="BEFOREBEGIN";p[s?"setStartBefore":"setEndAfter"](r);p.collapse(s)}p.insertNode(p.createContextualFragment(q))}return r};e.ac=e.dom.addClass=function(t,u){t=e.dom.g(t);var p=u.split(/\s+/),o=t.className,s=" "+o+" ",r=0,q=p.length;for(;r松开完成绘制",{position:O.point,offset:new BMapGL.Size(10,10)});b.setStyle(L.labelOptions);K.addOverlay(b)};var G=function(R){var S=K.getViewport(t.getBounds());S.zoom-=1;K.setViewport(S);K.removeOverlay(b);var Q=new BMapGL.Point(t.getBounds().getNorthEast().lng,E.lat);H.hide();q=new BMapGL.Marker(Q);q.setIcon(F);q.enableDragging();A=new BMapGL.Polyline([E,Q],B);var T=new BMapGL.Point((t.getBounds().getNorthEast().lng+E.lng)/2,E.lat);o=new l("circle",T,s,t,L);N=N.concat([q,A,o]);var O=null;if(L.limit){O=L.limit.area}var P={limit:O,type:"circle",point:Q,overlay:t,overlays:N};w=new c(P,L);K.addOverlay(q);K.addOverlay(A);K.addOverlay(o);K.addOverlay(w); -L._skipEditing();o.addEventListener("radiuschange",function(Z){var U=Z.radius;t.setRadius(U);var Y=i(E,U,"east");var V=new BMapGL.Point(Y.lng,E.lat);var X=Y.lng>E.lng?(t.getBounds().getNorthEast().lng+E.lng)/2:(t.getBounds().getSouthWest().lng+E.lng)/2;var W=new BMapGL.Point(X,E.lat);q.setPosition(V);o.setInfo(W,U);w.setPosition(V,true);w.updateWindow();A.setPath([E,V])});q.addEventListener("dragging",function(Y){var V=new BMapGL.Point(Y.latLng.lng,E.lat);var X=Y.latLng.lng>E.lng?(t.getBounds().getNorthEast().lng+E.lng)/2:(t.getBounds().getSouthWest().lng+E.lng)/2;var U=Y.latLng.lng>E.lng?true:false;var W=new BMapGL.Point(X,E.lat);Y.target.setPosition(V);o.setInfo(W,L._map.getDistance(E,Y.latLng).toFixed(0));w.setPosition(V,U);A.setPath([E,V]);s=L._map.getDistance(E,Y.latLng).toFixed(0);t.setRadius(L._map.getDistance(E,Y.latLng))});q.addEventListener("dragend",function(U){w.updateWindow()});H.disableEdgeMove();H.removeEventListener("mousemove",z);H.removeEventListener("mousemove",J);e.un(document,"mouseup",G);K.removeOverlay(H)};var J=function(O){e.preventDefault(O);e.stopBubble(O);if(L.controlButton=="right"&&O.button==1){return}if(E==null){I(O)}};var p=function(O){e.preventDefault(O);e.stopBubble(O);K.removeOverlay(b);b=new BMapGL.Label("按下确认中心点,拖拽确认半径",{position:O.point,offset:new BMapGL.Size(10,10)});b.setStyle(L.labelOptions);K.addOverlay(b)};var C=function(O){K.removeOverlay(q);K.removeOverlay(A);K.removeOverlay(o);K.removeOverlay(w)};var y=function(O){E=O.latLng;t.setCenter(O.latLng)};var M=function(O){E=O.latLng;G(O)};H.addEventListener("mousedown",J);H.addEventListener("mousemove",p);if(D){var v=x.getCenter();var r=new BMapGL.Point(x.getBounds().getNorthEast().lng,v.lat);I({point:v});z({point:r});G({})}};j.prototype._bindPolylineOrPolygon=function(w,u){var F=this,E=this._map,y=this._mask,z=[],B=null,C=null,t=null,q=false;function s(){var I=arguments[0];var J=0;var H=0;for(var G=0;G0){t=I[0].point;C.setPositionAt(B.length-1,I[0].point);return}}t=null;C.setPositionAt(B.length-1,H.point);E.removeOverlay(b);b=new BMapGL.Label("单击绘制下一个点,双击完成绘制",{position:H.point,offset:new BMapGL.Size(10,10)});b.setStyle(F.labelOptions);E.addOverlay(b)};var p=function(M){e.stopBubble(M);q=false;E.removeOverlay(b);y.disableEdgeMove();y.removeEventListener("mousedown",A);y.removeEventListener("mousemove",v);y.removeEventListener("mousemove",o);y.removeEventListener("dblclick",p);if(F.controlButton=="right"){z.push(M.point)}else{if(e.ie<=8){}else{z.pop()}}try{if(F._enableGpc&&window.gpcas&&"polygon"===F._drawingType){var O=new gpcas.geometry.PolyDefault();for(var J=0;J松开结束绘制",{position:H.point,offset:new BMapGL.Size(10,10)});b.setStyle(x.labelOptions);p.addOverlay(b)};var v=function(P){D.hide();var Q=null;var K=[];var R=w(q,P.point);var O=[];var H=p.getViewport(R);H.zoom-=1;p.setViewport(H);p.removeOverlay(b);var G=x._map.getDistance(q,R[2]).toFixed(0);var S=x._map.getDistance(q,R[6]).toFixed(0);var F=new l("rectangle",R[0],{width:G,height:S},z,x);for(var M=0;M松开完成绘制",{position:O.point,offset:new BMapGL.Size(10,10)});b.setStyle(L.labelOptions);K.addOverlay(b)};var G=function(R){var S=K.getViewport(t.getBounds());S.zoom-=1;K.setViewport(S);K.removeOverlay(b);var Q=new BMapGL.Point(t.getBounds().getNorthEast().lng,E.lat);H.hide();q=new BMapGL.Marker(Q);q.setIcon(F);q.enableDragging();A=new BMapGL.Polyline([E,Q],B);var T=new BMapGL.Point((t.getBounds().getNorthEast().lng+E.lng)/2,E.lat);o=new l("circle",T,s,t,L);N=N.concat([q,A,o]);var O=null;if(L.limit){O=L.limit.area}var P={limit:O,type:"circle",point:Q,overlay:t,overlays:N};w=new c(P,L);K.addOverlay(q);K.addOverlay(A); +K.addOverlay(o);K.addOverlay(w);L._skipEditing();o.addEventListener("radiuschange",function(Z){var U=Z.radius;t.setRadius(U);var Y=i(E,U,"east");var V=new BMapGL.Point(Y.lng,E.lat);var X=Y.lng>E.lng?(t.getBounds().getNorthEast().lng+E.lng)/2:(t.getBounds().getSouthWest().lng+E.lng)/2;var W=new BMapGL.Point(X,E.lat);q.setPosition(V);o.setInfo(W,U);w.setPosition(V,true);w.updateWindow();A.setPath([E,V])});q.addEventListener("dragging",function(Y){var V=new BMapGL.Point(Y.latLng.lng,E.lat);var X=Y.latLng.lng>E.lng?(t.getBounds().getNorthEast().lng+E.lng)/2:(t.getBounds().getSouthWest().lng+E.lng)/2;var U=Y.latLng.lng>E.lng?true:false;var W=new BMapGL.Point(X,E.lat);Y.target.setPosition(V);o.setInfo(W,L._map.getDistance(E,Y.latLng).toFixed(0));w.setPosition(V,U);A.setPath([E,V]);s=L._map.getDistance(E,Y.latLng).toFixed(0);t.setRadius(L._map.getDistance(E,Y.latLng))});q.addEventListener("dragend",function(U){w.updateWindow()});H.disableEdgeMove();H.removeEventListener("mousemove",z);H.removeEventListener("mousemove",J);e.un(document,"mouseup",G);K.removeOverlay(H)};var J=function(O){e.preventDefault(O);e.stopBubble(O);if(L.controlButton=="right"&&O.button==1){return}if(E==null){I(O)}};var p=function(O){e.preventDefault(O);e.stopBubble(O);K.removeOverlay(b);b=new BMapGL.Label("按下确认中心点,拖拽确认半径",{position:O.point,offset:new BMapGL.Size(10,10)});b.setStyle(L.labelOptions);K.addOverlay(b)};var C=function(O){K.removeOverlay(q);K.removeOverlay(A);K.removeOverlay(o);K.removeOverlay(w)};var y=function(O){E=O.latLng;t.setCenter(O.latLng)};var M=function(O){E=O.latLng;G(O)};H.addEventListener("mousedown",J);H.addEventListener("mousemove",p);if(D){var v=x.getCenter();var r=new BMapGL.Point(x.getBounds().getNorthEast().lng,v.lat);I({point:v});z({point:r});G({})}};j.prototype._bindPolylineOrPolygon=function(w,u){var F=this,E=this._map,y=this._mask,z=[],B=null,C=null,t=null,q=false;function s(){var I=arguments[0];var J=0;var H=0;for(var G=0;G0){t=I[0].point;C.setPositionAt(B.length-1,I[0].point);return}}t=null;C.setPositionAt(B.length-1,H.point);E.removeOverlay(b);b=new BMapGL.Label("单击绘制下一个点,双击完成绘制",{position:H.point,offset:new BMapGL.Size(10,10)});b.setStyle(F.labelOptions);E.addOverlay(b)};var p=function(M){e.stopBubble(M);q=false;E.removeOverlay(b);y.disableEdgeMove();y.removeEventListener("mousedown",A);y.removeEventListener("mousemove",v);y.removeEventListener("mousemove",o);y.removeEventListener("dblclick",p);if(F.controlButton=="right"){z.push(M.point)}else{if(e.ie<=8){}else{z.pop()}}try{if(F._enableGpc&&window.gpcas&&"polygon"===F._drawingType){var O=new gpcas.geometry.PolyDefault();for(var J=0;J松开结束绘制",{position:H.point,offset:new BMapGL.Size(10,10)});b.setStyle(x.labelOptions);p.addOverlay(b)};var v=function(P){D.hide();var Q=null;var K=[];var R=w(q,P.point);var O=[];var H=p.getViewport(R);H.zoom-=1;p.setViewport(H);p.removeOverlay(b);var G=x._map.getDistance(q,R[2]).toFixed(0);var S=x._map.getDistance(q,R[6]).toFixed(0);var F=new l("rectangle",R[0],{width:G,height:S},z,x);for(var M=0;M0?C:null;return T};j.prototype.mc2ll=function(o){var q=this._map;var p=q.mercatorToLnglat(o.lng,o.lat);return new BMapGL.Point(p[0],p[1])};j.prototype.ll2mc=function(o){var q=this._map;var p=q.lnglatToMercator(o.lng,o.lat);return new BMapGL.Point(p[0],p[1])};function c(o,p){this.limit=o.limit;this.type=o.type;this.point=o.point;this.overlay=o.overlay;this.overlays=o.overlays;this.DrawingManager=p}c.prototype=new BMapGL.Overlay();c.prototype.dispatchEvent=e.lang.Class.prototype.dispatchEvent;c.prototype.addEventListener=e.lang.Class.prototype.addEventListener;c.prototype.removeEventListener=e.lang.Class.prototype.removeEventListener;c.prototype.initialize=function(s){var r=this;this._map=s;var o=(this.type==="polyline"?"长度":"面积");var q=(this.type==="polyline"?"万米":"万平方米");var t=this.div=document.createElement("div");t.className="operateWindow";var p='
'+o+"不超过"+this.limit/10000+q+"!
";t.innerHTML=p;this._map.getPanes().markerPane.appendChild(t);this.updateWindow();this._bind();return t};c.prototype._bind=function(){var q=this;var r=this._map;var o=this.overlay;var p=this.overlays;document.getElementById("confirmOperate").addEventListener("click",function(v){r.removeOverlay(q);if(q.type=="rectangle"){var u=q.DrawingManager._calculate(o,o.getPath());q.DrawingManager.overlays.push(o)}else{if(q.type=="circle"){var u=q.DrawingManager._calculate(o,q.point);q.DrawingManager.overlays.push(o)}else{if(q.type=="polygon"){var u=q.DrawingManager._calculate(o,(o.getPath()));q.DrawingManager.overlays.push(o);o.disableEditing()}else{if(q.type=="polyline"){var u=q.DrawingManager._calculate(o,(o.getPath()));q.DrawingManager.overlays.push(o);o.disableEditing()}}}}q.DrawingManager._dispatchOverlayComplete(o,u);for(var t=0;to){document.getElementById("confirmOperate").style.display="none";document.getElementById("warnOperate").style.display="block"}else{document.getElementById("confirmOperate").style.display="block";document.getElementById("warnOperate").style.display="none"}};c.prototype.setPosition=function(p,o){this.point=p;var r=this._map,q=r.pointToOverlayPixel(this.point);if(o){this.div.classList.remove("operateLeft");this.div.style.left=q.x+15+"px"}else{this.div.classList.add("operateLeft");this.div.style.left=q.x-105+"px"}this.div.style.top=q.y-16+"px"};c.prototype.draw=function(){var p=this._map,o=p.pointToOverlayPixel(this.point);this.div.style.left=o.x+15+"px";this.div.style.top=o.y-16+"px"};function l(q,o,r,p,s){this.type=q;this.point=o;this.number=r;this.overlay=p;this.DrawingManager=s}l.prototype=new BMapGL.Overlay();l.prototype.dispatchEvent=e.lang.Class.prototype.dispatchEvent;l.prototype.addEventListener=e.lang.Class.prototype.addEventListener;l.prototype.removeEventListener=e.lang.Class.prototype.removeEventListener;l.prototype.initialize=function(q){var p=this;this._map=q;var r=this.div=document.createElement("div");r.className="screenshot";if(this.type=="circle"){var o='
'+this.number+'
'}else{if(this.type=="rectangle"){var o='
'+this.number.width+'
x
'+this.number.height+'
'}}r.innerHTML=o;this._map.getPanes().markerPane.appendChild(r); this._bind();return r};l.prototype._bind=function(){this.setNumber(this.number);if(this.type=="circle"){this.bindCircleEvent()}else{this.bindRectEvent()}};l.prototype.bindCircleEvent=function(){var p=this;var o=document.getElementById("screenshotNum");var q=document.getElementById("circleInput");o.addEventListener("click",function(r){var s=o.innerText;o.style.display="none";q.value=s;q.style.display="inline-block";q.focus()});q.addEventListener("click",function(r){q.focus()});q.addEventListener("keydown",function(s){if(s.keyCode===13){var t=q.value;q.style.display="none";o.style.display="inline-block";o.innerText=t;var r={radius:t,overlay:p.overlay};p._dispatchRadiusChange(r)}});q.addEventListener("blur",function(s){var t=q.value;q.style.display="none";o.style.display="inline-block";o.innerText=t;var r={radius:t,overlay:p.overlay};p._dispatchRadiusChange(r)})};l.prototype.bindRectEvent=function(){var q=this;var p=document.getElementById("rectWidth");var s=document.getElementById("rectWidthInput");var o=document.getElementById("rectHeight");var r=document.getElementById("rectHeightInput");s.value=p.innerText;r.value=o.innerText;p.addEventListener("click",function(t){var u=p.innerText;p.style.display="none";s.value=u;s.style.display="inline-block";s.focus()});o.addEventListener("click",function(t){var u=o.innerText;o.style.display="none";r.value=u;r.style.display="inline-block";r.focus()});s.addEventListener("click",function(t){s.focus()});r.addEventListener("click",function(t){r.focus()});s.addEventListener("keydown",function(w){if(w.keyCode===13){var u=s.value;var v=r.value;s.style.display="none";r.style.display="none";p.style.display="inline-block";o.style.display="inline-block";p.innerText=u;o.innerText=v;var t={width:u,height:v,overlay:q.overlay};q._dispatchRectWHChange(t)}});r.addEventListener("keydown",function(w){if(w.keyCode===13){var u=s.value;var v=r.value;s.style.display="none";r.style.display="none";p.style.display="inline-block";o.style.display="inline-block";p.innerText=u;o.innerText=v;var t={width:u,height:v,overlay:q.overlay};q._dispatchRectWHChange(t)}})};l.prototype.setInfo=function(o,p){this.setNumber(p);this.setPosition(o)};l.prototype.setNumber=function(o){if(this.type=="circle"){document.getElementById("screenshotNum").textContent=o}else{document.getElementById("rectWidth").textContent=o.width;document.getElementById("rectHeight").textContent=o.height}};l.prototype.setPosition=function(o){this.point=o;var r=this._map,q=this.type,p=r.pointToOverlayPixel(this.point);if(q=="circle"){this.div.style.left=p.x-30+"px";this.div.style.top=p.y-40+"px"}else{if(q=="rectangle"){this.div.style.left=p.x+"px";this.div.style.top=p.y-45+"px"}}};l.prototype.draw=function(){var q=this._map,p=this.type,o=q.pointToOverlayPixel(this.point);if(p=="circle"){this.div.style.left=o.x-30+"px";this.div.style.top=o.y-40+"px"}else{if(p=="rectangle"){this.div.style.left=o.x+"px";this.div.style.top=o.y-45+"px"}}};l.prototype._dispatchRadiusChange=function(o){this.dispatchEvent("radiuschange",o)};l.prototype._dispatchRectWHChange=function(o){this.dispatchEvent("rectwhchange",o)};function h(){this._enableEdgeMove=false}h.prototype=new BMapGL.Overlay();h.prototype.dispatchEvent=e.lang.Class.prototype.dispatchEvent;h.prototype.addEventListener=e.lang.Class.prototype.addEventListener;h.prototype.removeEventListener=e.lang.Class.prototype.removeEventListener;h.prototype.initialize=function(q){var p=this;this._map=q;var r=this.container=document.createElement("div");var o=this._map.getSize();r.style.cssText="position:absolute;background:transparent;cursor:crosshair;width:"+o.width+"px;height:"+o.height+"px";this._map.addEventListener("resize",function(s){p._adjustSize(s.size)});this._map.getPanes().floatPane.appendChild(r);this._bind();return r};h.prototype.draw=function(){var q=this._map,o=q.pixelToPoint(new BMapGL.Pixel(0,0)),p=q.pointToOverlayPixel(o);this.container.style.left=p.x+"px";this.container.style.top=p.y+"px"};h.prototype.enableEdgeMove=function(){this._enableEdgeMove=true};h.prototype.disableEdgeMove=function(){clearInterval(this._edgeMoveTimer);this._enableEdgeMove=false};h.prototype._bind=function(){var t=this,o=this._map,p=this.container,u=null,v=null;var s=function(x){return{x:x.clientX,y:x.clientY}};var r=function(z){var y=z.type;z=e.getEvent(z);point=t.getDrawPoint(z);var A=function(B){z.point=point;t.dispatchEvent(z)};if(y=="mousedown"){u=s(z)}var x=s(z);if(y=="click"){if(Math.abs(x.x-u.x)<5&&Math.abs(x.y-u.y)<5){if(!v||!(Math.abs(x.x-v.x)<5&&Math.abs(x.y-v.y)<5)){A("click");v=s(z)}else{v=null}}}else{A(y)}};var w=["click","mousedown","mousemove","mouseup","dblclick"],q=w.length;while(q--){e.on(p,w[q],r)}e.on(p,"mousemove",function(x){if(t._enableEdgeMove){t.mousemoveAction(x)}})};h.prototype.mousemoveAction=function(v){function o(A){var z=A.clientX,y=A.clientY;if(A.changedTouches){z=A.changedTouches[0].clientX;y=A.changedTouches[0].clientY}return new BMapGL.Pixel(z,y)}var p=this._map,w=this,q=p.pointToPixel(this.getDrawPoint(v)),s=o(v),t=s.x-q.x,r=s.y-q.y; q=new BMapGL.Pixel((s.x-t),(s.y-r));this._draggingMovePixel=q;var x=p.pixelToPoint(q),u={pixel:q,point:x};this._panByX=this._panByY=0;if(q.x<=20||q.x>=p.width-20||q.y<=50||q.y>=p.height-10){if(q.x<=20){this._panByX=8}else{if(q.x>=p.width-20){this._panByX=-8}}if(q.y<=50){this._panByY=8}else{if(q.y>=p.height-10){this._panByY=-8}}if(!this._edgeMoveTimer){this._edgeMoveTimer=setInterval(function(){p.panBy(w._panByX,w._panByY,{noAnimation:true})},30)}}else{if(this._edgeMoveTimer){clearInterval(this._edgeMoveTimer);this._edgeMoveTimer=null}}};h.prototype._adjustSize=function(o){this.container.style.width=o.width+"px";this.container.style.height=o.height+"px"};h.prototype.getDrawPoint=function(t){var s=this._map,r=e.getTarget(t),p=t.offsetX||t.layerX||0,u=t.offsetY||t.layerY||0;if(r.nodeType!=1){r=r.parentNode}while(r&&r!=s.getContainer()){if(!(r.clientWidth==0&&r.clientHeight==0&&r.offsetParent&&r.offsetParent.nodeName=="TD")){p+=r.offsetLeft||0;u+=r.offsetTop||0}r=r.offsetParent}var q=new BMapGL.Pixel(p,u);var o=s.pixelToPoint(q);return o};function g(p,o){this.drawingManager=p;o=this.drawingToolOptions=o||{};this._opts={};this.defaultAnchor=BMAP_ANCHOR_TOP_LEFT;this.defaultOffset=new BMapGL.Size(10,10);this.defaultDrawingModes=[BMAP_DRAWING_MARKER,BMAP_DRAWING_CIRCLE,BMAP_DRAWING_POLYLINE,BMAP_DRAWING_POLYGON,BMAP_DRAWING_RECTANGLE];if(o.drawingModes){this.drawingModes=o.drawingModes}else{this.drawingModes=this.defaultDrawingModes}if(o.hasCustomStyle){if(o.anchor){this.setAnchor(o.anchor)}if(o.offset){this.setOffset(o.offset)}}}g.prototype=new BMapGL.Control();g.prototype.initialize=function(s){var p=this.container=document.createElement("div");p.className="BMapGLLib_Drawing";var o=this.panel=document.createElement("div");o.className="BMapGLLib_Drawing_panel";if(this.drawingToolOptions&&this.drawingToolOptions.hasCustomStyle&&this.drawingToolOptions.scale){this._setScale(this.drawingToolOptions.scale)}p.appendChild(o);var q=this._generalHtml();o.appendChild(q);var r=this.tip=document.createElement("div");r.className="BMapGLLib_tip";r.innerHTML='

';if(this.drawingToolOptions.enableTips===true){o.appendChild(r)}this._bind(o);if(this.drawingToolOptions.customContainer){e.g(this.drawingToolOptions.customContainer).appendChild(p)}else{s.getContainer().appendChild(p)}return p};g.prototype._generalHtml=function(u){var t=this;var p={};p.hander="拖动地图";p[BMAP_DRAWING_MARKER]="画点";p[BMAP_DRAWING_CIRCLE]="圆形工具";p[BMAP_DRAWING_POLYLINE]="画折线";p[BMAP_DRAWING_POLYGON]="多边形工具";p[BMAP_DRAWING_RECTANGLE]="矩形工具";var v=function(x,w){var y=document.createElement("a");y.className=x;y.href="javascript:void(0)";y.setAttribute("drawingType",w);y.setAttribute("onfocus","this.blur()");y.addEventListener("mouseenter",function(A){var z=A.target.getAttribute("drawingType");var B=p[z];if(z==="hander"){t.tip.children[0].innerText=B;t.tip.children[1].innerText="使用鼠标拖动地图"}else{t.tip.className+=" "+z;t.tip.children[0].innerText=B;t.tip.children[1].innerText="使用"+B+"选出目标区域"}t.tip.style.display="block"});y.addEventListener("mouseleave",function(B){var z=B.target.getAttribute("drawingType");var A=" "+t.tip.className.replace(/[\t\r\n]/g,"")+" ";while(A.indexOf(" "+z+" ")>=0){A=A.replace(" "+z+" "," ")}t.tip.className=A.replace(/^\s+|\s+$/g,"");t.tip.style.display="none"});return y};var q=document.createDocumentFragment();for(var r=0,o=this.drawingModes.length;r