Skip to content

Instantly share code, notes, and snippets.

@jayzeng
Created March 23, 2011 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jayzeng/883776 to your computer and use it in GitHub Desktop.
Save jayzeng/883776 to your computer and use it in GitHub Desktop.
bing map
window.Microsoft = window.Microsoft || {};
window.Microsoft.Maps = window.Microsoft.Maps || {};
window.Microsoft.Maps.initMapDelayCode = function () {
var K = 'Invalid Credentials. Sign up for a developer account at: <a href="http://www.microsoft.com/maps/developers">http://www.microsoft.com/maps/developers</a>',
M = "{num} km",
Y = "{num} m",
ab = "{num} miles",
bb = "{num} yds",
db = "{num} feet",
X = "Click to pan in any direction",
P = "Rotate left",
L = "Rotate right",
cb = "Zoom in",
Z = "Zoom out",
Q = "Move slider to zoom in or out",
N = "N",
U = "Automatic",
F = "Switches to the best map style as you zoom",
V = "Road",
H = "A standard road map, no refolding needed",
O = "Bird's eye",
E = "A map made up of photos taken from the air",
J = "Bird's eye",
C = "A map made up of photos taken from the air",
G = "London Street Map",
B = "Detailed maps for Greater London",
D = "Ordnance Survey Map",
A = "Maps for outdoor life",
S = "show labels",
R = "show angled view",
v = "Search on Bing",
I = "Search on Bing",
T = "Bing Maps",
fb = "World",
d = window.Microsoft.Maps,
a = d.Gimme,
i = d.Globals,
l = d.Point,
r = d.LabelOverlay,
b = d.Events,
x = d.LocationRect,
y = d.Location,
pb = d.Pushpin,
k = d.MapTypeId,
j = d.InternalNamespaceForDelay,
mb = j.Dynamic,
jb = j.DelayMap,
s = j.IdGenerator,
t = j.Network,
o = j.MapMath,
z = j.Quirks,
q = {
auto: {
title: U,
description: F
},
r: {
title: V,
description: H
},
a: {
title: O,
description: E
},
be: {
title: J,
description: C
},
cb: {
title: G,
description: B
},
os: {
title: D,
description: A
}
};
function lb(n, y, z) {
var A = this,
d, h, r, f, g, m, w, c, t = 15,
p, s, q;
d = document.createElement("a");
d.appendChild(document.createTextNode(N));
h = a(d);
d.title = X;
h.add_event("mousedown", i).add_event("mouseup", k).add_event("mousemove", j).add_event("dblclick", e).add_event("touchstart", i).add_event("touchmove", j).add_event("touchend", k);
y.appendChild(d);
s = b.addHandler(n, "targetviewchanged", v);
this.dispose = function () {
if (d) {
h.remove_event("mousedown", i).remove_event("mouseup", k).remove_event("mousemove", j).remove_event("dblclick", e).remove_event("touchstart", i).remove_event("touchmove", j).remove_event("touchend", k);
y.removeChild(d);
d = null;
b.removeHandler(s)
}
};
this.enableRotation = function (a) {
if (a !== p) {
p = a;
if (!a) {
d.className = "NavBar_compass NavBar_compassFlat";
q = null
}
v()
}
};
function v() {
if (p) {
var b = n.getTargetHeading();
if (b !== q) {
var a = "";
switch (o.snapToCardinalHeading(b)) {
case o.northUpHeading:
a = "NavBar_compassN";
break;
case o.eastUpHeading:
a = "NavBar_compassE";
break;
case o.southUpHeading:
a = "NavBar_compassS";
break;
case o.westUpHeading:
a = "NavBar_compassW"
}
d.className = "NavBar_compass " + a;
q = b
}
}
}
function u(d) {
var b = a.Screen.get_mouse_pos(d);
if (isNaN(b.x)) b = new l(d.touches[0].pageX, d.touches[0].pageY);
c = new l(b.x - r.x - f.x, b.y - r.y - f.y);
var e = Math.sqrt(c.x * c.x + c.y * c.y);
if (e < g) {
c.x = c.x / g * t;
c.y = c.y / g * t
}
}
function x() {
if (Math.abs(c.x) <= 1) c.x = 0;
if (Math.abs(c.y) <= 1) c.y = 0;
if (c.x || c.y) {
var a = n.tryPixelToLocation(c);
a && n.setView({
center: a,
animate: false
})
}
}
function i(b) {
e(b);
z.reportAction(b);
f = new l(d.offsetWidth / 2, d.offsetHeight / 2);
g = Math.min(f.x, f.y);
r = h.get_absolute_pos();
a.Events.capture_mouse(d);
u(b);
x();
m = true;
w = window.setInterval(x, 100)
}
function j(a) {
if (m) {
e(a);
u(a)
}
}
function k(b) {
e(b);
if (m) {
window.clearInterval(w);
a.Events.release_mouse();
m = false
}
}
function e(a) {
a.stopPropagation();
a.preventDefault()
}
}
function gb(l, O, x) {
var X = this,
e, n, D, L = document.body,
c, p, d = l.getMapTypeId(),
j = true,
h = true,
u, t, C = k.auto,
K = k.road,
A = k.aerial,
f = k.birdseye,
M = k.collinsBart,
N = k.ordnanceSurvey,
G, F, y = false,
J = new Date(0),
Q = .3;
e = document.createElement("a");
e.href = "#";
e.className = "NavBar_button NavBar_typeButton";
a(e).add_event("click", U).add_event("mouseenter", T).add_event("mouseleave", o).add_event("touchstart", V);
n = document.createElement("span");
n.appendChild(document.createTextNode(""));
D = document.createElement("span");
D.className = "NavBar_dropIcon";
e.appendChild(D);
e.appendChild(n);
G = b.addHandler(l, "maptypechanged", B);
F = b.addHandler(l, "optionschanged", B);
O.appendChild(e);
B();
this.dispose = function () {
if (e) {
v();
b.removeHandler(G);
b.removeHandler(F);
O.removeChild(e);
e = null
}
};
this.getAerialViewSettings = function () {
return {
showLabels: j,
enableTilt: h
}
};
this.setAerialViewSettings = function (b, a) {
j = b;
h = a;
w(d) && g(f)
};
function B() {
var b = l.getOptions();
d = l.getMapTypeId();
if (q.hasOwnProperty(d)) {
var a = q[d];
n.replaceChild(document.createTextNode(a.title), n.firstChild)
}
if (d === A) h = false;
else if (d === f) h = true;
j = b.labelOverlay !== r.hidden
}
function T(a) {
if (!c) J = new Date;
E(a)
}
function E() {
z();
if (!c) {
c = document.createElement("ul");
c.className = "MicrosoftMap_NavBar_typeMenu";
c.style.cssText = "position:absolute;visibility:hidden";
L.appendChild(c);
a(c).add_event("mouseenter", E).add_event("mouseleave", o);
m(c, K, d === K, g);
i.allowCollinsBart && m(c, M, d === M, g);
i.allowOrdnanceSurvey && m(c, N, d === N, g);
m(c, C, d === C, g);
var r = m(c, f, w(d), g);
P(r)
}
if (c.style.visibility === "hidden") {
var k = a(e).get_absolute_pos(),
n = l.getRootElement(),
q = a(n).get_absolute_pos(),
p = n.offsetWidth,
s = c.offsetWidth,
v = k.y + e.offsetHeight,
b = k.x;
b = Math.min(b, q.x + p - s);
c.style.top = v + "px";
c.style.left = b + "px";
c.style.visibility = "visible";
t.checked = h;
u.checked = j
}
}
function w(a) {
return a === A || a === f
}
function U(b) {
if (c) {
var a = new Date;
(a - J) / 1e3 > Q && v()
} else {
x.reportAction(b);
E()
}
}
function o() {
z();
p = window.setTimeout(v, 1e3)
}
function v() {
z();
if (c) {
L.removeChild(c);
c = null
}
}
function z() {
if (p) {
window.clearTimeout(p);
p = null
}
}
function g(a) {
if (a === f) a = h ? f : A;
l.setView({
mapTypeId: a,
labelOverlay: j || a === C ? r.visible : r.hidden
})
}
function V() {
y = true
}
function I(a) {
a.stopPropagation();
x.reportAction(a);
if (a.currentTarget.tagName === "SPAN") u.checked = !j;
j = u.checked;
w(d) && g(f);
y && o()
}
function H(a) {
a.stopPropagation();
x.reportAction(a);
if (a.currentTarget.tagName === "SPAN") t.checked = !h;
h = t.checked;
w(d) && g(f);
y && o()
}
function m(l, c, k, h) {
var b = document.createElement("li"),
i = q[c];
b.className = "NavBar_menuitem" + (k ? " NavBar_menuItemSel" : "");
l.appendChild(b);
if (h) {
var d = document.createElement("div");
d.className = "NavBar_itemContainer NavBar_itemContainer_" + c;
b.appendChild(d);
a(d).add_event("click", function (a) {
a.stopPropagation();
x.reportAction(a);
h(c);
v()
});
b = d
}
var j = document.createElement("div");
j.className = "NavBar_typePreview NavBar_typePreview_" + c;
b.appendChild(j);
var e = document.createElement("div");
e.className = "NavBar_typeContent";
b.appendChild(e);
b = e;
var f = document.createElement("div");
f.className = "NavBar_typeTitle";
f.appendChild(document.createTextNode(i.title));
b.appendChild(f);
var g = document.createElement("div");
g.className = "NavBar_typeDesc";
g.appendChild(document.createTextNode(i.description));
b.appendChild(g);
return b
}
function P(f) {
var e = document.createElement("div");
e.className = "NavBar_checkControls";
var c = document.createElement("div");
c.className = "NavBar_checkControl";
var b = document.createElement("input");
b.id = "LabelCB_" + s.getNext();
b.setAttribute("type", "checkbox");
a(b).add_event("click", I);
u = b;
c.appendChild(b);
var d = document.createElement("span");
d.appendChild(document.createTextNode(S));
a(d).add_event("click", I);
c.appendChild(d);
e.appendChild(c);
c = document.createElement("div");
c.className = "NavBar_checkControl";
b = document.createElement("input");
b.id = "TiltCB_" + s.getNext();
b.setAttribute("type", "checkbox");
a(b).add_event("click", H);
t = b;
c.appendChild(b);
d = document.createElement("span");
d.appendChild(document.createTextNode(R));
a(d).add_event("click", H);
c.appendChild(d);
e.appendChild(c);
f.appendChild(e)
}
}
function nb(n, x, u) {
var L = this,
g, e, q, d, y, A, h, f, j, k, C, p;
g = document.createElement("div");
g.className = "NavBar_zoom";
g.style.cssText = z.safariRenderHack;
e = document.createElement("div");
e.className = "NavBar_zoomBar";
e.style.cssText = "position:absolute;overflow:hidden";
a(e).add_event("click", H).add_event("touchstart", r).add_event("touchmove", s).add_event("touchend", t);
q = document.createElement("div");
q.className = "NavBar_zoomBarBg";
q.style.cssText = "position:absolute";
e.appendChild(q);
d = document.createElement("div");
d.className = "NavBar_zoomSlider";
d.style.cssText = "position:absolute";
d.title = Q;
a(d).add_event("mousedown", D).add_event("mouseup", G).add_event("mousemove", E).add_event("click", c).add_event("touchstart", r).add_event("touchmove", s).add_event("touchend", t);
a(g).add_event("mousedown", c).add_event("mouseup", c).add_event("mousemove", c).add_event("click", c).add_event("touchstart", c).add_event("touchmove", c).add_event("touchend", c);
e.appendChild(d);
g.appendChild(e);
x.appendChild(g);
y = b.addHandler(n, "targetviewchanged", v);
A = b.addHandler(n, "imagerychanged", v);
m();
this.dispose = function () {
if (g) {
a(e).remove_event("click", H).remove_event("touchstart", r).remove_event("touchmove", s).remove_event("touchend", t);
a(d).remove_event("mousedown", D).remove_event("mouseup", G).remove_event("mousemove", E).remove_event("click", c).remove_event("touchstart", r).remove_event("touchmove", s).remove_event("touchend", t);
a(g).remove_event("mousedown", c).remove_event("mouseup", c).remove_event("mousemove", c).remove_event("click", c).remove_event("touchstart", c).remove_event("touchmove", c).remove_event("touchend", c);
b.removeHandler(y);
b.removeHandler(A);
x.removeChild(g);
e = null;
d = null;
g = null
}
};
this.show = function () {
v()
};
this.resetZoomBarTimer = m;
function c(a) {
a.stopPropagation();
a.preventDefault()
}
function D(b) {
c(b);
a.Events.capture_mouse(d);
h = true
}
function r(a) {
m();
var b = Math.min(1, a.touches.length);
if (!C && a.touches.length === 1) {
j = new l(a.touches[0].pageX, a.touches[0].pageY);
j.target = a.target;
j.start = new Date
}
k = new l(a.touches[0].pageX, a.touches[0].pageY);
C = k;
h = true;
c(a)
}
function E(b) {
c(b);
if (h) d.style.top = i(a.Screen.get_mouse_pos(b).y) + "px"
}
function s(a) {
m();
F();
k = new l(a.touches[0].pageX, a.touches[0].pageY);
if (h) d.style.top = i(k.y) + "px";
c(a)
}
function G(b) {
c(b);
if (h) {
a.Events.release_mouse();
h = false;
o(i(a.Screen.get_mouse_pos(b).y));
w();
u.reportAction(b)
}
}
function t(a) {
m();
if (j) {
K(a);
u.reportAction(a)
} else if (h) {
h = false;
o(i(k.y));
w();
u.reportAction(a)
}
F()
}
function H(b) {
c(b);
o(i(a.Screen.get_mouse_pos(b).y));
u.reportAction(b)
}
function K(a) {
a.target === e && o(i(j.y))
}
function F() {
j = null
}
function v() {
var a = n.getZoomRange();
if (!f || f.min != a.min || f.max != a.max) f = a;
w()
}
function i(b) {
var c = e.offsetHeight - d.offsetHeight;
b -= a(e).get_absolute_pos().y + d.offsetHeight / 2;
b = Math.max(b, 0);
b = Math.min(b, c);
return b
}
function o(b) {
var a = d.offsetHeight / 2,
c = e.offsetHeight - a,
g = b + a,
h = Math.round(f.max + (g - a) * -(f.max - f.min) / (c - a));
n.setView({
zoom: h
})
}
function I(b, h) {
if (f) {
var a = d.offsetHeight / 2,
c = e.offsetHeight - a,
g = Math.round(a + (c - a) * (h - f.max) / -(f.max - f.min));
b.style.top = g - b.offsetHeight / 2 + "px"
}
}
function w() {
I(d, n.getTargetZoom())
}
function B() {
if (p) {
window.clearTimeout(p);
p = null
}
}
function m() {
B();
p = window.setTimeout(J, 5e3)
}
function J() {
B();
x.style.display = "none"
}
}
var e = {
left: 0,
middle: 1,
right: 2,
getName: function (a) {
switch (a) {
case e.left:
return "left";
case e.middle:
return "middle";
case e.right:
return "right"
}
return ""
},
isValid: function (a) {
return a === e.left || a === e.middle || a === e.right
}
};
d.ClientRegion = e;
function m(d, R) {
var V = this,
N = d.getRootElement(),
g, h, l, t, q, G, E, u, z, o, f, w, x, C, y = false,
k, v, S = {
visibility: "hidden"
},
T = {
visibility: "visible"
},
F, Q = "navbaraction";
g = document.createElement("div");
g.className = "NavBar Navbar_" + i.locale;
h = document.createElement("div");
h.className = "NavBar_top";
g.appendChild(h);
a(g).select("> div").add_event("mousedown", c).add_event("mouseup", c).add_event("mousewheel", c).add_event("dblclick", c).add_event("contextmenu", c).add_event("keydown", c).add_event("keyup", c).add_event("click", c).add_event("touchstart", j).add_event("touchmove", j).add_event("touchend", j).add_event("touchcancel", j);
l = document.createElement("div");
l.className = "NavBar_compassContainer";
h.appendChild(l);
t = r("NavBar_rotateLeft", P);
l.appendChild(t);
a(t).add_event("click", K);
E = new lb(d, l, this);
q = r("NavBar_rotateRight", L);
l.appendChild(q);
a(q).add_event("click", I);
G = a([t, q]);
u = document.createElement("div");
u.className = "NavBar_zoomContainer";
h.appendChild(u);
o = r("NavBar_zoomOut", Z);
u.appendChild(o);
a(o).add_event("click", H).add_event("mouseenter", n).add_event("mouseleave", s);
z = r("NavBar_zoomIn", cb);
u.appendChild(z);
a(z).add_event("click", J).add_event("mouseenter", n).add_event("mouseleave", s);
k = document.createElement("div");
k.className = "NavBar_typeButtonContainer";
h.appendChild(k);
if (R.showMapTypeSelector !== false) {
a(g).add_class("NavBarFull");
m.appendSeparator(k);
v = new gb(d, k, this)
}
N.appendChild(g);
F = b.addHandler(d, "imagerychanged", M);
M();
var A = b.addHandler(d, "ondispose", U);
function U() {
if (A && g) {
b.removeHandler(A);
A = null;
a(g).select("> div").remove_event("mousedown", c).remove_event("mouseup", c).remove_event("mousewheel", c).remove_event("dblclick", c).remove_event("contextmenu", c).remove_event("keydown", c).remove_event("keyup", c).remove_event("click", c).remove_event("touchstart", j).remove_event("touchmove", j).remove_event("touchend", j).remove_event("touchcancel", j);
a(t).remove_event("click", K);
a(q).remove_event("click", I);
a(o).remove_event("click", H).remove_event("mouseenter", n).remove_event("mouseleave", s);
a(z).remove_event("click", J).remove_event("mouseenter", n).remove_event("mouseleave", s);
E.dispose();
w && w.dispose();
v && v.dispose();
b.removeHandler(F);
N.removeChild(g);
g = null
}
}
_publicApi = new
function () {
var f = {},
b = {};
function d(b) {
var a = f[b];
if (!a) {
a = document.createElement("div");
a.className = "NavBar_clientRegion NavBar_clientRegion_" + e.getName(b);
switch (b) {
case e.left:
h.insertBefore(a, l);
break;
case e.middle:
h.insertBefore(a, k);
k.className += " NavBar_typeButton_client";
m.appendSeparator(a);
break;
case e.right:
h.appendChild(a);
m.appendSeparator(a)
}
f[b] = a
}
return a
}
this.getBreadcrumbRegion = function () {
return d(e.left)
};
this.addClientButton = function (h, g, k, i, f) {
var j = d(h),
e = r(i, k);
j.appendChild(e);
b[g] = e;
a(e).add_event("click", function (a) {
c(a);
p(a);
f && f(g)
})
};
this.updateClientButton = function (e, d, c) {
var a = b[e];
if (a) {
a.className = "NavBar_button NavBar_toolButton " + (c || "");
a.title = d || ""
}
};
this.removeClientButton = function (e, c) {
var f = d(e),
a = b[c];
if (a) {
delete b[c];
f.removeChild(a)
}
};
this.getAerialViewSettings = function () {
return {
aerialViewSettings: v.getAerialViewSettings()
}
};
this.setAerialViewSettings = function (b, a) {
v.setAerialViewSettings(b, a)
}
};
d.addComponent("navigationBar", _publicApi);
function M() {
var a = d.isRotationEnabled();
G.set_style(a ? T : S);
E.enableRotation(a)
}
function c(a) {
a.stopPropagation();
a.preventDefault()
}
function j(a) {
y = true;
a.stopPropagation()
}
function r(c, b) {
var a = document.createElement("a");
a.href = "#";
a.className = "NavBar_button NavBar_toolButton " + (c || "");
if (b) a.title = b;
return a
}
function p(c) {
var a = c.currentTarget;
a && b.invoke(_publicApi, Q, {
id: a.id,
typeName: a.className,
title: a.title
})
}
function K(a) {
c(a);
p(a);
O(90)
}
function I(a) {
c(a);
p(a);
O(-90)
}
function O(a) {
d.setView({
heading: d.getTargetHeading() + a
})
}
function J(a) {
c(a);
p(a);
if (y) n();
else D();
d.setView({
zoom: d.getTargetZoom() + 1
})
}
function H(a) {
c(a);
p(a);
if (y) n();
else D();
d.setView({
zoom: d.getTargetZoom() - 1
})
}
function n() {
B();
if (!f) {
f = document.createElement("div");
f.className = "NavBar_zoomDrop";
f.style.cssText = "position:absolute;display:none;";
g.appendChild(f);
w = new nb(d, f, V);
a(f).add_event("mouseenter", n).add_event("mouseleave", s)
}
if (f.style.display === "none") {
var b = a(o).get_absolute_pos(),
c = a(g).get_absolute_pos();
f.style.top = b.y - c.y + o.offsetHeight + "px";
f.style.left = b.x - c.x + "px";
f.style.display = "";
w.show()
}
y && w.resetZoomBarTimer()
}
function s() {
B();
x = window.setTimeout(D, 1e3)
}
function D() {
B();
if (f) f.style.display = "none"
}
function B() {
if (x) {
window.clearTimeout(x);
x = null
}
if (C) {
window.clearTimeout(C);
C = null
}
}
this.reportAction = p
}
m.appendSeparator = function (b) {
var a = document.createElement("span");
a.className = "NavBar_separator";
b.appendChild(a)
};
function hb(h) {
var gb = d.Globals.bingMapsRESTServicesUrl,
S = "en-us",
Ib = ["cs-cz", "da-dk", "nl-nl", "en-ca", "en-gb", "en-us", "fi-fi", "fr-ca", "fr-fr", "de-de", "it-it", "ja-jp", "nb-no", "pt-br", "pt-pt", "es-es", "es-us", "sv-se"],
db = 0,
v = 0,
w = 0,
u, p, J = null,
K = null,
I = {},
m = {},
N, R = true,
i = this,
A = false,
bb, Y, O = "navigationBar",
Q = {},
q = "world",
dc = 0,
sb = "ready",
ub = "wait",
U = sb,
ob, tb, F, E, Lb = 1e3,
o, l = [],
f = {
world: fb,
worldBounds: [-75, -175, 75, 175],
countryZoom: 4,
stateZoom: 7,
countyZoom: 10,
cityZoom: 13,
neighborhoodZoom: 15,
streetZoom: 16,
current: ""
},
c = f,
s = {
world: 0,
country: 1,
state: 2,
county: 3,
city: 4,
neighborhood: 5,
street: 6,
current: 7
},
k = ["world", "country", "state", "county", "city", "neighborhood", "street", "current"],
n = s.world,
D = 0,
e = {},
g = {},
pb = {
_cacheSize: 100,
_history: [],
_recentlyUsed: [],
_cache: {},
add: function (a, b) {
if (!a) return;
this._cache[a] = b;
this._history.push(a);
if (this._history.length > this._cacheSize) delete this._cache[this._history.shift()]
},
"get": function (a) {
return a ? this._cache[a] : null
}
};
function Ub() {
b.removeHandler(F);
F = null;
ob = h.getTargetCenter();
tb = h.getTargetZoom()
}
function G() {
if (N) {
h.entities.remove(N);
N = null
}
if (e.current.style.display !== "none") {
e.current.style.display = "none";
e.currentDelim.style.display = "none";
q = k[n];
j()
}
}
function rb() {
if (e.current.style.display === "none") {
f.currentZoom = h.getTargetZoom();
f.currentCenter = h.getTargetCenter();
e.current.style.display = "inline-block";
e.currentDelim.style.display = "inline";
j()
}
}
function vb() {
v = ac()
}
function ac() {
var b = e.breadcrumbContainer,
f = e.breadcrumb;
if (f && b) {
var c = a(e.breadcrumb),
d = b.offsetWidth - parseInt(c.get_style("paddingLeft")) - parseInt(c.get_style("paddingRight"));
return d > 0 ? d : 0
}
return 0
}
function Rb() {
j()
}
function Nb() {
vb();
if (v <= 0) {
e.breadcrumb.style.display = "none";
return
} else e.breadcrumb.style.display = "block";
var b = e.breadcrumbBar.offsetWidth;
if (b >= v) for (var a = 0, c = k.length - 1; a < c; a++) {
e[k[a]].firstChild.nodeValue = "...";
e[k[a]].setAttribute("title", f[k[a]]);
b = e.breadcrumbBar.offsetWidth;
if (b < v) break
}
xb()
}
function xb() {
vb();
if (v <= 0) {
e.breadcrumb.style.display = "none";
return
} else e.breadcrumb.style.display = "block";
var b = e.breadcrumbBar.offsetWidth;
if (b >= v) for (var a = 0, c = l.length; a < c; a++) {
g[l[a].name].firstChild.nodeValue = "...";
g[l[a].name].setAttribute("title", l[a].value);
b = e.breadcrumbBar.offsetWidth;
if (b < v) break
}
cb(p)
}
function ab() {
if (e.breadcrumb) {
e.breadcrumb.parentNode.removeChild(e.breadcrumb);
e.breadcrumb = null
}
}
function Mb(a) {
var e = g[a + "Delim"];
if (e) {
e.parentNode.removeChild(e);
g[a + "Delim"] = null
}
var f = z(a);
if (f.type === "group") {
var c = a + "Click";
b.removeHandler(m[c]);
m[c] = null;
c = a + "MouseEnter";
b.removeHandler(m[c]);
m[c] = null;
c = a + "MouseLeave";
b.removeHandler(m[c]);
m[c] = null;
f === p && r(true);
var d = g[a + "Container"];
g[a + "Container"] = null;
g[a] = null;
g[a + "ListSign"] = null;
d.parentNode.removeChild(d)
} else {
var c = a + "Click";
b.removeHandler(m[c]);
m[c] = null;
var d = g[a];
g[a] = null;
d.parentNode.removeChild(d)
}
}
function Pb(a) {
q = a;
j();
switch (a) {
case "world":
case "country":
case "state":
case "county":
case "city":
case "neighborhood":
rb();
break;
case "current":
G();
break;
default:
b.invoke(i, "pathnodeclicked", {
pathNodeLevel: a,
pathNodeValue: z(a).value
});
return
}
D++;
var c = f[a + "Bounds"];
if (c) {
var d = x.fromEdges(c[2], c[1], c[0], c[3]);
T({
bounds: d,
animate: R
})
} else if (a === "current") T({
center: f.currentCenter,
zoom: f.currentZoom,
animate: R
});
else T({
center: u,
zoom: f[a + "Zoom"],
animate: R
});
b.invoke(i, "pathnodeclicked", {
pathNodeLevel: a,
pathNodeValue: f[a]
})
}
function V() {
Pb(this.attributes.pathNodeLevel.value)
}
function qb(a) {
if (a && a.componentName === O && a.component) {
var c = a.component.getBreadcrumbRegion();
e.breadcrumbContainer = c;
c.appendChild(e.breadcrumb);
b.removeHandler(Y)
}
}
function Z() {
if (!e.root) {
e.root = h.getRootElement();
var d = document.createElement("div");
e.breadcrumb = d;
d.className = "pathContainer";
d.setAttribute("onselectstart", "return false;");
var f = h.getComponent(O);
if (!f) Y = b.addHandler(h, "componentadded", qb);
else qb({
componentName: O,
component: f
});
var c = document.createElement("div");
c.className = "unlockButton";
a(c).add_event("click", Ab);
e.root.appendChild(c);
e.breadcrumbUnlock = c;
yb()
}
}
function yb() {
if (e.breadcrumb) {
var g = document.createElement("span");
g.className = "path";
for (var c in s) {
var d = document.createElement("span");
if (c !== "world") {
if (c === "current") {
var h = document.createElement("span");
g.appendChild(h);
e.breadcrumbExtension = h
}
var i = "•";
d.className = "pathNodeDelim";
d.style.display = "none"
} else {
var i = "";
d.className = "pathHeight";
d.style.display = "inline-block"
}
d.appendChild(document.createTextNode(i));
g.appendChild(d);
e[c + "Delim"] = d;
if (c === "current") {
var b = document.createElement("span");
b.className = "currentIcon"
} else {
var b = document.createElement("span");
b.className = "pathNode";
if (c !== "world") b.appendChild(document.createTextNode(""));
else b.appendChild(document.createTextNode(f[c]))
}
if (c !== "world") b.style.display = "none";
a(b).add_event("click", V);
b.setAttribute("pathNodeLevel", c);
g.appendChild(b);
e[c] = b
}
e.breadcrumbBar = g;
e.breadcrumb.appendChild(g)
}
}
function nb() {
c.country = null;
c.state = null;
c.county = null;
c.city = null;
c.neighborhood = null;
c.street = null;
c.current = null;
c.countryBounds = null;
c.stateBounds = null;
c.countyBounds = null;
c.cityBounds = null;
c.neighborhoodBounds = null;
c.streetBounds = null;
c.currentBounds = null;
c.countryEntityId = null;
c.stateEntityId = null;
c.countyEntityId = null;
c.cityEntityId = null;
c.neighborhoodEntityId = null;
c.streetEntityId = null;
c.currentEntityId = null
}
function kb() {
e.breadcrumbUnlock.style.display = "block"
}
function ib() {
e.breadcrumbUnlock.style.display = "none"
}
function Zb(f, e, d, c, b) {
var a = {
type: f,
name: e,
value: d,
values: c,
isVisible: b
};
l.push(a);
Vb(a)
}
function Vb(b) {
var f = document.createElement("span"),
i = "•";
f.className = "pathNodeDelim";
f.style.display = "none";
f.appendChild(document.createTextNode(i));
g[b.name + "Delim"] = f;
e.breadcrumbExtension.appendChild(f);
if (b.type === "group") {
var d = document.createElement("span");
d.className = "groupContainer";
d.style.display = "none";
d.setAttribute("pathNodeLevel", b.name);
m[b.name + "Click"] = a(d).add_event("click", Fb);
m[b.name + "MouseEnter"] = a(d).add_event("mouseenter", eb);
m[b.name + "MouseLeave"] = a(d).add_event("mouseleave", hb);
var c = document.createElement("span");
c.className = "group";
c.appendChild(document.createTextNode(""));
var h = document.createElement("span");
h.className = "groupListSign";
g[b.name + "Container"] = d;
g[b.name] = c;
g[b.name + "ListSign"] = h;
d.appendChild(c);
d.appendChild(h);
e.breadcrumbExtension.appendChild(d)
} else {
var c = document.createElement("span");
c.className = "pathNode";
c.appendChild(document.createTextNode(""));
c.style.display = "none";
m[b.name + "Click"] = a(c).add_event("click", V);
c.setAttribute("pathNodeLevel", b.name);
g[b.name] = c;
e.breadcrumbExtension.appendChild(c)
}
}
function Tb(c, b) {
var a = z(c);
a.type === "group" && b === false && a === p && r(true);
a.isVisible = b;
j()
}
function Xb(a) {
Mb(a);
l.splice(Jb(a), 1);
j()
}
function z(b) {
var a = l.length;
while (a--) if (l[a].name === b) return l[a]
}
function Jb(b) {
var a = l.length;
while (a--) if (l[a].name === b) return a
}
function jb(a, c) {
var d = z(a),
e = d.value;
d.value = c;
g[a].firstChild.nodeValue = c;
P(a);
j();
b.invoke(i, "groupselecteditemchanged", {
groupName: a,
newItem: c,
oldItem: e
})
}
function lb(a) {
A = true;
u = a;
C(true);
b.invoke(i, "locked")
}
function T(a) {
if (!F) F = b.addHandler(h, "targetviewchanged", Ub);
h.setView(a)
}
function Gb() {
A = false
}
function Kb() {
A = false;
ib();
r(true);
G();
nb();
c.currentZoom = h.getTargetZoom();
X();
q = k[n];
j();
u = h.getTargetCenter();
C(true);
b.invoke(i, "unlocked")
}
function Ab() {
Kb();
b.invoke(i, "closed")
}
function Fb() {
var a = this.attributes.pathNodeLevel.value,
c = z(a);
P(a);
j();
if (!g.groupList) mb(c);
else r(true);
b.invoke(i, "pathnodeclicked", {
pathNodeLevel: a,
pathNodeValue: c.value
})
}
function eb() {
mb(z(this.attributes.pathNodeLevel.value))
}
function hb() {
g.groupList && r()
}
function Eb() {
jb(p.name, this.firstChild.nodeValue);
r(true)
}
function W() {
o = null;
if (g.groupList) {
b.removeHandler(J);
b.removeHandler(K);
for (var a in p.values) b.removeHandler(I[a]);
J = null;
K = null;
I = {};
g.groupList.parentNode.removeChild(g.groupList);
g.groupList = null;
p = null
}
}
function r(a) {
if (g.groupList) if (a) {
if (o) {
clearTimeout(o);
o = null
}
W()
} else if (!o) o = setTimeout(W, 1e3)
}
function cb(d) {
var a = g.groupList;
if (a) {
var b = e.breadcrumb,
h = b.offsetTop + b.offsetHeight,
c = g[d.name + "ListSign"],
f = c.offsetLeft + c.offsetWidth - a.offsetWidth;
a.style.top = h + "px";
a.style.left = f + "px"
}
}
function mb(c) {
if (p) if (p !== c) r(true);
else {
if (o) {
clearTimeout(o);
o = null
}
return
}
var b = document.createElement("ul");
g.groupList = b;
p = c;
b.className = "pathList";
b.style.position = "absolute";
b.setAttribute("pathNodeLevel", c.name);
e.root.appendChild(b);
J = a(b).add_event("mouseenter", eb);
K = a(b).add_event("mouseleave", hb);
for (var f in c.values) {
var d = document.createElement("li");
d.appendChild(document.createTextNode(c.values[f]));
b.appendChild(d);
I[f] = a(d).add_event("click", Eb)
}
cb(c)
}
function Yb() {
f.country = null;
f.state = null;
f.county = null;
f.city = null;
f.neighborhood = null;
f.street = null;
f.current = null;
f.countryBounds = null;
f.stateBounds = null;
f.countyBounds = null;
f.cityBounds = null;
f.neighborhoodBounds = null;
f.streetBounds = null;
f.currentBounds = null;
f.countryEntityId = null;
f.stateEntityId = null;
f.countyEntityId = null;
f.cityEntityId = null;
f.neighborhoodEntityId = null;
f.streetEntityId = null;
f.currentEntityId = null;
n = s.world;
q = "world"
}
function L() {
U = sb;
w++;
h.getCredentials(function (a) {
if (a) {
var b = gb + "/" + u.latitude.toFixed(10) + "," + u.longitude.toFixed(10) + "?include=EntityId&includeEntityTypes=Neighborhood,PopulatedPlace,AdminDivision1,AdminDivision2,CountryRegion&output=json&jsonp=microsoftMapsNetworkCallback&key=" + a + "&jsonso={jsono}&culture=" + S;
t.getObjectAsync(b, Bb, w)
}
})
}
function C(b, a) {
if (!b) {
U === ub && clearTimeout(E);
w++;
U = ub;
if (a) E = setTimeout(L, a);
else E = setTimeout(L, Lb)
} else {
clearTimeout(E);
L()
}
}
var Hb = {
street: "addressLine",
city: "locality",
county: "adminDistrict2",
state: "adminDistrict",
country: "countryRegion"
};
function M(a) {
var e = "",
i = s[a] + 1;
while (i-- > 1) {
var g = k[i],
d = Hb[g],
b = c[g];
if (d && b) e += "&" + d + "=" + b;
else {
H();
return
}
}
if (a !== "street") var f = pb.get(c[a + "EntityId"]);
if (!f) h.getCredentials(function (a) {
if (a) {
var b = gb + "?key=" + a + "&jsonso={jsono}&culture=" + S + "&output=json&jsonp=microsoftMapsNetworkCallback" + e;
t.getObjectAsync(b, zb, w)
}
});
else {
c[a + "Bounds"] = f;
H()
}
}
function j() {
var h = s,
g;
for (var b in h) {
var c = e[b];
if (b !== "current") {
if (b === "street") c.firstChild.nodeValue = "Near " + f[b];
else {
g = f[b];
if (!g) g = "";
c.firstChild.nodeValue = g
}
c.removeAttribute("title");
var d = e[b + "Delim"];
if (s[b] > n && !A || !f[b]) {
if (c) c.style.display = "none";
if (d) if (b !== "world") d.style.display = "none"
} else {
if (c) {
c.style.display = "inline";
if (b === q) a(c).add_class("pathNodeSelected");
else a(c).remove_class("pathNodeSelected")
}
if (d) if (b !== "world") d.style.display = "inline"
}
}
}
Db();
Nb()
}
function Db() {
for (var e = 0, f = l.length; e < f; e++) {
var b = l[e],
c = g[b.name];
c.firstChild.nodeValue = b.value;
c.removeAttribute("title");
var d = g[b.name + "Delim"];
if (!b.isVisible) {
if (c) if (b.type === "group") {
g[b.name + "Container"].style.display = "none";
r(true)
} else c.style.display = "none";
if (d) d.style.display = "none"
} else {
if (c) {
if (b.type === "group") g[b.name + "Container"].style.display = "inline";
else c.style.display = "inline";
if (b.name === q) a(c).add_class("pathNodeSelected");
else a(c).remove_class("pathNodeSelected")
}
if (d) d.style.display = "inline"
}
}
}
function Bb(g, i) {
var k = i.userData;
if (k === w && i.success && g.statusCode === 200) {
var h = g.resourceSets[0];
if (h.estimatedTotal > 0) {
var d = h.resources;
nb();
var f = d.length;
while (f--) {
var e = d[f],
b = e.entityType;
if (b === "Address" || b === "PopulatedPlace" || b === "AdminDivision2" || b === "AdminDivision1" || b === "Sovereign" || b === "CountryRegion") {
var a = e.address;
c.country = a.countryRegion;
c.state = a.adminDistrict;
c.county = a.adminDistrict2;
c.city = a.locality;
c.street = a.addressLine;
c.countryEntityId = a.countryRegionEntityId;
c.stateEntityId = a.adminDistrictEntityId;
c.countyEntityId = a.adminDistrict2EntityId;
c.cityEntityId = a.localityEntityId;
c.streetEntityId = a.addressLineEntityId;
break
}
}
var f = d.length;
while (f--) {
var e = d[f];
if (e.entityType === "Neighborhood") {
var a = e.address;
c.country = a.countryRegion;
c.state = a.adminDistrict;
c.county = a.adminDistrict2;
c.neighborhood = a.locality;
c.countryEntityId = a.countryRegionEntityId;
c.stateEntityId = a.adminDistrictEntityId;
c.countyEntityId = a.adminDistrict2EntityId;
c.neighborhoodEntityId = a.localityEntityId;
break
}
}
wb()
} else {
Yb();
j()
}
Q = {
country: c.country,
state: c.state,
county: c.county,
neighborhood: c.neighborhood,
city: c.city,
street: c.street,
location: g
}
}
}
var Sb = {
Sovereign: "country",
CountryRegion: "country",
AdminDivision1: "state",
AdminDivision2: "county",
PopulatedPlace: "city",
Neighborhood: "neighborhood",
Address: "street"
};
function Wb(d, b) {
var a = Sb[d];
c[a + "Bounds"] = b;
pb.add(c[a + "EntityId"], b)
}
function wb() {
db = 3;
M("city");
M("state");
M("country")
}
function zb(a, c) {
var d = c.userData;
if (d === w && c.success && a && a.statusCode === 200) if (a.resourceSets && a.resourceSets.length > 0 && a.resourceSets[0].resources && a.resourceSets[0].resources.length > 0) {
var b = a.resourceSets[0].resources[0];
Wb(b.entityType, b.bbox)
}
H()
}
function H() {
if (!--db) {
f = c;
X();
Q.currentCrumb = k[n];
b.invoke(i, "breadcrumbschanged");
j()
}
}
function Ob(b) {
var a = h.getBounds();
return !(b.width > a.width || b.height > a.height)
}
function Cb(b) {
var a = h.getBounds(),
c = Math.min(a.width / 4, a.height / 4);
return b.width >= c || b.height >= c
}
function X() {
if (A) {
n = s.neighborhood;
return
}
for (var a = 0, e = k.length - 1; a < e; a++) if (f[k[a]]) {
var b = f[k[a] + "Bounds"];
if (b) {
var c = x.fromEdges(b[2], b[1], b[0], b[3]);
if (Ob(c)) {
var g = c;
if (Cb(c)) n = a;
break
} else n = a
} else {
var d = f[k[a] + "Zoom"];
if (d) if (d >= f.currentZoom) {
if (d < f.currentZoom + 2) {
n = a;
break
}
} else n = a
}
}
q = k[n]
}
function cc() {
Z();
u = h.getTargetCenter();
c.currentZoom = h.getTargetZoom();
C(false, 5e3);
bb = b.addHandler(h, "viewchangeend", Qb)
}
function Qb() {
if (D > 0) D--;
else {
D = 0;
if (!y.areEqual(h.getTargetCenter(), ob) || h.getTargetZoom() !== tb) {
G();
if (A === false) {
u = h.getCenter();
c.currentZoom = h.getZoom();
C()
} else j()
}
}
}
function P(a) {
q = a;
j()
}
function bc() {
b.removeHandler(bb);
ab()
}
var B = d.Globals.locale;
if (B) {
B = B.toLowerCase();
if (a(Ib).index_of(B) !== -1) S = B
}
b.addHandler(h, "resize", Rb);
h.addComponent("breadcrumb", i);
i.enable = cc;
i.disable = bc;
i.lockToLocation = lb;
i.unlockFromLocation = Gb;
i.showCloseButton = kb;
i.hideCloseButton = ib;
i.addCrumb = Zb;
i.removeCrumb = Xb;
i.setVisibility = Tb;
i.selectGroupItem = jb;
i.highlightCrumb = P;
i.showBookmark = rb;
i.hideBookmark = G;
i.relocateCloseButton = function (b, a) {
e.breadcrumbUnlock.style.top = b;
e.breadcrumbUnlock.style.right = a
};
i.getBreadcrumbs = function () {
return Q
}
}
function n(e) {
var d = e;
a(e).add_class("shadowtextDark");
var b = document.createElement("div");
b.className = "bg";
d.appendChild(b);
var c = document.createElement("div");
c.className = "fg";
d.appendChild(c);
this.setColorsForDarkBackground = function () {
a(d).swap_class("shadowtextDark", "shadowtextLight")
};
this.setColorsForLightBackground = function () {
a(d).swap_class("shadowtextLight", "shadowtextDark")
};
this.setHtmlContent = function (a) {
c.innerHTML = a;
b.innerHTML = a
};
this.setTextContent = function (a) {
n._clearChildNodes(c);
n._clearChildNodes(b);
c.appendChild(document.createTextNode(a));
b.appendChild(document.createTextNode(a))
}
}
n._clearChildNodes = function (a) {
if (a.hasChildNodes && a.removeChild) while (a.hasChildNodes()) a.removeChild(a.firstChild)
};
var h = {
light: 0,
dark: 1
};
h.getImageryBackground = function (a) {
return a === "Aerial" || a === "EnhancedBirdseye" || a === "NativeBirdseye" ? h.dark : h.light
};
function ib(d, o) {
var l = o;
a(l).add_class("Copyright");
var j = new n(l),
r = 2.5,
p = 80,
q = "&nbsp;&nbsp;&nbsp;",
m = 3,
c = d,
f = [],
e;
i();
g();
var k = [b.addThrottledHandler(c, "copyrightchanged", i, 2e3), b.addHandler(c, "imagerychanged", g), b.addHandler(c, "modechanged", g)],
e = b.addHandler(d, "ondispose", t);
function i() {
for (var d = [c.getCopyrights(), f], a = 0, b = [], k = 1, e = 0; e < d.length; e++) if (d) for (var i = d[e] || [], g = 0; g < i.length; g++) {
var h = i[g];
if (a + h.length > p) {
b.push("<br />");
a = 0;
k++
} else {
b.push(q);
a += m
}
b.push(h);
a += h.length
}
j.setHtmlContent(b.join(""));
l.style.height = r * k + "ex"
}
function g() {
if (h.getImageryBackground(d.getImageryId()) === h.light) j.setColorsForLightBackground();
else j.setColorsForDarkBackground()
}
var s = new
function () {
this.get_customAttributions = function () {
return f
};
this.set_customAttributions = function (a) {
f = a;
i()
}
};
function t() {
if (e) {
b.removeHandler(e);
e = null;
var a = k.length;
while (a--) b.removeHandler(k[a]);
k.length = 0
}
}
d.addComponent("copyright", s)
}
function ob(w, r, N, M) {
var W = this,
O = false,
e = null,
n = false,
j = false,
k = false,
l = null,
g = null,
d = null,
f = null,
s = null,
h = null,
o = null,
q, B = "logo2.png",
R = "logo_no_shadow2.png";
function V() {
q = b.addHandler(w, "ondispose", U);
O = z.isIE6;
h = document.createElement("div");
h.className = "LogoContainer";
r.appendChild(h);
if (N || M) {
g = a(h);
g.add_event("mouseover", H).add_event("mouseout", K).add_event("mousedown", c).add_event("mouseup", c).add_event("dblclick", c).add_event("contextmenu", c).add_event("click", c)
}
if (N) {
e = document.createElement("a");
e.href = "#";
e.target = "mc_bingMaps";
e.title = T;
o = e;
b.addHandler(w, "viewchangeend", x);
try {
x()
} catch (t) {}
} else e = document.createElement("div");
e.id = "PoweredByLogo";
p(e, B);
h.appendChild(e);
if (M) {
var n = document.createElement("div");
n.className = "LogoSearchContainer";
var m = document.createElement("div");
m.className = "LogoSearchGroup";
n.appendChild(m);
var i = document.createElement("input");
i.id = "LogoSearchInput";
i.type = "text";
i.maxLength = 60;
i.className = "watermark";
i.value = v;
k = true;
m.appendChild(i);
var l = document.createElement("input");
l.id = "LogoSearchGo";
l.type = "button";
l.title = I;
m.appendChild(l);
d = a(n);
d.set_style({
display: "none"
});
j = false;
d.add_event("mouseover", F).add_event("mouseout", G).add_event("mousedown", c).add_event("mouseup", c).add_event("dblclick", c).add_event("contextmenu", c);
s = a(l);
s.add_event("blur", A).add_event("focus", y).add_event("click", C);
f = a(i);
f.add_event("blur", E).add_event("focus", D).add_event("keydown", J);
r.appendChild(n)
}
}
function U() {
if (q) {
b.removeHandler(q);
q = null
}
o && b.removeHandler(x);
g && g.remove_event("mouseover", H).remove_event("mouseout", K).remove_event("mousedown", c).remove_event("mouseup", c).remove_event("dblclick", c).remove_event("contextmenu", c).remove_event("click", c);
r.removeChild(h);
if (d) {
d.remove_event("mouseover", F).remove_event("mouseout", G).remove_event("mousedown", c).remove_event("mouseup", c).remove_event("dblclick", c).remove_event("contextmenu", c);
s.remove_event("blur", A).remove_event("focus", y).remove_event("click", C);
f.remove_event("blur", E).remove_event("focus", D).remove_event("keydown", J);
r.removeChild(d.element())
}
m();
o = null;
e = null;
h = null;
s = null;
f = null;
d = null;
g = null
}
function p(a, b) {
if (O) {
a.style.background = "";
a.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + i.domain + "/i/" + b + '", sizingMethod="scale")'
}
}
function m() {
if (d && l) {
window.clearTimeout(l);
l = null
}
}
function t() {
if (d && n) {
m();
l = window.setTimeout(Q, 2e3)
}
}
function L() {
if (!k && !f.element().value) {
f.element().value = v;
f.add_class("watermark");
k = true
}
}
function S() {
if (k) {
f.element().value = "";
f.remove_class("watermark");
k = false
}
}
function Q() {
l = null;
P();
n = false
}
function P() {
d.set_style({
display: "none"
});
g.swap_class("LogoContainerActive", "LogoContainer");
p(e, B);
d.set_style("width", null)
}
function x() {
if (o) {
var a = w.getCenter();
if (a) o.href = i.logoBingMapsLink.replace("{0}", a.latitude).replace("{1}", a.longitude).replace("{2}", w.getZoom())
}
}
function F() {
m()
}
function G() {
!j && t()
}
function A() {
j = false;
t()
}
function y() {
j = true;
m()
}
function E(a) {
A(a);
L()
}
function D(a) {
y(a);
S()
}
function C() {
var a = f.element().value;
if (!k && typeof a === "string" && a.length > 0) {
f.element().value = "";
L();
a = u.encodeUrl(a);
var b = i.logoBingSearchUrl.replace("{0}", a);
window.open(b, "mc_bingSearch");
t()
}
}
function J(a) {
j && a.keyCode === 13 && C()
}
function H() {
m();
if (d && !n) {
d.set_style({
display: ""
});
n = true
}
g.swap_class("LogoContainer", "LogoContainerActive");
p(e, R)
}
function K() {
if (d) n && !j && t();
else {
g.swap_class("LogoContainerActive", "LogoContainer");
p(e, B)
}
}
V()
}
var p = {
milesFeet: 0,
milesYards: 1,
kilometersMeters: 2
},
f = {
metersPerKm: 1e3,
yardsPerMeter: 1.0936133,
yardsPerMile: 1760,
feetPerYard: 3,
feetPerMeter: 3.2808399,
feetPerMile: 5280
};
function w(r, t) {
var s = 2.3025850929940459,
c = r,
j = t,
m = 0,
k = 0,
g = [5, 2],
i = [5, 2.5, 2];
a(c).add_class("ScaleBar");
var l = document.createElement("div");
c.appendChild(l);
var e = new n(l),
d = document.createElement("div");
d.className = "scalerect";
c.appendChild(d);
function o(d) {
for (var c = Math.floor(d), a = 0; a < g.length; a++) {
var b = g[a];
if (c > b) return b
}
return 1
}
function q(d, b) {
for (var a = 0; a < i.length; a++) {
var c = i[a];
if (d > c) return c * b
}
return b
}
function b(c) {
var e = Math.log(c) / s,
d = Math.floor(e),
a = Math.pow(10, d),
b = c / a;
return 1 === a ? o(b) : q(b, a)
}
this.getMaxWidth = function () {
return m
};
this.setMaxWidth = function (a) {
m = a;
return a
};
this.getActualWidth = function () {
return k
};
this.setActualWidth = function (a) {
k = a;
return a
};
this.setColorsForBackground = function (a) {
if (a === h.light) e.setColorsForLightBackground();
else e.setColorsForDarkBackground()
};
this.setScale = function (e) {
var d, a, c;
if (j === p.kilometersMeters) {
var i = e * this.getMaxWidth();
if (i > f.metersPerKm) {
a = b(i / f.metersPerKm);
d = Math.floor(a * f.metersPerKm / e);
c = M
} else {
a = b(i);
d = Math.floor(a / e);
c = Y
}
} else {
var g = e * f.feetPerMeter,
h = g * this.getMaxWidth();
if (h > f.feetPerMile) {
a = b(h / f.feetPerMile);
d = Math.floor(a * f.feetPerMile / g);
c = ab
} else if (j === p.milesFeet) {
a = b(h);
d = Math.floor(a / g);
c = db
} else {
a = b(h / f.feetPerYard);
d = Math.floor(a * f.feetPerYard / g);
c = bb
}
}
this.setControlScale(d, c.replace("{num}", a))
}, this.setControlScale = function (a, b) {
this.setActualWidth(a + 2);
c.style.width = this.getActualWidth().toFixed() + "px";
e.setTextContent(b);
d.style.width = a.toFixed() + "px"
}
}
function W(g) {
var f = 200,
b = g;
a(b).add_class("DoubleScaleBar");
_scaleBarMiElement = document.createElement("div");
var e = new w(_scaleBarMiElement, p.milesFeet);
e.setMaxWidth(f / 2);
b.appendChild(_scaleBarMiElement);
var d = document.createElement("div"),
c = new w(d, p.kilometersMeters);
c.setMaxWidth(f / 2);
d.style.right = "0";
b.appendChild(d);
this.setBottomOffset = function (a) {
b.style.display = "block";
b.style.bottom = a.toFixed() + "px"
};
this.setColorsForBackground = function (a) {
c.setColorsForBackground(a);
e.setColorsForBackground(a)
};
this.setScale = function (a) {
c.setScale(a);
e.setScale(a);
_scaleBarMiElement.style.right = (c.getActualWidth() + 2).toFixed() + "px"
}
}
function kb(a, g) {
var d = new W(g);
d.setScale(a.getMetersPerPixel());
var e = [b.addHandler(a, "viewchangeend", f), b.addHandler(a, "imagerychanged", i), b.addHandler(a, "modechanged", f)],
c = b.addHandler(a, "ondispose", j);
function f() {
d.setScale(a.getMetersPerPixel())
}
function i() {
d.setColorsForBackground(h.getImageryBackground(a.getImageryId()))
}
function j() {
if (c) {
b.removeHandler(c);
c = null;
var a = e.length;
while (a--) b.removeHandler(e[a]);
e.length = 0
}
}
}
function c(a) {
a.stopPropagation()
}
var u = {
singleByteHex: function (c) {
if (!c) return "";
for (var a = c.toString(16), b = a.length; b < 2; b++) a = "0" + a;
return a
},
twoByteHex: function (c) {
if (!c) return "";
for (var a = c.toString(16), b = a.length; b < 4; b++) a = "0" + a;
return a
},
encodeUrl: function (d) {
if (!d) return "";
for (var a, e = d.length, b = new Array(e), c = 0; c < e; ++c) {
a = d.charCodeAt(c);
if (a > 96 && a < 123 || a > 64 && a < 91 || a > 47 && a < 58 || a == 46 || a == 45 || a == 95) b.push(String.fromCharCode(a));
else if (a > 127) {
b.push("%u");
b.push(u.twoByteHex(a))
} else {
b.push("%");
b.push(u.singleByteHex(a))
}
}
return b.join("")
}
},
g = jb.prototype;
g.showNavcontrol = function (a) {
this._map && new m(this._map, a)
};
g.showScalebar = function () {
if (this._map) {
this.createBottomRightBar();
new kb(this._map, this._scalebarDiv)
}
};
g.showCopyright = function () {
if (this._map) {
this.createBottomRightBar();
new ib(this._map, this._copyrightDiv)
}
};
g.createBottomRightBar = function () {
if (!this._scalebarDiv || !this._copyrightDiv) {
var b = document.createElement("div");
a(b).add_class("BottomRightBar");
this._map.getRootElement().appendChild(b);
var d = document.createElement("div");
b.appendChild(d);
this._scalebarDiv = d;
var c = document.createElement("div");
b.appendChild(c);
this._copyrightDiv = c
}
};
g.showLogo = function (b, a) {
if (this._map) var c = new ob(this._map, this._map.getRootElement(), b, a)
};
g.showBreadcrumb = function () {
if (this._map) {
var a = new hb(this._map);
a.enable()
}
};
g.authenticate = function (a) {
if (this._map) this._authentication = new eb(this._map, a)
};
g.getCredentials = function (a) {
this._map && this._authentication.getCredentials(a)
};
mb.done("delay");
function eb(k, e) {
var h = this,
d = i.logServiceUriFormat;
if (d) {
var f = [],
b, a, c = "microsoftMapsNetworkCallback" + s.getNext();
d = d.replace(/{credentials}/, e).replace(/{jsonp}/, c);
this.getCredentials = function (a) {
f.push(a)
};
function g() {
h.getCredentials = function (b) {
b(a)
};
var c = f.length;
while (c--) h.getCredentials(f[c]);
b && b.parentNode && b.parentNode.removeChild(b)
}
var j = setTimeout(function () {
window[c] = function () {};
a = e;
g()
}, 1e4);
window[c] = function (b) {
clearInterval(j);
var f = b && b.authenticationResultCode == "ValidCredentials";
a = f && typeof b.sessionId == "string" && b.sessionId.length > 0 ? b.sessionId : null;
if (!f) {
var d = document.createElement("div");
d.style.cssText = "position:absolute; width:100%; top:50%; text-Align:center";
var e = document.createElement("div");
e.innerHTML = K;
e.style.cssText = "background: #f8f7f5; padding:10px";
d.appendChild(e);
k.getRootElement().appendChild(d)
}
window[c] = null;
g()
};
b = t.downloadScript(d)
} else {
a = e;
this.getCredentials = function (b) {
b(a)
}
}
}
delete window.Microsoft.Maps.initMapDelayCode
};
Microsoft.Maps.Map && Microsoft.Maps.initMapDelayCode && window.Microsoft.Maps.initMapDelayCode();
typeof closeDependency !== "undefined" && closeDependency("mapcontroldelay.js")
1
Watch Expressions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment