var BMapLib = window.BMapLib = BMapLib || {}; (function () { var c, a = c = a || { version: "1.3.9" }; a.guid = "$BAIDU$"; (function () { a.dom = a.dom || {}; a.event = a.event || {}; a.lang = a.lang || {}; a.browser = a.browser || {}; a.dom.addClass = function (p, q) { p = a.dom.g(p); var k = q.split(/\s+/), j = p.className, o = " " + j + " ", n = 0, m = k.length; for (; n < m; n++) { if (o.indexOf(" " + k[n] + " ") < 0) { j += (j ? " " : "") + k[n] } } p.className = j; return p }; a.addClass = a.dom.addClass; a.dom.removeClass = function (p, q) { p = a.dom.g(p); var n = p.className.split(/\s+/), r = q.split(/\s+/), l, k = r.length, m, o = 0; for (; o < k; ++o) { for (m = 0, l = n.length; m < l; ++m) { if (n[m] == r[o]) { n.splice(m, 1); break } } } p.className = n.join(" "); return p }; a.removeClass = a.dom.removeClass; a.dom.getComputedStyle = function (k, j) { k = a.dom._g(k); var m = a.dom.getDocument(k), l; if (m.defaultView && m.defaultView.getComputedStyle) { l = m.defaultView.getComputedStyle(k, null); if (l) { return l[j] || l.getPropertyValue(j) } } return "" }; a.dom.getStyle = function (k, j) { var m = a.dom; k = m.g(k); var l = k.style[j] || (k.currentStyle ? k.currentStyle[j] : "") || m.getComputedStyle(k, j); return l }; a.getStyle = a.dom.getStyle; a.dom.getDocument = function (j) { j = a.dom.g(j); return j.nodeType == 9 ? j : j.ownerDocument || j.document }; a.dom.g = function (j) { if ("string" == typeof j || j instanceof String) { return document.getElementById(j) } else { if (j && j.nodeName && (j.nodeType == 1 || j.nodeType == 9)) { return j } } return null }; a.g = a.G = a.dom.g; a.dom._g = function (j) { if (a.lang.isString(j)) { return document.getElementById(j) } return j }; a._g = a.dom._g; a.lang.isString = function (j) { return "[object String]" == Object.prototype.toString.call(j) }; a.isString = a.lang.isString; a.event._listeners = a.event._listeners || []; a.event.on = function (k, n, p) { n = n.replace(/^on/i, ""); k = a.dom._g(k); var o = function (r) { p.call(k, r) }, j = a.event._listeners, m = a.event._eventFilter, q, l = n; n = n.toLowerCase(); if (m && m[n]) { q = m[n](k, n, o); l = q.type; o = q.listener } if (k.addEventListener) { k.addEventListener(l, o, false) } else { if (k.attachEvent) { k.attachEvent("on" + l, o) } } j[j.length] = [k, n, p, o, l]; return k }; a.on = a.event.on; a.event.un = function (l, o, k) { l = a.dom._g(l); o = o.replace(/^on/i, "").toLowerCase(); var r = a.event._listeners, m = r.length, n = !k, q, p, j; while (m--) { q = r[m]; if (q[1] === o && q[0] === l && (n || q[2] === k)) { p = q[4]; j = q[3]; if (l.removeEventListener) { l.removeEventListener(p, j, false) } else { if (l.detachEvent) { l.detachEvent("on" + p, j) } } r.splice(m, 1) } } return l }; a.un = a.event.un; if (/msie (\d+\.\d)/i.test(navigator.userAgent)) { a.browser.ie = a.ie = document.documentMode || +RegExp["\x241"] } a.platform = a.platform || {}; a.platform.isIphone = /iphone/i.test(navigator.userAgent); a.platform.isAndroid = /android/i.test(navigator.userAgent); a.platform.isIpad = /ipad/i.test(navigator.userAgent); a.isMobile = function () { return !!(a.platform.isIphone || a.platform.isIpad || a.platform.isAndroid) } })(); var h = a.isMobile() ? "_mobile" : "_deskTop"; var g = BMapLib.TrafficControl = function (j) { this.defaultAnchor = BMAP_ANCHOR_TOP_RIGHT; this.defaultOffset = new BMap.Size(10, 10); this.showPanel = j && j.showPanel }; g.prototype = new BMap.Control(); g.prototype.initialize = function (l) { var j = d("div", { title: "显示交通流量", id: "tcBtn", "class": "maplibTcBtn" + h + " maplibTcBtnOff" + h }); l.getContainer().appendChild(j); this._map = l; this._popUpDiv(this, j); var k = this; this.btn = j; return j }; g.prototype._popUpDiv = function (F, w) { var F = this; var x = ["查看实时路况", "流量预测"]; var l = ["查看流量预测", "实时路况"]; var A = true; this.bShow = false; var D = this; D._bind = false; b(w, "afterEnd", u()); b(w, "afterEnd", H()); var B = a.g("tcViewPrediction"); var t = a.g("tcPredition"); var G = a.g("tcTitle"); var n = a.g("maplibTcDay"); var y = a.g("tcNow"); var p = a.g("tcWrap"); var v = a.g("tcTimeBox"); var z = a.g("tcUpdate"); var j = ["一", "二", "三", "四", "五", "六", "日"]; var s = new E(F); this.show = function () { k(); F.bShow = true; a.dom.removeClass(w, "maplibTcBtnOff" + h) }; this.hide = function () { F.bShow = false; a.dom.addClass(w, "maplibTcBtnOff" + h); if (a.isMobile()) { a.dom.addClass("tcWrap_mobile", "maplibTfctrHide") } else { a.dom.addClass("tcWrap", "maplibTcHide"); a.dom.addClass("tcPredition", "maplibTcHide") } F.hideTraffic() }; this.isbShow = function () { return F.bShow }; this.setPopOffset = function (J) { var L = 24; var K = J.height + L + "px"; var I = J.width + "px"; switch (F.getAnchor()) { case BMAP_ANCHOR_TOP_LEFT: p.style.top = K; p.style.left = I; break; case BMAP_ANCHOR_TOP_RIGHT: p.style.top = K; p.style.right = I; break; case BMAP_ANCHOR_BOTTOM_RIGHT: p.style.bottom = K; p.style.right = I; break; case BMAP_ANCHOR_BOTTOM_LEFT: p.style.bottom = K; p.style.left = I; break } }; var r = a.isMobile() ? "ontouchend" : "onclick"; a.event.on(w, r, function () { o() }); a.event.on("tcClose", "click", function (I) { o() }); function o() { if (!D.isbShow()) { D.setPopOffset(F.getOffset()); D.show() } else { D.hide() } } function k() { n.innerHTML = "更新时间"; G.innerHTML = l[1]; B.innerHTML = l[0]; a.dom.addClass(t, "maplibTcHide"); z.style.display = "block"; A = true; if (a.isMobile()) { if (F.showPanel) { a.dom.removeClass("tcWrap_mobile", "maplibTfctrHide") } } else { a.dom.removeClass("tcWrap", "maplibTcHide") } var K = a.g("tcWeek").getElementsByTagName("a"); for (var J = 0; J < 7; J++) { K[J].className = "" } var I = "http://its.map.baidu.com:8002/traffic/GetCurrentTime?callback=BMapLib.TrafficControl.getTime&"; e(I + (new Date()).getTime(), L); if (F.timer) { clearInterval(F.timer) } F.timer = setInterval(function () { e(I + (new Date()).getTime(), function () { if (F.bShow) { var N = g.curTime; var M = N.getHours(); var O = (M < 10 ? ("0" + M) : M) + ":" + (N.getMinutes() < 10 ? ("0" + N.getMinutes()) : N.getMinutes()); y.innerHTML = O; F.hideTraffic(); F.showTraffic() } }) }, 1000 * 3 * 60); function L() { var N = g.curTime; var M = N.getHours(); if (!D._bind) { C(F); m(F); D._bind = true } var O = (M < 10 ? ("0" + M) : M) + ":" + (N.getMinutes() < 10 ? ("0" + N.getMinutes()) : N.getMinutes()); y.innerHTML = O; F.hour = M; F.weekday = N.getDay() == 0 ? 7 : N.getDay(); F.time = O; s.setBarTime(M) } } function H() { return '