var BMapLib=window.BMapLib=BMapLib||{};!function(){var T,baidu=T=baidu||{version:"1.3.9"};baidu.guid="$BAIDU$",baidu.dom=baidu.dom||{},baidu.event=baidu.event||{},baidu.lang=baidu.lang||{},baidu.browser=baidu.browser||{},baidu.dom.addClass=function(element,className){element=baidu.dom.g(element);for(var classArray=className.split(/\s+/),result=element.className,classMatch=" "+result+" ",i=0,l=classArray.length;i
瀹炴椂璺喌
鍫�缂�鐣�
');var viewPreDom=baidu.g("tcViewPrediction"),dvPredition=baidu.g("tcPredition"),dvTcTitle=baidu.g("tcTitle"),dvTcDay=baidu.g("maplibTcDay"),dvTcNow=baidu.g("tcNow"),dvTcWrap=baidu.g("tcWrap"),dvTcTimeBox=baidu.g("tcTimeBox"),dvTcUpdate=baidu.g("tcUpdate"),weekName=["涓€","浜�","涓�","鍥�","浜�","鍏�","鏃�"],timeline=new setBar(me);this.show=function(){initialize(),me.bShow=!0,baidu.dom.removeClass(btn,"maplibTcBtnOff"+stylePrefix)},this.hide=function(){me.bShow=!1,baidu.dom.addClass(btn,"maplibTcBtnOff"+stylePrefix),baidu.isMobile()?baidu.dom.addClass("tcWrap_mobile","maplibTfctrHide"):(baidu.dom.addClass("tcWrap","maplibTcHide"),baidu.dom.addClass("tcPredition","maplibTcHide")),me.hideTraffic()},this.isbShow=function(){return me.bShow},this.setPopOffset=function(size){var controlHeight=24,offsetH=size.height+24+"px",offsetW=size.width+"px";switch(me.getAnchor()){case BMAP_ANCHOR_TOP_LEFT:dvTcWrap.style.top=offsetH,dvTcWrap.style.left=offsetW;break;case BMAP_ANCHOR_TOP_RIGHT:dvTcWrap.style.top=offsetH,dvTcWrap.style.right=offsetW;break;case BMAP_ANCHOR_BOTTOM_RIGHT:dvTcWrap.style.bottom=offsetH,dvTcWrap.style.right=offsetW;break;case BMAP_ANCHOR_BOTTOM_LEFT:dvTcWrap.style.bottom=offsetH,dvTcWrap.style.left=offsetW}};var eventName=baidu.isMobile()?"ontouchend":"onclick";function showOrHidePopDiv(){thisPop.isbShow()?thisPop.hide():(thisPop.setPopOffset(me.getOffset()),thisPop.show())}function initialize(){dvTcDay.innerHTML="鏇存柊鏃堕棿",dvTcTitle.innerHTML=arrPredictionTxt[1],viewPreDom.innerHTML=arrPredictionTxt[0],baidu.dom.addClass(dvPredition,"maplibTcHide"),dvTcUpdate.style.display="block",bRealTime=!0,baidu.isMobile()?me.showPanel&&baidu.dom.removeClass("tcWrap_mobile","maplibTfctrHide"):baidu.dom.removeClass("tcWrap","maplibTcHide");for(var arrA=baidu.g("tcWeek").getElementsByTagName("a"),i=0;i<7;i++)arrA[i].className="";var curTimeUrl="https://itsmap2.baidu.com/traffic/GetCurrentTime?callback=BMapLib.TrafficControl.getTime&";function callback(){var t=TrafficControl.curTime,tHour=t.getHours();thisPop._bind||(bindEventToPopDiv(me),bindEventToWeek(me),thisPop._bind=!0);var time=(tHour<10?"0"+tHour:tHour)+":"+(t.getMinutes()<10?"0"+t.getMinutes():t.getMinutes());dvTcNow.innerHTML=time,me.hour=tHour,me.weekday=0==t.getDay()?7:t.getDay(),me.time=time,timeline.setBarTime(tHour)}scriptRequest(curTimeUrl+(new Date).getTime(),callback),me.timer&&clearInterval(me.timer),me.timer=setInterval((function(){scriptRequest(curTimeUrl+(new Date).getTime(),(function(){if(me.bShow){var t=TrafficControl.curTime,tHour=t.getHours(),time=(tHour<10?"0"+tHour:tHour)+":"+(t.getMinutes()<10?"0"+t.getMinutes():t.getMinutes());dvTcNow.innerHTML=time,me.hideTraffic(),me.showTraffic()}}))}),18e4)}function genHtml_mobile(){return'
瀹炴椂璺喌
鍫�缂�鐣�
'}function genHtml(){var html=['
'];return html.push('
瀹炴椂璺喌
'),html.push('
'),html.push('
鏇存柊鏃堕棿锛�  鏌ョ湅娴侀噺棰勬祴
'),html.push('
'),html.push(''),html.push('
鏃堕棿
'),html.push('
'),html.push('
20:00
'),html.push('
'),html.push('
'),html.push('
'),html.push('
'),html.push("
"),html.push('
锛堝熀浜庡巻鍙叉祦閲忕粺璁¢娴� 浠呬緵鍙傝€冿級
'),html.push("
"),html.join("")}function bindEventToPopDiv(me){function showPrediction(){me.timer&&clearInterval(me.timer),dvTcTitle.innerHTML=arrRealTimeTxt[1],viewPreDom.innerHTML=arrRealTimeTxt[0],baidu.dom.removeClass(dvPredition,"maplibTcHide"),dvTcUpdate.style.display="none",bRealTime=!1,dvTcDay.innerHTML="鏄熸湡"+weekName[me.weekday-1],dvTcNow.innerHTML=dvTcTimeBox.innerHTML,me.showTraffic({predictDate:{hour:me.hour,weekday:me.weekday}})}baidu.event.on("tcViewPrediction","click",(function(){bRealTime?showPrediction():initialize()})),baidu.event.on("tcUpdate","click",(function(){initialize()}))}function updateTimeTxt(){dvTcDay.innerHTML="鏄熸湡"+weekName[me.weekday-1],dvTcNow.innerHTML=dvTcTimeBox.innerHTML}function bindEventToWeek(me){baidu.event.on("tcWeek","onclick",(function(e){var elem=e.target||e.srcElement;if("a"==elem.tagName.toLowerCase()){for(var arrA=baidu.g("tcWeek").getElementsByTagName("a"),i=0;i<7;i++)arrA[i].className="";baidu.dom.addClass(elem,"maplibTcOn"),me.weekday=parseInt(attr(elem,"lang"),10),updateTimeTxt(),me.showTraffic({predictDate:{hour:me.hour,weekday:me.weekday}})}}))}function setBar(me){var hour,bt=baidu.g("tcMove");function dragStart(e){return baidu.on(document,"onmousemove",dragIng),baidu.on(document,"onmouseup",dragEnd),e&&e.preventDefault?e.preventDefault():window.event.returnValue=!1,!1}function dragIng(e){var x,left,margin=(e.clientX||e.x)-(getPosition(baidu.G("tcPrev")).left+9)-4;margin<0&&(margin=0),margin>165&&(margin=165),baidu.browser.ie<=6?bt.style.marginLeft=.53*margin+"px":bt.style.marginLeft=margin+"px",dvTcTimeBox.style.marginLeft=margin+"px",setTimeBox()}function dragEnd(){baidu.un(document,"onmousemove",dragIng),baidu.un(document,"onmouseup",dragEnd),me.showTraffic({predictDate:{hour:me.hour,weekday:me.weekday}})}function setBarBtn(key){var box=dvTcTimeBox,margin=parseInt(baidu.dom.getStyle("tcTimeBox","marginLeft")),n=Math.ceil(24*(margin-4)/165);setBarTime("next"==key?n+1:n-1)}function setBarTime(n){n<0&&(n=0),n>24&&(n=24),hour=n;var margin=6.875*n;dvTcTimeBox.style.marginLeft=margin+"px";var bt=baidu.g("tcMove");baidu.browser.ie<=6&&baidu.browser.ie>0?bt.style.marginLeft=.53*margin+"px":bt.style.marginLeft=margin+"px",me.hour=hour,bRealTime?me.showTraffic():me.showTraffic({predictDate:{hour:me.hour,weekday:me.weekday}}),setTimeBox()}function setTimeBox(){var margin=parseInt(dvTcTimeBox.style.marginLeft),n=Math.ceil(24*(margin-4)/165);hour=n,me.hour=n,n<10&&(n="0"+n),bRealTime?(dvTcNow.innerHTML=me.time,dvTcTimeBox.innerHTML=n+":00"):dvTcNow.innerHTML=dvTcTimeBox.innerHTML=n+":00"}baidu.on(bt,"onmousedown",dragStart),baidu.on("tcPrev","click",(function(){setBarBtn("prev")})),baidu.on("tcNext","click",(function(){setBarBtn("next")})),this.setBarTime=function(n){setBarTime(n)}}baidu.event.on(btn,eventName,(function(){showOrHidePopDiv()})),baidu.event.on("tcClose","click",(function(e){showOrHidePopDiv()}))},TrafficControl.prototype.showTraffic=function(predictDate){var trafficLayer;if(this._trafficLayer&&this._map.removeTileLayer(this._trafficLayer),predictDate){if(predictDate.predictDate.weekday>7||predictDate.predictDate.weekday<1)return;trafficLayer=new BMap.TrafficLayer(predictDate)}else trafficLayer=new BMap.TrafficLayer;this.bShow=!0,baidu.isMobile()&&baidu.dom.removeClass(this.btn,"maplibTcBtnOff"+stylePrefix),this._map.addTileLayer(trafficLayer),this._trafficLayer=trafficLayer},TrafficControl.prototype.hideTraffic=function(){this.bShow=!1,this._trafficLayer&&(this._map.removeTileLayer(this._trafficLayer),this._trafficLayer=null),baidu.isMobile()&&baidu.dom.addClass(this.btn,"maplibTcBtnOff"+stylePrefix)},TrafficControl.prototype.remove=function(){this.hideTraffic();var dvWrap=baidu.g("tcWrap");dvWrap.parentNode.removeChild(dvWrap),BMap.Control.prototype.remove.call(this),this.timer&&clearInterval(this.timer)},TrafficControl.getTime=function(dtNow){this.curTime=isNaN(dtNow)?new Date:new Date(dtNow)}}();