var BMapLib=window.BMapLib=BMapLib||{};var BMAPLIB_TAB_SEARCH=0,BMAPLIB_TAB_TO_HERE=1,BMAPLIB_TAB_FROM_HERE=2;(function(){var d,c=d=c||{version:"1.5.0"};c.guid="$BAIDU$";(function(){window[c.guid]=window[c.guid]||{};c.lang=c.lang||{};c.lang.isString=function(e){return"[object String]"==Object.prototype.toString.call(e)};c.lang.Event=function(e,f){this.type=e;this.returnValue=true;this.target=f||null;this.currentTarget=null};c.object=c.object||{};c.extend=c.object.extend=function(g,e){for(var f in e){if(e.hasOwnProperty(f)){g[f]=e[f]}}return g};c.event=c.event||{};c.event._listeners=c.event._listeners||[];c.dom=c.dom||{};c.dom._g=function(e){if(c.lang.isString(e)){return document.getElementById(e)}return e};c._g=c.dom._g;c.event.on=function(f,i,k){i=i.replace(/^on/i,"");f=c.dom._g(f);var j=function(m){k.call(f,m)},e=c.event._listeners,h=c.event._eventFilter,l,g=i;i=i.toLowerCase();if(h&&h[i]){l=h[i](f,i,j);g=l.type;j=l.listener}if(f.addEventListener){f.addEventListener(g,j,false)}else{if(f.attachEvent){f.attachEvent("on"+g,j)}}e[e.length]=[f,i,k,j,g];return f};c.on=c.event.on;c.event.un=function(g,j,f){g=c.dom._g(g);j=j.replace(/^on/i,"").toLowerCase();var m=c.event._listeners,h=m.length,i=!f,l,k,e;while(h--){l=m[h];if(l[1]===j&&l[0]===g&&(i||l[2]===f)){k=l[4];e=l[3];if(g.removeEventListener){g.removeEventListener(k,e,false)}else{if(g.detachEvent){g.detachEvent("on"+k,e)}}m.splice(h,1)}}return g};c.un=c.event.un;c.dom.g=function(e){if("string"==typeof e||e instanceof String){return document.getElementById(e)}else{if(e&&e.nodeName&&(e.nodeType==1||e.nodeType==9)){return e}}return null};c.g=c.G=c.dom.g;c.string=c.string||{};c.browser=c.browser||{};c.browser.ie=c.ie=/msie (\d+\.\d+)/i.test(navigator.userAgent)?(document.documentMode||+RegExp["\x241"]):undefined;c.dom._NAME_ATTRS=(function(){var e={cellpadding:"cellPadding",cellspacing:"cellSpacing",colspan:"colSpan",rowspan:"rowSpan",valign:"vAlign",usemap:"useMap",frameborder:"frameBorder"};if(c.browser.ie<8){e["for"]="htmlFor";e["class"]="className"}else{e.htmlFor="for";e.className="class"}return e})();c.dom.setAttr=function(f,e,g){f=c.dom.g(f);if("style"==e){f.style.cssText=g}else{e=c.dom._NAME_ATTRS[e]||e;f.setAttribute(e,g)}return f};c.setAttr=c.dom.setAttr;c.dom.setAttrs=function(g,e){g=c.dom.g(g);for(var f in e){c.dom.setAttr(g,f,e[f])}return g};c.setAttrs=c.dom.setAttrs;c.dom.create=function(g,e){var h=document.createElement(g),f=e||{};return c.dom.setAttrs(h,f)};d.undope=true})();var a=BMapLib.SearchInfoWindow=function(g,f,e){this.guid=b++;BMapLib.SearchInfoWindow.instance[this.guid]=this;this._isOpen=false;this._map=g;this._opts=e=e||{};this._content=f||"";this._opts.width=e.width;this._opts.height=e.height;this._opts._title=e.title||"";this._opts.offset=e.offset||new BMap.Size(0,0);this._opts.enableAutoPan=e.enableAutoPan===false?false:true;this._opts._panel=e.panel||null;this._opts._searchTypes=e.searchTypes};a.prototype=new BMap.Overlay();a.prototype.initialize=function(f){this._closeOtherSearchInfo();var e=this;var h=this._createSearchTemplate();var g=f.getPanes().floatPane;g.style.width="auto";g.appendChild(h);this._initSearchTemplate();this._getSearchInfoWindowSize();this._boxWidth=parseInt(this.container.offsetWidth,10);this._boxHeight=parseInt(this.container.offsetHeight,10);c.event.on(h,"onmousedown",function(i){e._stopBubble(i)});c.event.on(h,"onmouseover",function(i){e._stopBubble(i)});c.event.on(h,"click",function(i){e._stopBubble(i)});c.event.on(h,"dblclick",function(i){e._stopBubble(i)});return h};a.prototype.draw=function(){this._isOpen&&this._adjustPosition(this._point)};a.prototype.open=function(e){this._map.closeInfoWindow();var f=this,g;if(!this._isOpen){this._map.addOverlay(this);this._isOpen=true;setTimeout(function(){f._dispatchEvent(f,"open",{point:f._point})},10)}if(e instanceof BMap.Point){g=e;this._removeMarkerEvt();this._marker=null}else{if(e instanceof BMap.Marker){if(this._marker){this._removeMarkerEvt()}g=e.getPosition();this._marker=e;!this._markerDragend&&this._marker.addEventListener("dragend",this._markerDragend=function(h){f._point=h.point;f._adjustPosition(f._point);f._panBox();f.show()});!this._markerDragging&&this._marker.addEventListener("dragging",this._markerDragging=function(){f.hide();f._point=f._marker.getPosition();f._adjustPosition(f._point)})}}this.show();this._point=g;this._panBox();this._adjustPosition(this._point)};a.prototype.close=function(){if(this._isOpen){this._map.removeOverlay(this);this._disposeAutoComplete();this._isOpen=false;this._dispatchEvent(this,"close",{point:this._point})}};a.prototype.enableAutoPan=function(){this._opts.enableAutoPan=true};a.prototype.disableAutoPan=function(){this._opts.enableAutoPan=false};a.prototype.setContent=function(e){this._setContent(e);this._getSearchInfoWindowSize();this._adjustPosition(this._point)},a.prototype.setTitle=function(e){this.dom.title.innerHTML=e;this._opts._title=e};a.prototype.getContent=function(){return this.dom.content.innerHTML},a.prototype.getTitle=function(){return this.dom.title.innerHTML};a.prototype.setPosition=function(e){this._point=e;this._adjustPosition(e);this._panBox();this._removeMarkerEvt()};a.prototype.getPosition=function(){return this._point};a.prototype.getOffset=function(){return this._opts.offset},c.object.extend(a.prototype,{_closeOtherSearchInfo:function(){var f=BMapLib.SearchInfoWindow.instance,e=f.length;while(e--){if(f[e]._isOpen){f[e].close()}}},_setContent:function(f){if(!this.dom||!this.dom.content){return}if(typeof f.nodeType==="undefined"){this.dom.content.innerHTML=f}else{this.dom.content.appendChild(f)}var e=this;e._adjustContainerWidth();this._content=f},_adjustPosition:function(g){var e=this._getPointPosition(g);var f=this._marker&&this._marker.getIcon();if(this._marker){this.container.style.bottom=-(e.y-this._opts.offset.height-f.anchor.height+f.infoWindowAnchor.height)-this._marker.getOffset().height+2+30+"px";this.container.style.left=e.x-f.anchor.width+this._marker.getOffset().width+f.infoWindowAnchor.width-this._boxWidth/2+28+"px"}else{this.container.style.bottom=-(e.y-this._opts.offset.height)+30+"px";this.container.style.left=e.x-this._boxWidth/2+25+"px"}},_getPointPosition:function(e){this._pointPosition=this._map.pointToOverlayPixel(e);return this._pointPosition},_getSearchInfoWindowSize:function(){this._boxWidth=parseInt(this.container.offsetWidth,10);this._boxHeight=parseInt(this.container.offsetHeight,10)},_stopBubble:function(f){if(f&&f.stopPropagation){f.stopPropagation()}else{window.event.cancelBubble=true}},_panBox:function(){if(!this._opts.enableAutoPan){return}var j=parseInt(this._map.getContainer().offsetHeight,10),o=parseInt(this._map.getContainer().offsetWidth,10),k=this._boxHeight,e=this._boxWidth;if(k>=j||e>=o){return}if(!this._map.getBounds().containsPoint(this._point)){this._map.setCenter(this._point)}var f=this._map.pointToPixel(this._point),p,m,i=e/2-28-f.x+10,n=e/2+28+f.x-o+10;if(this._marker){var l=this._marker.getIcon()}var g=this._marker?l.anchor.height+this._marker.getOffset().height-l.infoWindowAnchor.height:0;p=k-f.y+this._opts.offset.height+g+31+10;panX=i>0?i:(n>0?-n:0);m=p>0?p:0;this._map.panBy(panX,m)},_removeMarkerEvt:function(){this._markerDragend&&this._marker.removeEventListener("dragend",this._markerDragend);this._markerDragging&&this._marker.removeEventListener("dragging",this._markerDragging);this._markerDragend=this._markerDragging=null},_dispatchEvent:function(e,f,h){f.indexOf("on")!=0&&(f="on"+f);var g=new c.lang.Event(f);if(!!h){for(var i in h){g[i]=h[i]}}e.dispatchEvent(g)},_initSearchTemplate:function(){this._initDom();this._initPanelTemplate();this.setTitle(this._opts._title);if(this._opts.height){this.dom.content.style.height=parseInt(this._opts.height,10)+"px"}this._setContent(this._content);this._initService();this._bind();if(this._opts._searchTypes){this._setSearchTypes()}this._mendIE6()},_createSearchTemplate:function(){if(!this._div){var f=c.dom.create("div",{"class":"BMapLib_SearchInfoWindow",id:"BMapLib_SearchInfoWindow"+this.guid});var e=['
',{position:this._point});this._map.addOverlay(f);this._map.addOverlay(e);this._hasCircle=true},_changeSearchRadius:function(){var e=parseInt(c.g("BMapLib_search_radius"+this.guid).value,10);if(e>0&&e!=this._radius){this._radius=e;this.localSearch.searchNearby(this._kw,this._point,e);this._closeCircleBound()}},_closeCircleBound:function(e){if(this._searchCircle){this._map.removeOverlay(this._searchCircle)}if(this._searchLabel){this._map.removeOverlay(this._searchLabel)}this._hasCircle=false},_transitRouteAction:function(e){var f=this.dom.transText.value;if(f==""){this.dom.transText.focus()}else{this._reset();this.close();var g=this._getTransPoi(f);e.search(g.start,g.end)}},_transitRouteComplete:function(e,h){this._clearAddress();var f=e.getStatus();if(f==BMAP_STATUS_UNKNOWN_ROUTE){var g=h.getStartStatus(),i=h.getEndStatus(),j="";j="找不到相关的线路";if(g==BMAP_ROUTE_STATUS_EMPTY&&i==BMAP_ROUTE_STATUS_EMPTY){j="找不到相关的起点和终点"}else{if(g==BMAP_ROUTE_STATUS_EMPTY){j="找不到相关的起点"}if(i==BMAP_ROUTE_STATUS_EMPTY){j="找不到相关的终点"}}if(this._pointType=="startPoint"&&i==BMAP_ROUTE_STATUS_ADDRESS||this._pointType=="endPoint"&&g==BMAP_ROUTE_STATUS_ADDRESS){this._searchAddress(e)}else{this.dom.panel.address.style.display="block";this.dom.panel.address.innerHTML=j}}},_searchAddress:function(e){var i=this;var f=this.dom.panel;if(!this.lsAddress){var g={map:this._map};if(f){g.panel=this.dom.panel.localSearch}this.lsAddress=new BMap.LocalSearch(map,{renderOptions:g})}var h=i._pointType=="startPoint"?"终点":"起点";if(f){this.dom.panel.address.style.display="block";this.dom.panel.address.innerHTML="请选择准确的"+h}this.lsAddress.setInfoHtmlSetCallback(function(l,k){var j=document.createElement("div");j.style.cssText="position:relative;left:50%;margin:5px 0 0 -30px;width:60px;height:27px;line-height:27px;border:1px solid #E0C3A6;text-align:center;color:#B35900;cursor:pointer;background-color:#FFEECC;border-radius:2px; background-image: -webkit-gradient(linear, left top, left bottom, from(#FFFDF8), to(#FFEECC))";j.innerHTML="设为"+h;k.appendChild(j);c.on(j,"click",function(){i._clearAddress();var m=l.marker.getPosition();if(h=="起点"){e.search(m,i._point)}else{e.search(i._point,m)}})});this._reset();this.lsAddress.search(this.dom.transText.value)},_getTransPoi:function(f){var g,e;if(this._pointType=="startPoint"){g=this._point;e=f}else{g=f;e=this._point}return{start:g,end:e}},_setSearchTypes:function(){var l=this._unique(this._opts._searchTypes),f=this.dom.navTab,k=[this.dom.seartTab,this.dom.tohereTab,this.dom.fromhereTab],j=0,e=0,h=0,m;this.tabLength=l.length;tabWidth=Math.floor((this._width-this.tabLength+1)/this.tabLength);if(l.length==0){this.dom.navBox.style.display="none"}else{for(j=0,e=k.length;j