var BMapLib=window.BMapLib=BMapLib||{},BMAPLIB_TAB_SEARCH=0,BMAPLIB_TAB_TO_HERE=1,BMAPLIB_TAB_FROM_HERE=2;!function(){function t(t,e){this._point=t,this.guid=e}function e(t){this.iw=t}function i(t){var e=document.createElement("script");e.setAttribute("type","text/javascript"),e.setAttribute("src",t),e.addEventListener?e.addEventListener("load",function(t){var e=t.target||t.srcElement;e.parentNode.removeChild(e)},!1):e.attachEvent&&e.attachEvent("onreadystatechange",function(){var t=window.event.srcElement;!t||"loaded"!=t.readyState&&"complete"!=t.readyState||t.parentNode.removeChild(t)}),setTimeout(function(){document.getElementsByTagName("head")[0].appendChild(e),e=null},1)}var n,s=n=s||{version:"1.5.0"};s.guid="$BAIDU$",function(){window[s.guid]=window[s.guid]||{},s.lang=s.lang||{},s.lang.isString=function(t){return"[object String]"==Object.prototype.toString.call(t)},s.lang.Event=function(t,e){this.type=t,this.returnValue=!0,this.target=e||null,this.currentTarget=null},s.object=s.object||{},s.extend=s.object.extend=function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t},s.event=s.event||{},s.event._listeners=s.event._listeners||[],s.dom=s.dom||{},s.dom._g=function(t){return s.lang.isString(t)?document.getElementById(t):t},s._g=s.dom._g,s.event.on=function(t,e,i){e=e.replace(/^on/i,""),t=s.dom._g(t);var n,o=function(e){i.call(t,e)},a=s.event._listeners,r=s.event._eventFilter,h=e;return e=e.toLowerCase(),r&&r[e]&&(n=r[e](t,e,o),h=n.type,o=n.listener),t.addEventListener?t.addEventListener(h,o,!1):t.attachEvent&&t.attachEvent("on"+h,o),a[a.length]=[t,e,i,o,h],t},s.on=s.event.on,s.event.un=function(t,e,i){t=s.dom._g(t),e=e.replace(/^on/i,"").toLowerCase();for(var n,o,a,r=s.event._listeners,h=r.length,d=!i;h--;)n=r[h],n[1]!==e||n[0]!==t||!d&&n[2]!==i||(o=n[4],a=n[3],t.removeEventListener?t.removeEventListener(o,a,!1):t.detachEvent&&t.detachEvent("on"+o,a),r.splice(h,1));return t},s.un=s.event.un,s.dom.g=function(t){return"string"==typeof t||t instanceof String?document.getElementById(t):t&&t.nodeName&&(1==t.nodeType||9==t.nodeType)?t:null},s.g=s.G=s.dom.g,s.string=s.string||{},s.browser=s.browser||{},s.browser.ie=s.ie=/msie (\d+\.\d+)/i.test(navigator.userAgent)?document.documentMode||+RegExp.$1:void 0,s.dom._NAME_ATTRS=function(){var t={cellpadding:"cellPadding",cellspacing:"cellSpacing",colspan:"colSpan",rowspan:"rowSpan",valign:"vAlign",usemap:"useMap",frameborder:"frameBorder"};return s.browser.ie<8?(t["for"]="htmlFor",t["class"]="className"):(t.htmlFor="for",t.className="class"),t}(),s.dom.setAttr=function(t,e,i){return t=s.dom.g(t),"style"==e?t.style.cssText=i:(e=s.dom._NAME_ATTRS[e]||e,t.setAttribute(e,i)),t},s.setAttr=s.dom.setAttr,s.dom.setAttrs=function(t,e){t=s.dom.g(t);for(var i in e)s.dom.setAttr(t,i,e[i]);return t},s.setAttrs=s.dom.setAttrs,s.dom.create=function(t,e){var i=document.createElement(t),n=e||{};return s.dom.setAttrs(i,n)},s.cookie=s.cookie||{},s.cookie._isValidKey=function(t){return new RegExp('^[^\\x00-\\x20\\x7f\\(\\)<>@,;:\\\\\\"\\[\\]\\?=\\{\\}\\/\\u0080-\\uffff]+$').test(t)},s.cookie.getRaw=function(t){if(s.cookie._isValidKey(t)){var e=new RegExp("(^| )"+t+"=([^;]*)(;|$)"),i=e.exec(document.cookie);if(i)return i[2]||null}return null},s.cookie.get=function(t){var e=s.cookie.getRaw(t);return"string"==typeof e?e=decodeURIComponent(e):null},s.cookie.setRaw=function(t,e,i){if(s.cookie._isValidKey(t)){i=i||{};var n=i.expires;"number"==typeof i.expires&&(n=new Date,n.setTime(n.getTime()+i.expires)),document.cookie=t+"="+e+(i.path?"; path="+i.path:"")+(n?"; expires="+n.toGMTString():"")+(i.domain?"; domain="+i.domain:"")+(i.secure?"; secure":"")}},s.cookie.set=function(t,e,i){s.cookie.setRaw(t,encodeURIComponent(e),i)},s.cookie.remove=function(t,e){e=e||{},e.expires=new Date(0),s.cookie.setRaw(t,"",e)},s.isPhone=function(t){return/\d{11}/.test(t)},s.isActivateCode=function(t){return/\d{4}/.test(t)},n.undope=!0}();var o=BMapLib.SearchInfoWindow=function(t,e,i){this.guid=r++,BMapLib.SearchInfoWindow.instance[this.guid]=this,this._isOpen=!1,this._map=t,this._opts=i=i||{},this._content=e||"",this._opts.width=i.width,this._opts.height=i.height,this._opts._title=i.title||"",this._opts.offset=i.offset||new BMap.Size(0,0),this._opts.enableAutoPan=i.enableAutoPan===!1?!1:!0,this._opts._panel=i.panel||null,this._opts._searchTypes=i.searchTypes,this._opts.enableSendToPhone=i.enableSendToPhone};o.prototype=new BMap.Overlay,o.prototype.initialize=function(t){this._closeOtherSearchInfo();var e=this,i=this._createSearchTemplate(),n=t.getPanes().floatPane;return n.style.width="auto",n.appendChild(i),this._initSearchTemplate(),this._getSearchInfoWindowSize(),this._boxWidth=parseInt(this.container.offsetWidth,10),this._boxHeight=parseInt(this.container.offsetHeight,10),s.event.on(i,"onmousedown",function(t){e._stopBubble(t)}),s.event.on(i,"ontouchstart",function(t){e._stopBubble(t)}),s.event.on(i,"touchmove",function(t){e._stopBubble(t)}),s.event.on(i,"touchend",function(t){e._stopBubble(t)}),s.event.on(i,"onmouseover",function(t){e._stopBubble(t)}),s.event.on(i,"click",function(t){e._stopBubble(t)}),s.event.on(i,"dblclick",function(t){e._stopBubble(t)}),i},o.prototype.draw=function(){this._isOpen&&this._adjustPosition(this._point)},o.prototype.open=function(t){this._map.closeInfoWindow();var e,i=this;this._isOpen||(this._map.addOverlay(this),this._isOpen=!0,setTimeout(function(){i._dispatchEvent(i,"open",{point:i._point})},10)),t instanceof BMap.Point?(e=t,this._removeMarkerEvt(),this._marker=null):t instanceof BMap.Marker&&(this._marker&&this._removeMarkerEvt(),e=t.getPosition(),this._marker=t,!this._markerDragend&&this._marker.addEventListener("dragend",this._markerDragend=function(t){i._point=t.point,i._adjustPosition(i._point),i._panBox(),i.show()}),!this._markerDragging&&this._marker.addEventListener("dragging",this._markerDragging=function(){i.hide(),i._point=i._marker.getPosition(),i._adjustPosition(i._point)})),this.show(),this._point=e,this._panBox(),this._adjustPosition(this._point)},o.prototype.close=function(){this._isOpen&&(this._map.removeOverlay(this),this._disposeAutoComplete(),this._isOpen=!1,this._dispatchEvent(this,"close",{point:this._point}))},o.prototype.enableAutoPan=function(){this._opts.enableAutoPan=!0},o.prototype.disableAutoPan=function(){this._opts.enableAutoPan=!1},o.prototype.setContent=function(t){this._setContent(t),this._getSearchInfoWindowSize(),this._adjustPosition(this._point)},o.prototype.setTitle=function(t){this.dom.title.innerHTML=t,this._opts._title=t},o.prototype.getContent=function(){return this.dom.content.innerHTML},o.prototype.getTitle=function(){return this.dom.title.innerHTML},o.prototype.setPosition=function(t){this._point=t,this._adjustPosition(t),this._panBox(),this._removeMarkerEvt()},o.prototype.getPosition=function(){return this._point},o.prototype.getOffset=function(){return this._opts.offset},s.object.extend(o.prototype,{_closeOtherSearchInfo:function(){for(var t=BMapLib.SearchInfoWindow.instance,e=t.length;e--;)t[e]._isOpen&&t[e].close()},_setContent:function(t){if(this.dom&&this.dom.content){"undefined"==typeof t.nodeType?this.dom.content.innerHTML=t:this.dom.content.appendChild(t);var e=this;e._adjustContainerWidth(),this._content=t}},_adjustPosition:function(t){var e=this._getPointPosition(t),i=this._marker&&this._marker.getIcon();this._marker?(this.container.style.bottom=-(e.y-this._opts.offset.height-i.anchor.height+i.infoWindowAnchor.height)-this._marker.getOffset().height+2+30+"px",this.container.style.left=e.x-i.anchor.width+this._marker.getOffset().width+i.infoWindowAnchor.width-this._boxWidth/2+28+"px"):(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(t){return this._pointPosition=this._map.pointToOverlayPixel(t),this._pointPosition},_getSearchInfoWindowSize:function(){this._boxWidth=parseInt(this.container.offsetWidth,10),this._boxHeight=parseInt(this.container.offsetHeight,10)},_stopBubble:function(t){t&&t.stopPropagation?t.stopPropagation():window.event.cancelBubble=!0},_panBox:function(){if(this._opts.enableAutoPan){var t=parseInt(this._map.getContainer().offsetHeight,10),e=parseInt(this._map.getContainer().offsetWidth,10),i=this._boxHeight,n=this._boxWidth;if(!(i>=t||n>=e)){this._map.getBounds().containsPoint(this._point)||this._map.setCenter(this._point);var s,o,a=this._map.pointToPixel(this._point),r=n/2-28-a.x+10,h=n/2+28+a.x-e+10;if(this._marker)var d=this._marker.getIcon();var c=this._marker?d.anchor.height+this._marker.getOffset().height-d.infoWindowAnchor.height:0;s=i-a.y+this._opts.offset.height+c+31+10,panX=r>0?r:h>0?-h:0,o=s>0?s:0,this._map.panBy(panX,o)}}},_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(t,e,i){0!=e.indexOf("on")&&(e="on"+e);var n=new s.lang.Event(e);if(i)for(var o in i)n[o]=i[o];t.dispatchEvent(n)},_initSearchTemplate:function(){this._initDom(),this._initPanelTemplate(),this.setTitle(this._opts._title),this._opts.height&&(this.dom.content.style.height=parseInt(this._opts.height,10)+"px"),this._setContent(this._content),this._initService(),this._bind(),this._opts._searchTypes&&this._setSearchTypes(),this._mendIE6()},_createSearchTemplate:function(){if(!this._div){var t=s.dom.create("div",{"class":"BMapLib_SearchInfoWindow",id:"BMapLib_SearchInfoWindow"+this.guid}),e=['
鍙戦€佹柟鎵嬫満鍙饵/th>",' | '," |
---|---|
"," | "," | ","
鎺ユ敹鏂规墜鏈哄彿 | ','璁颁綇姝ゅ彿 ','',''," | ","
",' | '," |
",' | '," |
鐧惧害淇濊瘉涓嶅悜浠讳綍绗笁鏂规彁渚涜緭鍏ョ殑鎵嬫満鍙风爜
',' ",' ",'',' '].join("");return t.innerHTML=s,t},initDom:function(){this.dom={sms_tip:s.g("BMapLib_sms_tip"),activate_btn:s.g("BMapLib_activate_btn"),fromphone:s.g("BMapLib_phone_0"),tophone:s.g("BMapLib_phone_1"),isRememberPhone:s.g("BMapLib_is_remember_phone"),sms_container:s.g("BMapLib_sms_pnl_phone"),success_tip:s.g("BMapLib_success_tip"),add_phone_con:s.g("BMapLib_add_phone_con"),add_phone_btn:s.g("BMapLib_add_phone_btn"),activateBox:s.g("BMapLib_activateBox"),activateTip:s.g("BMapLib_activateTip"),activate_input:s.g("BMapLib_activate"),ver_image:s.g("BMapLib_ver_image"),ver_input:s.g("BMapLib_ver_input")}},showTip:function(t){var e=t.error,i={PHONE_NUM_INVALID:"鎵嬫満鍙风爜鏃犳晥",SMS_SEND_SUCCESS:"鍙戦€佸埌鎵嬫満鎴愬姛",AK_INVALID:"浣犳墍浣跨敤鐨刱ey鏃犳晥",INTERNAL_ERROR:"鏈嶅姟鍣ㄩ敊璇?,OVER_MAX_ACTIVATE_TIME:"浠婂ぉ宸茶秴杩囧彂閫佹縺娲荤爜鏈€澶ф鏁?,SMS_ACTIVATE_SUCCESS:"婵€娲荤爜宸插彂閫佸埌鎮ㄧ殑鎵嬫満锛岃娉ㄦ剰鏌ユ敹锛?,ACTIVATE_FAIL:"鎵嬫満婵€娲荤爜鏃犳晥",SMS_LACK:"浠婂ぉ鎮ㄨ繕鑳藉線5涓墜鏈哄彂閫佺煭淇?,PARAM_INVALID:"璇峰~瀹屾墍鏈夐€夐」",SEND_ACTIVATE_FAIL:"婵€娲荤爜鍙戦€佸け璐?,VCODE_VERITY_FAIL:"楠岃瘉鐮佹牎楠屽け璐?},n=i[e];if("SMS_LACK"==e){var s=t.res_sms;n="浠婂ぉ鎮ㄨ繕鑳藉線"+s+"涓墜鏈哄彂閫佺煭淇?,this.addPhoneNum=s-1}this.renderImageVer(),n&&(this.dom.sms_tip.innerHTML=n,this.dom.sms_tip.style.display="inline"),"SMS_SEND_SUCCESS"==e&&(this.rememberPhone(),this.sendSuccess())},bind:function(){var t=this;t.renderImageVer(),s.on(this.container,"click",function(e){var i=e.target||e.srcElement,n=i.getAttribute("bid");switch(n){case"close":t.closeActon();break;case"sendToPhoneBtn":t.sendAction();break;case"activate":t.activateAction();break;case"addPhone":t.addPhoneAction();break;case"deletePhone":t.deletePhoneAction(i);break;case"BMapLib_ver_image":t.renderImageVer()}});s.g("BMapLib_phone_0"),s.g("BMapLib_phone_1");this.container.onkeypress=function(t){var e=t||window.e,i=e.which||e.keyCode,n=!1;return(i>=48&&57>=i||44==i||8==i)&&(n=!0),n},this.dom.ver_input.onkeypress=function(e){t._stopBubble(e);var i=e||window.e,n=i.which||i.keyCode,s=!1;return(n>=48&&57>=n||n>=65&&90>=n||n>=97&&122>=n)&&(s=!0),s},s.on(this.dom.fromphone,"blur",function(){s.isPhone(this.value)?t.checkActivateAction():(t.dom.activateTip.innerHTML="",t.dom.activateBox.style.display="none")}),s.on(this.dom.activate_input,"blur",function(){s.isActivateCode(this.value)&&t.checkActivateAction()})},_stopBubble:function(t){t&&t.stopPropagation?t.stopPropagation():window.event.cancelBubble=!0},renderImageVer:function(){var t=this;this.request("http://map.baidu.com/maps/services/captcha?",{cbName:"cb"},function(e){t.vcode=e.content.vcode,t.dom.ver_image.src="http://map.baidu.com/maps/services/captcha/image?vcode="+t.vcode})},checkActivateAction:function(){var t={phone:this.dom.fromphone.value,activate:this.dom.activate_input.value,cbName:"callback"},e=this;this.request(this.config.ckActivateURL,t,function(t){t&&0!=t.isactivate?(e.dom.activateBox.style.display="none",e.dom.activateTip.style.color="green",e.dom.activateTip.innerHTML="宸叉縺娲?):(e.dom.activateBox.style.display="table-row",e.dom.activateTip.style.color="red",e.dom.activateTip.innerHTML="鏈縺娲?)})},activateAction:function(){var t=this,e=this._map.getKey(),i={phone:this.dom.fromphone.value,ak:e,cbName:"callback"};s.isPhone(i.phone)?this.request(this.config.activateURL,i,function(e){e&&t.showTip(e)}):this.showTip({error:"PHONE_NUM_INVALID"})},closeActon:function(){this._map.removeOverlay(this)},getMessage:function(){},sendAction:function(){var t=this;if(this.validate()){tophoneStr=s.g("BMapLib_phone_1").value;for(var e=this.dom.add_phone_con.getElementsByTagName("input"),i=0,n=e.length;n>i;i++){if(!s.isPhone(e[i].value))return void this.showTip({error:"PHONE_NUM_INVALID"});tophoneStr+=","+e[i].value}var o=this._map.getKey(),a={fromphone:s.g("BMapLib_phone_0").value,tophone:tophoneStr,ak:o,activate:this.dom.activate_input.value,code_input:this.dom.ver_input.value,vcode:this.vcode,content:s.g("BMapLib_phone_0").value+"鍒嗕韩涓€涓綅缃粰鎮紝"+this.messageContent,cbName:"callback"};this.request(this.config.sendURL,a,function(e){e&&t.showTip(e)})}},validate:function(){var t=!0;return s.isPhone(this.dom.fromphone.value)&&s.isPhone(this.dom.tophone.value)||(t=!1,this.showTip({error:"PHONE_NUM_INVALID"})),t},getAddressByPoint:function(){var t=this.iw._point,e=this,i=new BMap.Geocoder;i.getLocation(t,function(t){if(t&&t.addressComponents){var i=t.addressComponents;e.address=i.province+i.city+i.district+i.street+i.streetNumber,e.generalMessage()}})},generalMessage:function(){var t=s.g("BMapLib_msgContent"),e="",i=this.iw,n=i.getPosition();this.userPhone&&(e+=this.userPhone+"鍒嗕韩涓€涓綅缃粰鎮紝"),i.getTitle&&(e+="鍚嶇О涓猴細"+i.getTitle()+"锛?),this.address&&(e+="澶ц嚧浣嶇疆鍦?+this.address+"锛?);var o="http://api.map.baidu.com/marker?location="+n.lat+","+n.lng+"&title="+encodeURIComponent(i.getTitle())+"&content="+encodeURIComponent(i.getContent())+"&output=html",a={url:encodeURIComponent(o),t:(new Date).getTime(),cbName:"callback"},r=this;this.request(this.config.shortURL,a,function(i){e+=i.url,r.messageContent=e,t.innerHTML=e})},rememberPhone:function(){if(this.dom.isRememberPhone.checked){var t=this.dom.tophone.value;s.cookie.set("BMapLib_phone",t,{path:"/",expires:2592e6})}},getRememberPhone:function(){var t=s.cookie.get("BMapLib_phone");t&&(this.dom.tophone.value=t,this.dom.isRememberPhone.checked=!0)},sendSuccess:function(){this.dom.sms_container.style.display="none",this.dom.success_tip.style.display="block";var t=this;setTimeout(function(){t._map.removeOverlay(t)},1500)},addPhoneAction:function(){if(this.addPhoneNum>=4);else{var t=document.createElement("div");t.innerHTML='鍒犻櫎',this.dom.add_phone_con.appendChild(t),this.addPhoneNum++}},deletePhoneAction:function(t){t.parentNode.parentNode.removeChild(t.parentNode),this.addPhoneNum-- },request:function(t,e,n){var s=(1e5*Math.random()).toFixed(0);BMapLib["BMapLib_cbk"+s]=function(t){n&&n(t),delete BMapLib["BMapLib_cbk"+s]};for(var o in e)"cbName"!=o&&(t+="&"+o+"="+e[o]);t+="&"+e.cbName+"=BMapLib.BMapLib_cbk"+s,i(t)},config:{sendURL:a+"/ws/message?method=send",activateURL:a+"/ws/message?method=activate",ckActivateURL:a+"/ws/message?method=ckActivate",shortURL:"http://j.map.baidu.com/?"}});var r=0;BMapLib.SearchInfoWindow.instance=[]}();