| 1 |
- var BMapLib=window.BMapLib=BMapLib||{};if(typeof BMapLib._toolInUse=="undefined"){BMapLib._toolInUse=false}(function(){var e=e||{guid:"$BAIDU$"};(function(){window[e.guid]={};e.extend=function(e,n){for(var i in n){if(n.hasOwnProperty(i)){e[i]=n[i]}}return e};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(n){this.guid=n||e.lang.guid();window[e.guid]._instances[this.guid]=this};e.lang.isString=function(e){return"[object String]"==Object.prototype.toString.call(e)};e.lang.isFunction=function(e){return"[object Function]"==Object.prototype.toString.call(e)};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 n in this){if(!e.lang.isFunction(this[n])){delete this[n]}}this.disposed=true};e.lang.Event=function(e,n){this.type=e;this.returnValue=true;this.target=n||null;this.currentTarget=null};e.lang.Class.prototype.addEventListener=function(n,i,t){if(!e.lang.isFunction(i)){return}!this.__listeners&&(this.__listeners={});var a=this.__listeners,o;if(typeof t=="string"&&t){if(/[^\w\-]/.test(t)){throw"nonstandard key:"+t}else{i.hashCode=t;o=t}}n.indexOf("on")!=0&&(n="on"+n);typeof a[n]!="object"&&(a[n]={});o=o||e.lang.guid();i.hashCode=o;a[n][o]=i};e.lang.Class.prototype.removeEventListener=function(n,i){if(e.lang.isFunction(i)){i=i.hashCode}else if(!e.lang.isString(i)){return}!this.__listeners&&(this.__listeners={});n.indexOf("on")!=0&&(n="on"+n);var t=this.__listeners;if(!t[n]){return}t[n][i]&&delete t[n][i]};e.lang.Class.prototype.dispatchEvent=function(n,i){if(e.lang.isString(n)){n=new e.lang.Event(n)}!this.__listeners&&(this.__listeners={});i=i||{};for(var t in i){n[t]=i[t]}var t,a=this.__listeners,o=n.type;n.target=n.target||this;n.currentTarget=this;o.indexOf("on")!=0&&(o="on"+o);e.lang.isFunction(this[o])&&this[o].apply(this,arguments);if(typeof a[o]=="object"){for(t in a[o]){a[o][t].apply(this,arguments)}}return n.returnValue};e.lang.inherits=function(e,n,i){var t,a,o=e.prototype,s=new Function;s.prototype=n.prototype;a=e.prototype=new s;for(t in o){a[t]=o[t]}e.prototype.constructor=e;e.superClass=n.prototype;if("string"==typeof i){a._className=i}}})();var n=BMapLib.MarkerTool=function(i,t){e.lang.Class.call(this);this._map=i;this._opts={icon:n.SYS_ICONS[8],followText:"点击地图添加工作场所",autoClose:true};e.extend(this._opts,t);this._isOpen=false;this._opts.followText=this._checkStr(this._opts.followText);this._followMarker=null;this._followLabel=null};e.lang.inherits(n,e.lang.Class,"MarkerTool");n.prototype.open=function(){if(!this._map){return false}if(this._isOpen==true){return true}if(BMapLib._toolInUse){return false}BMapLib._toolInUse=true;this._isOpen=true;if(!this._binded){this._bind();this._binded=true}if(!this._followMarker){this._followMarker=new BMap.Marker(this._map.getCenter(),{offset:new BMap.Size(-10,-10)});this._map.addOverlay(this._followMarker);this._followMarker.setZIndex(1e3);this._followMarker.hide()}if(!this._followLabel){this._followLabel=new BMap.Label(this._opts.followText,{offset:new BMap.Size(20,0)})}this._preCursor=this._map.getDefaultCursor();this._map.setDefaultCursor("url("+n.CUR_IMG+"), default");return true};n.prototype.close=function(){if(!this._isOpen){return}this._map.removeEventListener("mousemove",this._mouseMoveHandler);this._map.removeEventListener("click",this._clickHandler);this._followMarker.hide();this._map.setDefaultCursor(this._preCursor);BMapLib._toolInUse=false;this._isOpen=false;this._binded=false};n.prototype.setIcon=function(e){if(!e||!(e instanceof BMap.Icon)){return}this._opts.icon=e};n.prototype.getIcon=function(){return this._opts.icon};n.prototype._checkStr=function(e){if(!e){return""}return e.replace(/</g,"<").replace(/>/g,">")};n.prototype._bind=function(){var n=this;if(!n._isOpen){return}n._mouseMoveHandler=function(e){var i=e.point;n._followMarker.setIcon(n._opts.icon);n._followMarker.setPosition(i);n._followMarker.setLabel(n._followLabel);n._followMarker.show()};n._map.addEventListener("mousemove",n._mouseMoveHandler);n._clickHandler=function(i){var t=i.pixel;var a=new BMap.Pixel(t.x-10,t.y-10);var o=n._map.pixelToPoint(a);var s=new BMap.Marker(o,{icon:n._opts.icon,enableDragging:true});n._map.addOverlay(s);var r=new e.lang.Event("onmarkend");r.marker=s;n.dispatchEvent(r);if(n._opts.autoClose){n.close()}};n._map.addEventListener("click",n._clickHandler)};n.CUR_IMG="/x_component_Attendance/$AddressExplorer/default/icon/transparent.cur";n.ICON_IMG="/x_component_Attendance/$AddressExplorer/default/icon/us_mk_icon.png";n.SYS_ICONS=[new BMap.Icon(n.ICON_IMG,new BMap.Size(21,21),{anchor:new BMap.Size(6,21),imageOffset:new BMap.Size(0,0)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(21,21),{anchor:new BMap.Size(6,21),imageOffset:new BMap.Size(-23,0)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(21,21),{anchor:new BMap.Size(6,21),imageOffset:new BMap.Size(-46,0)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(21,21),{anchor:new BMap.Size(6,21),imageOffset:new BMap.Size(-69,0)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(21,21),{anchor:new BMap.Size(6,21),imageOffset:new BMap.Size(-92,0)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(21,21),{anchor:new BMap.Size(6,21),imageOffset:new BMap.Size(-115,0)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(23,25),{anchor:new BMap.Size(9,25),imageOffset:new BMap.Size(0,-21)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(23,25),{anchor:new BMap.Size(9,25),imageOffset:new BMap.Size(-23,-21)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(23,25),{anchor:new BMap.Size(9,25),imageOffset:new BMap.Size(-46,-21)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(23,25),{anchor:new BMap.Size(9,25),imageOffset:new BMap.Size(-69,-21)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(23,25),{anchor:new BMap.Size(9,25),imageOffset:new BMap.Size(-92,-21)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(23,25),{anchor:new BMap.Size(9,25),imageOffset:new BMap.Size(-115,-21)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(21,21),{anchor:new BMap.Size(1,21),imageOffset:new BMap.Size(0,-46)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(21,21),{anchor:new BMap.Size(1,21),imageOffset:new BMap.Size(-23,-46)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(21,21),{anchor:new BMap.Size(1,21),imageOffset:new BMap.Size(-46,-46)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(21,21),{anchor:new BMap.Size(1,21),imageOffset:new BMap.Size(-69,-46)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(21,21),{anchor:new BMap.Size(1,21),imageOffset:new BMap.Size(-92,-46)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(21,21),{anchor:new BMap.Size(1,21),imageOffset:new BMap.Size(-115,-46)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(25,25),{anchor:new BMap.Size(12,25),imageOffset:new BMap.Size(0,-67)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(25,25),{anchor:new BMap.Size(12,25),imageOffset:new BMap.Size(-25,-67)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(24,25),{anchor:new BMap.Size(12,25),imageOffset:new BMap.Size(-50,-67)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(25,25),{anchor:new BMap.Size(12,25),imageOffset:new BMap.Size(-75,-67)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(25,25),{anchor:new BMap.Size(12,25),imageOffset:new BMap.Size(-100,-67)}),new BMap.Icon(n.ICON_IMG,new BMap.Size(19,25),{anchor:new BMap.Size(9,25),imageOffset:new BMap.Size(-125,-67)})]})();
|