You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
11 KiB
2 lines
11 KiB
3 months ago
|
var BMapLib=window.BMapLib=BMapLib||{};(function(){var e=0;var j=1;var c=BMapLib.RectangleZoom=function(n,m){if(!n){return}this._map=n;this._opts={zoomType:e,followText:"",strokeWeight:2,strokeColor:"#111",style:"solid",fillColor:"#ccc",opacity:0.4,cursor:"crosshair",autoClose:false};this._setOptions(m);this._opts.strokeWeight=this._opts.strokeWeight<=0?1:this._opts.strokeWeight;this._opts.opacity=this._opts.opacity<0?0:this._opts.opacity>1?1:this._opts.opacity;if(this._opts.zoomType<e||this._opts.zoomType>j){this._opts.zoomType=e}this._isOpen=false;this._fDiv=null;this._followTitle=null};c.prototype._setOptions=function(m){if(!m){return}for(var n in m){if(typeof(m[n])!="undefined"){this._opts[n]=m[n]}}};c.prototype.setStrokeColor=function(m){if(typeof m=="string"){this._opts.strokeColor=m;this._updateStyle()}};c.prototype.setLineStroke=function(m){if(typeof m=="number"&&Math.round(m)>0){this._opts.strokeWeight=Math.round(m);this._updateStyle()}};c.prototype.setLineStyle=function(m){if(m=="solid"||m=="dashed"){this._opts.style=m;this._updateStyle()}};c.prototype.setOpacity=function(m){if(typeof m=="number"&&m>=0&&m<=1){this._opts.opacity=m;this._updateStyle()}};c.prototype.setFillColor=function(m){this._opts.fillColor=m;this._updateStyle()};c.prototype.setCursor=function(m){this._opts.cursor=m;f.setCursor(this._opts.cursor)};c.prototype._updateStyle=function(){if(this._fDiv){this._fDiv.style.border=[this._opts.strokeWeight,"px ",this._opts.style," ",this._opts.color].join("");var m=this._fDiv.style,n=this._opts.opacity;m.opacity=n;m.MozOpacity=n;m.KhtmlOpacity=n;m.filter="alpha(opacity="+(n*100)+")"}};c.prototype.getCursor=function(){return this._opts.cursor};c.prototype._bind=function(){this.setCursor(this._opts.cursor);var n=this;d(this._map.getContainer(),"mousemove",function(q){if(!n._isOpen){return}if(!n._followTitle){return}q=window.event||q;var o=q.target||q.srcElement;if(o!=f.getDom(n._map)){n._followTitle.hide();return}if(!n._mapMoving){n._followTitle.show()}var p=f.getDrawPoint(q,true);n._followTitle.setPosition(p)});if(this._opts.followText){var m=this._followTitle=new BMap.Label(this._opts.followText,{offset:new BMap.Size(14,16)});this._followTitle.setStyles({color:"#333",borderColor:"#ff0103"})}};c.prototype.open=function(){if(this._isOpen==true){return true}if(!!BMapLib._toolInUse){return}this._isOpen=true;BMapLib._toolInUse=true;if(!this.binded){this._bind();this.binded=true}if(this._followTitle){this._map.addOverlay(this._followTitle);this._followTitle.hide()}var o=this;var p=this._map;var q=0;if(/msie (\d+\.\d)/i.test(navigator.userAgent)){q=document.documentMode||+RegExp["\x241"]}var n=function(s){s=window.event||s;if(s.button!=0&&!q||q&&s.button!=1){return}if(!!q&&f.getDom(p).setCapture){f.getDom(p).setCapture()}if(!o._isOpen){return}o._bind.isZooming=true;d(document,"mousemove",m);d(document,"mouseup",r);o._bind.mx=s.layerX||s.offsetX||0;o._bind.my=s.layerY||s.offsetY||0;o._bind.ix=s.pageX||s.clientX||0;o._bind.iy=s.pageY||s.clientY||0;a(f.getDom(p),"beforeBegin",o._generateHTML());o._fDiv=f.getDom(p).previousSibling;o._fDiv.style.width="0";o._fDiv.style.height="0";o._fDiv.style.left=o._bind.mx+"px";o._fDiv.style.top=o._bind.my+"px";b(s);return h(s)};var m=function(z){if(o._isOpen==true&&o._bind.isZooming==true){var z=window.event||z;var u=z.pageX||z.clientX||0;var s=z.pageY||z.clientY||0;var w=o._bind.dx=u-o._bind.ix;var t=o._bind.dy=s-o._bind.iy;var v=Math.abs(w)-o._opts.strokeWeight;var y=Math.abs(t)-o._opts.strokeWeight;o._fDiv.style.width=(v<0?0:v)+"px";o._fDiv.style.height=(y<0?0:y)+"px";var x=[p.getSize().width,p.getSize().height];if(w>=0){o._fDiv.style.right="auto";o._fDiv.style.left=o._bind.mx+"px";if(o._bind.mx+w>=x[0]-2*o._opts.strokeWeight){o._fDiv.style.width=x[0]-o._bind.mx-2*o._opts.strokeWeight+"px";o._followTitle&&o._followTitle.hide()}}else{o._fDiv.style.left="auto";o._fDiv.style.right=x[0]-o._bind.mx+"px";if(o._bind.mx+w<=2*o._opts.strokeWeight){o._fDiv.style.width=o._bind.mx-2*o._opts.strokeWeight+"px";o._followTitle&&o._followTitle.hide()}}if(t>=0){o._fDiv.style.bottom="auto";o._
|