function AJAXMAP(B, da, fg, bT, cx) { this.B = B; this.aV = $(B); this.cj = null; this.fa = []; this.ag = 256; this.I = 0; this.F = 0; this.fx = 265960; this.fv = 6647720; this.dD = 265960; this.dC = 6647720; this.at = { 'bottom': 0, 'left': 0, 'top': 0, 'right': 0 }; this.v = { 'bottom': 0, 'left': 0, 'top': 0, 'right': 0 }; this.bp = { 'bottom': 0, 'left': 0, 'top': 0, 'right': 0 }; this.al = 0; this.aj = 0; this.dp = fg; this.o = 4; this.bC = 19; this.bO = 4; this.da = da; this.webatlasTileServerLowerBound = 11; this.webatlasTileServerUpperBound = 14; this.fH = 1; this.bt = 0; this.aO = null; this.cT = false; this.Q = { 'x': 0, 'y': 0 }; this.C = { 'x': 0, 'y': 0 }; this.ar = null; this.cY = null; this.dZ = 0; this.af = null; this.bV = 0; this.ao = { 'x': 0, 'y': 0 }; this.fz = 4326; this.as = 'EPSG:32633'; this.bA = false; this.bq = null; this.dr = null; this.T = null; this.V = null; this.cD = false; this.U = []; this.fw = 0; this.bb = null; this.bT = bT ? bT : 'test'; this.cx = cx ? cx : 'qt_basic'; this.aL = {}; this.aL['blank'] = new Image(); this.aL['loading'] = this.aL['blank']; this.bM = []; this.bL = []; this.aN = []; this.cE = null; this.fF = null; this.trackCoords = null; this.cs = true; this.bW = WAAnnotationOpenBehaviour.Hover; this.dA = WAAnnotationCloseBehaviour.IconMouseOut; this.bZ = false; this.dP = 0; this.dQ = 0; this.bP = true; this.ak = null; this.fu = { 'x': 0, 'y': 0 }; this.dk = true; this.cz = null; this.cA = false; this.H = []; this.cf = 'default'; this.dV = false; this.logClientIP = null; this.logAddressID = null; this.logCustID = null; this.logMode = ''; }; AJAXMAP.ZOOMLEVELS = [56, 128, 256, 512, 1024, 2048, 5120, 10240, 20480, 40960, 81920, 131072, 262144, 524288, 1000000]; var WAAnnotationOpenBehaviour = { Disable: 1, Hover: 2, Click: 4, Manual: 8 }; var WAAnnotationCloseBehaviour = { IconMouseOut: 16, Manual: 32 }; AJAXMAP.prototype = { init: function (P, au, dq) { if (P) P = this.bn(P); if (au) { this.o = parseInt(au); } var latlon = P.transform('EPSG:4326'); var pX = NGTools.aF(latlon.y, latlon.x, au)[0]; var pY = NGTools.aF(latlon.y, latlon.x, au)[1]; if (dq) { this.bt = dq; } this.bV = AJAXMAP.ZOOMLEVELS[this.o] / 256; if (P) { var fd = new Coordinate(P.x, P.y, P.srs); } this.eP(); tileLayer = new Layer({ 'type': 'webatlastile', 'visible': true, 'name': 'Tile Webatlas', 'WATilePath': this.cx }); this.addLayer(tileLayer); Event.observe(this.B + 'mouselayer', 'mousemove', this.eG.bindAsEventListener(this)); Event.observe(this.B + 'mouselayer', 'click', this.cQ.bindAsEventListener(this)); Event.observe(this.B + 'mouselayer', 'mousedown', this.cW.bindAsEventListener(this)); Event.observe(this.B + 'mouselayer', 'mouseup', this.cH.bindAsEventListener(this)); Event.observe(this.B + 'mouselayer', 'mouseout', this.cN.bindAsEventListener(this)); Event.observe(this.B + 'mouselayer', 'mouseover', this.cX.bindAsEventListener(this)); Event.observe(this.B + 'mouselayer', 'dblclick', this.eD.bindAsEventListener(this)); Event.observe(this.B + 'mouselayer', 'contextmenu', this.eN.bindAsEventListener(this)); if (this.dp) { Event.observe(window, 'resize', this.resizeEventHandler.bindAsEventListener(this)); } Event.observe($(this.B), "mousewheel", this.dE.bindAsEventListener(this)); Event.observe($(this.B), "DOMMouseScroll", this.dE.bindAsEventListener(this)); Event.observe(this.B, 'map:resized', this.hideAnnotationPopup.bindAsEventListener(this)); Event.observe(this.B, 'map:moved', this.hideAnnotationPopup.bindAsEventListener(this)); Event.observe(this.B, 'map:dragBegin', this.hideAnnotationPopup.bindAsEventListener(this)); if (this.I == 0 && this.F == 0) { this.I = this.aV.offsetWidth; this.F = this.aV.offsetHeight; } if (this.I == 0 && this.F == 0) { this.eO(); } this.v = { 'bottom': pY + this.F / 2, 'left': pX - this.I / 2, 'top': pY - this.F / 2, 'right': pX + this.I / 2 }; if (this.dp) { this.ew(false); this.v = { 'bottom': pY + this.F / 2, 'left': pX - this.I / 2, 'top': pY - this.F / 2, 'right': pX + this.I / 2 }; } else { } if (P) this.bF(fd); this.dV = true; }, setLogExtra: function (clientip, url, addressid, custid, mode) { this.logClientIP = clientip; this.logAddressID = addressid; this.logCustID = custid; this.logMode = mode }, bF: function (P) { var latlon = P.transform('EPSG:4326'); var pX = NGTools.aF(latlon.y, latlon.x, this.o)[0]; var pY = NGTools.aF(latlon.y, latlon.x, this.o)[1]; this.v = { 'bottom': pY + this.F / 2, 'left': pX - this.I / 2, 'top': pY - this.F / 2, 'right': pX + this.I / 2 }; this.bJ(false); this.by(P, false); this.updateBB(); this.updateWMSLayers(); }, cW: function (K) { this.Q = this.ef(K); this.cY = new Coordinate(this.at.left + (this.bV * this.Q.x), this.at.top - (this.bV * this.Q.y), this.as); var lat = NGTools.ad(this.v.top + this.C.y, this.o); var lon = NGTools.ac(this.v.left + this.C.x, this.o); this.cY = new Coordinate(lon, lat, 'EPSG:4326'); this.cT = true; if (this.dx(K) == "MIDDLE" && !this.bZ) { this.cE.style.zIndex = '2'; this.cD = true; this.T.style.display = 'block'; this.T.style.top = this.C.y + "px"; this.T.style.left = this.C.x + "px"; this.T.style.width = "0px"; this.T.style.height = "0px"; } if (this.cf == 'DrawBoundingBox') { this.cE.style.zIndex = '2'; this.T.style.display = 'block'; this.T.style.top = this.C.y + "px"; this.T.style.left = this.C.x + "px"; this.T.style.width = "0px"; this.T.style.height = "0px"; } $(this.B).fire("map:grabbed", { 'mouseMapCoords': this.ar, 'mouseCoords': this.C }); K.stop(); }, cQ: function (K) { $(this.B).fire("map:mouseClicked", { 'mouseMapCoords': this.ar, 'mouseCoords': this.C }); }, eN: function (K) { }, eD: function (K) { if (this.bP) if (!this.bZ) this.zoomIn(new Coordinate(this.ar.x, this.ar.y, this.as)); }, cH: function (K) { this.release(this.ao); this.T.style.display = 'none'; var lat = NGTools.ad(this.v.top + this.F / 2, this.o); var lon = NGTools.ac(this.v.left + this.I / 2, this.o); this.af = new Coordinate(lon, lat, 'EPSG:4326'); if (this.cD && this.V != null) { this.zoomOnBoundingBox(this.V); this.V = null; this.cD = false; } if (this.cf == 'DrawBoundingBox' && this.V != null) { var eH = { 'bottom': this.V.y1, 'left': this.V.x1, 'top': this.V.y2, 'right': this.V.x2 }; $(this.B).fire("map:boundingboxSelected", { 'boundingbox': eH }); this.V = null; } $(this.B).fire("map:mouseUp", { 'button': this.dx(K), 'mouseMapCoords': this.ar, 'mouseCoords': this.C }); }, cN: function (K) { this.release(this.ao); $(this.B).fire("map:mouseOut"); }, cX: function (K) { $(this.B).fire("map:mouseOver"); }, eG: function (K) { this.C = this.ef(K); if (this.bP) { if (this.cT) { this.dZ++; if (this.dZ % 3 == 0) { if (this.cD) { this.V = { 'x1': 0, 'y1': 0, 'x2': 0, 'y2': 0 }; if (this.C.y < this.Q.y) { this.T.style.top = this.C.y + "px"; this.T.style.height = this.Q.y - this.C.y + "px"; this.V.y1 = NGTools.ad(this.v.top + this.Q.y, this.o); this.V.y2 = NGTools.ad(this.v.top + this.C.y, this.o); } else { this.T.style.top = this.Q.y + "px"; this.T.style.height = this.C.y - this.Q.y + "px"; this.V.y1 = NGTools.ad(this.v.top + this.C.y, this.o); this.V.y2 = NGTools.ad(this.v.top + this.Q.y, this.o); } if (this.C.x < this.Q.x) { this.T.style.left = this.C.x + "px"; this.T.style.width = this.Q.x - this.C.x + "px"; this.V.x1 = NGTools.ac(this.v.left + this.C.x, this.o); this.V.x2 = NGTools.ac(this.v.left + this.Q.x, this.o); } else { this.T.style.left = this.Q.x + "px"; this.T.style.width = this.C.x - this.Q.x + "px"; this.V.x2 = NGTools.ac(this.v.left + this.C.x, this.o); this.V.x1 = NGTools.ac(this.v.left + this.Q.x, this.o); } } else { this.ao = { 'x': this.C.x - this.Q.x, 'y': this.C.y - this.Q.y }; this.bD(this.ao, true); $(this.B).fire("map:dragging", { 'offsetCoords': this.ao }); if (!this.cA) { $(this.B).fire("map:dragBegin", { 'mouseMapCoords': this.ar, 'mouseCoords': this.C, 'boundingBox': this.at }); this.cA = true; } } } } else { var mouseLat = NGTools.ad(this.v.top + this.C.y, this.o); var mouseLon = NGTools.ac(this.v.left + this.C.x, this.o); var mouseMapCoord = new Coordinate(mouseLon, mouseLat, 'EPSG:4326'); mouseMapCoord = this.bn(mouseMapCoord); this.ar = mouseMapCoord; } } if (this.cf == 'DrawBoundingBox') { this.V = { 'x1': 0, 'y1': 0, 'x2': 0, 'y2': 0 }; if (this.C.y < this.Q.y) { this.T.style.top = this.C.y + "px"; this.T.style.height = this.Q.y - this.C.y + "px"; this.V.y1 = NGTools.ad(this.v.top + this.Q.y, this.o); this.V.y2 = NGTools.ad(this.v.top + this.C.y, this.o); } else { this.T.style.top = this.Q.y + "px"; this.T.style.height = this.C.y - this.Q.y + "px"; this.V.y1 = NGTools.ad(this.v.top + this.C.y, this.o); this.V.y2 = NGTools.ad(this.v.top + this.Q.y, this.o); } if (this.C.x < this.Q.x) { this.T.style.left = this.C.x + "px"; this.T.style.width = this.Q.x - this.C.x + "px"; this.V.x1 = NGTools.ac(this.v.left + this.C.x, this.o); this.V.x2 = NGTools.ac(this.v.left + this.Q.x, this.o); } else { this.T.style.left = this.Q.x + "px"; this.T.style.width = this.C.x - this.Q.x + "px"; this.V.x2 = NGTools.ac(this.v.left + this.C.x, this.o); this.V.x1 = NGTools.ac(this.v.left + this.Q.x, this.o); } } $(this.B).fire("map:mouseMoved", { 'mouseMapCoords': this.ar, 'mouseCoords': this.C }); var mouseLat = NGTools.ad(this.v.top + this.C.y, this.o); var mouseLon = NGTools.ac(this.v.left + this.C.x, this.o); var mouseMapCoord = new Coordinate(mouseLon, mouseLat, 'EPSG:4326'); mouseMapCoord = this.bn(mouseMapCoord); this.ar = mouseMapCoord; return false; }, setState: function (dY) { this.cf = dY; if (dY == 'DrawBoundingBox') { this.disallowMouseNavigation(); } else { this.allowMouseNavigation(); } }, getState: function () { return this.cf; }, move: function (ao, cZ) { this.ao = ao; this.bD(this.ao, true); this.release(ao, cZ); }, resizeEventHandler: function (e) { this.resize(); }, resize: function (F, I) { this.aT(); var user = false; if (F != null) { var M = I; var O = F; user = true; } else { var M = 0; var O = 0; if (window.innerWidth) { M = window.innerWidth; O = window.innerHeight; } else { M = document.compatMode == 'CSS1Compat' ? document.documentElement.clientWidth : document.body.clientWidth; O = document.compatMode == 'CSS1Compat' ? document.documentElement.clientHeight : document.body.clientHeight; } if (M % 2) { M--; } if (O % 2) { O--; } } this.I = M; this.F = O; if (user) { $(this.B).style.width = M + "px"; $(this.B).style.height = O + "px"; if (this.ak != null) { this.ak.element.width = M; this.ak.element.height = O; } } else { aQ = this.cp($(this.B)); aS = this.cq($(this.B)); $(this.B).style.width = M - aS + "px"; $(this.B).style.height = O - aQ + "px"; if (this.ak != null) { this.ak.element.width = M - aS; this.ak.element.height = O - aQ; } } if (F == null) { this.I = M - aS; this.F = O - aQ; } this.bJ(true); this.updateBB(); $(this.B).fire("map:resized"); }, eO: function () { var M = 0; var O = 0; if (window.innerWidth) { M = window.innerWidth; O = window.innerHeight; } else { M = document.compatMode == 'CSS1Compat' ? document.documentElement.clientWidth : document.body.clientWidth; O = document.compatMode == 'CSS1Compat' ? document.documentElement.clientHeight : document.body.clientHeight; } if (M % 2) { M--; } if (O % 2) { O--; } aQ = this.cp($(this.B)); aS = this.cq($(this.B)); this.I = M - aS; this.F = O - aQ; }, ew: function (load, F, I) { this.aT(); var user = false; if (F != null) { var M = I; var O = F; user = true; } else { var M = 0; var O = 0; if (window.innerWidth) { M = window.innerWidth; O = window.innerHeight; } else { M = document.compatMode == 'CSS1Compat' ? document.documentElement.clientWidth : document.body.clientWidth; O = document.compatMode == 'CSS1Compat' ? document.documentElement.clientHeight : document.body.clientHeight; } if (M % 2) { M--; } if (O % 2) { O--; } } this.I = M; this.F = O; aQ = this.cp($(this.B)); aS = this.cq($(this.B)); if (user) { $(this.B).style.width = M + "px"; $(this.B).style.height = O + "px"; if (this.ak != null) { this.ak.element.width = M - aS; this.ak.element.height = O - aQ; } } else { $(this.B).style.width = M - aS + "px"; $(this.B).style.height = O - aQ + "px"; if (this.ak != null) { this.ak.element.width = M - aS; this.ak.element.height = O - aQ; } } if (F == null) { this.I = M - aS; this.F = O - aQ; } this.bJ(false); $(this.B).fire("map:resized"); }, cG: function () { for (var i = 0; i < this.H.length; i++) { if (this.H[i].type != 'wmsoverlay') { for (var c = 0; c < this.H[i].tiles.length; c++) { for (var r = 0; r < this.H[i].tiles[c].length; r++) { var A = this.H[i].tiles[c][r]; this.dz(A); } } } } }, ef: function (K) { return { 'x': Event.pointerX(K) - this.cq($(this.B)), 'y': Event.pointerY(K) - this.cp($(this.B)) }; }, bJ: function (cP) { if (this.F == 0) this.F = 200; if (this.I == 0) this.I = 200; var rows = Math.ceil(this.F / this.ag) + 1; var cols = Math.ceil(this.I / this.ag) + 1; this.fD = rows; this.fE = cols; for (var i = 0; i < this.H.length; i++) { this.H[i].tiles = []; if (this.H[i].visible == true) { for (var c = 0; c < cols; c++) { var dg = []; var tX = NGTools.ec(this.v.left, this.v.top)[0]; var tY = NGTools.ec(this.v.left, this.v.top)[1]; var remX = NGTools.eb(this.v.left, this.v.top)[0]; var remY = NGTools.eb(this.v.left, this.v.top)[1]; this.al = -remX; this.aj = -remY; for (var r = 0; r < rows; r++) { var A = { 'element': null, 'qk': 0, 'posx': 256 * c, 'posy': 256 * r, 'tx': tX + c, 'ty': tY + r, 'xIndex': c, 'yIndex': r, 'layer': this.H[i] }; dg.push(A); } this.H[i].tiles.push(dg); } } } this.bD({ 'x': 0, 'y': 0 }, cP); }, bD: function (aa, cP) { if (!aa) { aa = { 'x': 0, 'y': 0 }; } this.bq.style.top = aa.y + "px"; this.bq.style.left = aa.x + "px"; for (i = 0; i < this.bM.length; i++) { var overlay = this.bM[i]; } for (i = 0; i < this.bL.length; i++) { var overlay = this.bL[i]; overlay.style.left = aa.x + 'px'; overlay.style.top = aa.y + 'px'; } this.bb.style.top = this.dP + aa.y + 'px'; this.bb.style.left = this.dQ + aa.x + 'px'; for (i = 0; i < this.U.length; i++) { var l = this.U[i]; l.element.style.left = l.x + aa.x + 'px'; l.element.style.top = l.y + aa.y + 'px'; } for (var i = 0; i < this.H.length; i++) { if (this.H[i].type != 'wmsoverlay') { for (var c = 0; c < this.H[i].tiles.length; c++) { for (var r = 0; r < this.H[i].tiles[c].length; r++) { var A = this.H[i].tiles[c][r]; A.posx = (A.xIndex * this.ag) + this.al + aa.x; A.posy = (A.yIndex * this.ag) + this.aj + aa.y; var ci = true; if (A.posx > this.I) { do { A.xIndex -= this.H[i].tiles.length; A.tx -= this.H[i].tiles.length; A.posx = (A.xIndex * this.ag) + this.al + aa.x; } while (A.posx > this.I); if (A.posx + this.ag < 0) { ci = false; } } else { while (A.posx < -this.ag) { A.xIndex += this.H[i].tiles.length; A.tx += this.H[i].tiles.length; A.posx = (A.xIndex * this.ag) + this.al + aa.x; } if (A.posx > this.I) { ci = false; } } if (A.posy > this.F) { do { A.yIndex -= this.H[i].tiles[c].length; A.ty -= this.H[i].tiles[c].length; A.posy = (A.yIndex * this.ag) + this.aj + aa.y; } while (A.posy > this.F); if (A.posy + this.ag < 0) { ci = false; } } else { while (A.posy < -this.ag) { A.yIndex += this.H[i].tiles[c].length; A.ty += this.H[i].tiles[c].length; A.posy = (A.yIndex * this.ag) + this.aj + aa.y; } if (A.posy > this.F) { ci = false; } } if (cP && ci) { this.dz(A); } if (A.element) { A.element.style.top = A.posy + 'px'; A.element.style.left = A.posx + 'px'; } } } } } }, addNavigationGUI: function (gui) { gui.mapControl = this; this.aO.appendChild(gui.element); gui.element.style.zIndex = 2; }, addDrawCanvas: function (canvasIn) { this.ak = canvasIn; this.ak.parent = this; var av = this.B + 'canvas'; this.ak.element.setAttribute('id', av); this.bq.appendChild(this.ak.element); var M = 0; var O = 0; if (window.innerWidth) { M = window.innerWidth; O = window.innerHeight; } else { M = document.compatMode == 'CSS1Compat' ? document.documentElement.clientWidth : document.body.clientWidth; O = document.compatMode == 'CSS1Compat' ? document.documentElement.clientHeight : document.body.clientHeight; } this.ak.element.width = this.I; this.ak.element.height = this.F; if (/msie/i.test(navigator.userAgent)) { var hack = G_vmlCanvasManager.initElement(this.getDrawCanvas().element); this.getDrawCanvas().element = hack; this.getDrawCanvas().useex = true; } canvas = this.ak.element; this.ak.surface = canvas.getContext("2d"); }, getDrawCanvas: function () { return this.ak; }, by: function (ae, mouse) { var ae = ae.transform('EPSG:4326'); screenCoords = this.llToScreen(ae); if (mouse) { var diffX = this.C.x; var diffY = this.C.y; var aa = { 'x': Math.floor((diffX - screenCoords.x)), 'y': Math.floor(diffY - screenCoords.y) }; } else { var diffX = this.I / 2; var diffY = this.F / 2; var aa = { 'x': Math.floor((diffX - screenCoords.x)), 'y': Math.floor(diffY - screenCoords.y) }; } this.dR(); this.bD(aa, true); this.release(aa, false); }, centerOnCoords: function (ae, mouse) { var ae = ae.transform('EPSG:4326'); screenCoords = this.llToScreen(ae); if (mouse) { var diffX = this.C.x; var diffY = this.C.y; var aa = { 'x': Math.floor((diffX - screenCoords.x)), 'y': Math.floor(diffY - screenCoords.y) }; } else { var diffX = this.I / 2; var diffY = this.F / 2; var aa = { 'x': Math.floor((diffX - screenCoords.x)), 'y': Math.floor(diffY - screenCoords.y) }; } this.dR(); this.bD(aa, true); this.release(aa, false); }, addAnnotation: function (l) { l.coordinate = this.bn(l.coordinate); screenCoords = this.llToScreen(l.coordinate); var div = document.createElement('div'); div.setAttribute('id', l.id); var img = document.createElement('img'); $(img).addClassName("annotationIcon"); l.element = div; l.parent = this; Event.observe(l.element, 'click', l.cQ.bindAsEventListener(l)); Event.observe(l.element, 'mouseover', l.cX.bindAsEventListener(l)); Event.observe(l.element, 'mouseout', l.cN.bindAsEventListener(l)); Event.observe(l.element, 'mouseup', l.cH.bindAsEventListener(l)); Event.observe(l.element, 'mousedown', l.cW.bindAsEventListener(l)); img.src = l.iconURL; div.style.position = "absolute"; div.style.left = screenCoords.x + l.xOffset + 'px'; div.style.top = screenCoords.y + l.yOffset + 'px'; l.x = screenCoords.x + l.xOffset; l.y = screenCoords.y + l.yOffset; div.appendChild(img); l.img = img; div.appendChild(img); this.aO.appendChild(l.element); l.element.style.zIndex = 1; this.U.push(l); return l.id; }, llToScreen: function (P) { var latlon = P.transform('EPSG:4326'); var pX = NGTools.aF(latlon.y, latlon.x, this.o)[0]; var pY = NGTools.aF(latlon.y, latlon.x, this.o)[1]; pX = pX - this.v.left; pY = pY - this.v.top; return new Coordinate(pX, pY); }, removeAnnotation: function (id) { for (var i = 0; i < this.U.length; i++) { var l = this.U[i]; if (l.id == id) { this.aO.removeChild(l.element); this.U.splice(i, 1); return; } } }, removeAnnotationGroup: function (fm) { var removed = 0; do { removed = 0; for (var i = 0; i < this.U.length; i++) { var l = this.U[i]; if (l.group == fm) { this.aO.removeChild(l.element); this.U.splice(i, 1); removed = 1; break; } } } while (removed == 1); }, getAnnotation: function (id) { for (i = 0; i < this.U.length; i++) { var l = this.U[i]; if (l.id == id) { return l; } } }, getAnnotations: function () { return this.U; }, hasValue: function (cr) { return (typeof cr != "undefined") && cr != null && (typeof cr == "string" ? cr != "" : true); }, showAnnotationPopup: function (l) { if ((this.cs && this.bW != WAAnnotationOpenBehaviour.Disable) && (this.hasValue(l.title) || this.hasValue(l.description))) { this.bb.innerHTML = l.title + '<p>' + l.description + '</p>'; var bu = 0; var bw = 0; if (l.x > this.I - 250) { bu = -275; } else { bu = 25; } if (l.y < 150) { bw = 0; } else { bw = -150; } this.bb.style.top = l.y + bw + 'px'; this.bb.style.left = l.x + bu + 'px'; this.dQ = l.x + bu; this.dP = l.y + bw; if (this.bW == WAAnnotationOpenBehaviour.Hover) { this.popupTimerId = setTimeout((function () { $(this.B + 'annotation_popup').style.display = 'block'; $(this.B).fire("map:annotationOpened", { 'annotation': l, 'element': this.bb }); }).bind(this), 700); } else { this.bb.style.display = "block"; $(this.B).fire("map:annotationOpened", { 'annotation': l, 'element': this.bb }); } } }, hideAnnotationPopup: function (l) { clearTimeout(this.popupTimerId); $(this.B + 'annotation_popup').style.display = 'none'; }, addLayer: function (bH) { bH.id = "layer_" + this.H.length; this.H.push(bH); if (this.dV == true) { this.aT(); this.bJ(true); if (bH.type == "wmsoverlay") this.dN(); } return bH.id; }, removeLayer: function (eY) { for (var i = 0; i < this.H.length; i++) { if (this.H[i].id == eY) { this.H.splice(i, 1); return; } } }, showLayer: function (id, zindex) { for (var i = 0; i < this.H.length; i++) { if (this.H[i].id == id) { if (zindex) { this.H[i].zindex = zindex; } if (this.H[i].visible == false) { this.H[i].visible = true; this.aT(); this.bJ(true); } } } }, hideLayer: function (id) { for (var i = 0; i < this.H.length; i++) { if (this.H[i].id == id) if (this.H[i].visible == true) { this.H[i].visible = false; this.aT(); this.bJ(true); } } this.cG(); }, getLayers: function () { return this.H; }, fl: function (aa) { for (i = 0; i < this.U.length; i++) { var l = this.U[i]; l.x = l.x + aa.x; l.y = l.y + aa.y; } }, dR: function () { for (var i = 0; i < this.U.length; i++) { l = this.U[i]; screenCoords = this.llToScreen(l.coordinate); l.x = screenCoords.x + l.xOffset; l.y = screenCoords.y + l.yOffset; l.element.style.left = l.x + 'px'; l.element.style.top = l.y + 'px'; } }, refreshAnnotations: function () { for (var i = 0; i < this.U.length; i++) { var l = this.U[i]; if (l.upperbound < this.o || l.lowerbound > this.o) { l.element.style.display = 'none'; } else { l.element.style.display = 'block'; } var screenCoords = this.llToScreen(l.coordinate); l.x = screenCoords.x + l.xOffset; l.y = screenCoords.y + l.yOffset; l.element.style.left = l.x + 'px'; l.element.style.top = l.y + 'px'; } }, fB: function (annotation) { var l = annotation; if (l.upperbound < this.o || l.lowerbound > this.o) { l.element.style.display = 'none'; } else { l.element.style.display = 'block'; } var screenCoords = this.geoToScreenCoordinates(l.coordinate); l.x = screenCoords.x + l.xOffset; l.y = screenCoords.y + l.yOffset; l.element.style.left = l.x + 'px'; l.element.style.top = l.y + 'px'; }, clearAnnotations: function () { for (var i = 0; i < this.U.length; i++) { var l = this.U[i]; this.aO.removeChild(l.element); } this.U = []; }, disableZoom: function () { this.bZ = true; }, enableZoom: function () { this.bZ = false; }, zoomIn: function (P) { if (this.o < this.bC) { this.aT(); if (!this.af) { lat = NGTools.ad(this.v.top + this.F / 2, this.o); lon = NGTools.ac(this.v.left + this.I / 2, this.o); this.af = new Coordinate(lon, lat, 'EPSG:4326'); } if (P) { P = this.bn(P); this.af = P; } this.al = 0; this.aj = 0; this.o = parseInt(this.o) + 1; this.bF(this.af); this.by(this.af, false); $(this.B).fire("map:zoomedIn", { 'boundingBox': this.at }); $(this.B).fire("map:zoomed", { "zoomLevel": this.getZoomLevel() }); } }, zoomOut: function (P) { if (this.o > this.bO) { this.aT(); if (!this.af) { lat = NGTools.ad(this.v.top + this.F / 2, this.o); lon = NGTools.ac(this.v.left + this.I / 2, this.o); this.af = new Coordinate(lon, lat, 'EPSG:4326'); } if (P) { P = this.bn(P); this.af = P; } this.al = 0; this.aj = 0; this.o = parseInt(this.o) - 1; this.bF(this.af); this.by(this.af, false); $(this.B).fire("map:zoomedOut", { 'boundingBox': this.at }); $(this.B).fire("map:zoomed", { "zoomLevel": this.getZoomLevel() }); } }, mouseZoomIn: function () { if (this.o < this.bC) { this.aT(); var aE = null; var lat; var lon; if (!this.af && !this.bA) { lat = NGTools.ad(this.v.top + this.F / 2, this.o); lon = NGTools.ac(this.v.left + this.I / 2, this.o); aE = new Coordinate(lon, lat, 'EPSG:4326'); } if (this.bA) { lat = NGTools.ad(this.v.top + this.C.y, this.o); lon = NGTools.ac(this.v.left + this.C.x, this.o); aE = new Coordinate(lon, lat, 'EPSG:4326'); } this.al = 0; this.aj = 0; if (aE != null) { this.af = aE; } this.o = parseInt(this.o) + 1; this.bF(this.af); this.by(this.af, this.bA); $(this.B).fire("map:zoomedIn", { 'boundingBox': this.at }); $(this.B).fire("map:zoomed", { "zoomLevel": this.getZoomLevel() }); } }, mouseZoomOut: function () { if (this.o > this.bO) { this.aT(); var aE = null; var lat; var lon; if (!this.af && !this.bA) { lat = NGTools.ad(this.v.top + this.F / 2, this.o); lon = NGTools.ac(this.v.left + this.I / 2, this.o); aE = new Coordinate(lon, lat, 'EPSG:4326'); } if (this.bA) { lat = NGTools.ad(this.v.top + this.C.y, this.o); lon = NGTools.ac(this.v.left + this.C.x, this.o); aE = new Coordinate(lon, lat, 'EPSG:4326'); } this.al = 0; this.aj = 0; if (aE != null) { this.af = aE; } this.o = parseInt(this.o) - 1; this.bF(this.af); this.by(this.af, this.bA); $(this.B).fire("map:zoomedIn", { 'boundingBox': this.at }); $(this.B).fire("map:zoomed", { "zoomLevel": this.getZoomLevel() }); } }, zoom: function (level, P) { if (level >= this.bO && level <= this.bC) { this.aT(); if (!this.af) { lat = NGTools.ad(this.v.top + this.F / 2, this.o); lon = NGTools.ac(this.v.left + this.I / 2, this.o); this.af = new Coordinate(lon, lat, 'EPSG:4326'); } if (P) { P = this.bn(P); this.af = P; } this.al = 0; this.aj = 0; this.o = parseInt(level); this.bF(this.af); this.by(this.af, false); $(this.B).fire("map:zoomed", { "zoomLevel": this.getZoomLevel() }); } }, centerAndZoom: function (aE, level) { if (level == this.o) this.by(aE, false); else this.zoom(level, aE); }, zoomOnBoundingBox: function (ae, center, dc) { var ev = ae.x2 - ae.x1; var en = ae.y2 - ae.y1; var fG = this.I / 2; var fy = this.F / 2; var bf = new Coordinate(ae.x1 + (ev / 2), ae.y1 + (en / 2), 'EPSG:4326'); for (var i = this.bC; i >= this.bO; i--) { var pX = NGTools.aF(bf.y, bf.x, i)[0]; var pY = NGTools.aF(bf.y, bf.x, i)[1]; var df = { 'bottom': pY + this.F / 2, 'left': pX - this.I / 2, 'top': pY - this.F / 2, 'right': pX + this.I / 2 }; var bottomLeft = NGTools.aF(ae.y1, ae.x1, i); var upperRight = NGTools.aF(ae.y2, ae.x2, i); var dI = { 'bottom': bottomLeft[1], 'left': bottomLeft[0], 'top': upperRight[1], 'right': upperRight[0] }; if (df.left < dI.left && df.bottom > dI.bottom) { if (this.o == i && !center) { return { 'zoom': i, 'coordinate': bf }; } if (!dc && this.o < this.bC) { this.zoom(i, bf); } return { 'zoom': i, 'coordinate': bf }; } } if (!dc) { this.zoom(i, bf); } return { 'zoom': i, 'coordinate': bf }; }, zoomOnAnnotations: function () { if (this.U.length == 0) { return; } var x1 = this.U[0].coordinate.transform('EPSG:4326').x; var y1 = this.U[0].coordinate.transform('EPSG:4326').y; var x2 = this.U[0].coordinate.transform('EPSG:4326').x; var y2 = this.U[0].coordinate.transform('EPSG:4326').y; var tmpCoordinate = null; for (i = 0; i < this.U.length; i++) { tmpCoordinate = this.U[i].coordinate.transform('EPSG:4326'); if (tmpCoordinate.x > x2) { x2 = tmpCoordinate.x; } if (tmpCoordinate.x < x1) { x1 = tmpCoordinate.x; } if (tmpCoordinate.y > y2) { y2 = tmpCoordinate.y; } if (tmpCoordinate.y < y1) { y1 = tmpCoordinate.y; } } this.zoomOnBoundingBox({ 'x1': x1, 'y1': y1, 'x2': x2, 'y2': y2 }, true); }, eP: function () { this.aV.style.position = "absolute"; this.aV.style.zIndex = 10; this.aV.style.overflow = "hidden"; var cc = document.getElementById(this.B); var m = document.createElement('div'); var av = this.B + 'tilelayer'; m.innerHTML = '<!-- -->'; m.setAttribute('id', av); this.aV.appendChild(m); m.style.position = "absolute"; m.style.top = "0px"; m.style.left = "0px"; m.style.width = "100%"; m.style.height = "100%"; m.style.overflow = "hidden"; this.cj = m; var cc = document.getElementById(this.B); var m = document.createElement('div'); var av = this.B + 'staticdrawlayer'; m.innerHTML = '<!-- -->'; m.setAttribute('id', av); m.style.position = "absolute"; m.style.top = "0px"; m.style.left = "0px"; m.style.width = "100%"; m.style.height = "100%"; m.style.zIndex = 1000; this.aV.appendChild(m); this.dr = m; var cc = document.getElementById(this.B); var m = document.createElement('div'); var av = this.B + 'drawlayer'; m.innerHTML = '<!-- -->'; m.setAttribute('id', av); m.style.position = "absolute"; m.style.top = "0px"; m.style.left = "0px"; m.style.width = "100%"; m.style.height = "100%"; m.style.zIndex = 1000; this.aV.appendChild(m); this.bq = m; var cc = document.getElementById(this.B); var m = document.createElement('div'); var av = this.B + 'mouselayer'; m.innerHTML = '<!-- -->'; m.setAttribute('id', av); m.style.position = "absolute"; m.style.top = "0px"; m.style.left = "0px"; m.style.width = "100%"; m.style.height = "100%"; m.style.zIndex = 1000; m.style.overflow = "hidden"; this.aV.appendChild(m); this.aO = m; var cc = document.getElementById(this.B); var m = document.createElement('div'); var av = this.B + 'zoomBox'; m.innerHTML = '<!-- -->'; m.setAttribute('id', av); this.aO.appendChild(m); m.style.position = "absolute"; m.style.border = "solid 1px"; m.style.width = "0px"; m.style.height = "0px"; m.style.top = "0px"; m.style.left = "10px"; m.style.display = 'none'; m.style.zIndex = 2; this.T = m; var m = document.createElement('div'); var av = this.B + 'surface'; m.innerHTML = '<!-- -->'; m.setAttribute('id', av); m.style.position = "absolute"; m.style.top = "0px"; m.style.left = "0px"; m.style.width = "100%"; m.style.height = "100%"; m.style.zIndex = 0; m.style.background = "url(http://tsadm.webatlas.no/sh/2/v/090602/media/interface/default/blank_1px.gif)"; this.aO.appendChild(m); this.cE = m; var cc = document.getElementById(this.B); var m = document.createElement('div'); var av = this.B + 'annotation_popup'; m.innerHTML = '<!-- -->'; m.setAttribute('id', av); this.aO.appendChild(m); m.style.position = "absolute"; m.style.width = "250px"; m.style.height = "150px"; m.style.top = "29px"; m.style.left = "130px"; m.style.display = 'none'; m.style.padding = '10px'; m.style.zIndex = 1000; m.style.backgroundColor = 'white'; m.style.border = 'solid 1px'; this.bb = m; }, dz: function (A) { if (A.layer.lowerBound > this.o || A.layer.upperBound < this.o) return; var cb, bs; if (A.layer.type == 'webatlastile') { var qK = NGTools.fr(A.tx, A.ty, this.o); A.qk = qK; var tsAddress = parseInt(qK.charAt(qK.length - 1)); cb = bs = 'http://ts' + (this.webatlasTileServerLowerBound + tsAddress) + '.webatlas.no/' + A.layer.WATilePath + '/' + A.qk + '.png?s=' + this.bt; } if (A.layer.type == 'osmtile') { cb = bs = 'http://b.tile.openstreetmap.org/' + this.o + '/' + A.tx + '/' + A.ty + '.png'; } else if (A.layer.type == 'wms') { var x1 = NGTools.ac(A.tx * 256, this.o); var x2 = NGTools.ac(A.tx * 256 + 256, this.o); var y1 = NGTools.ad(A.ty * 256 + 256, this.o); var y2 = NGTools.ad(A.ty * 256, this.o); var m1 = this.toMercatorMeters(y1, x1); var m2 = this.toMercatorMeters(y2, x2); cb = bs = A.layer.wmsRequest.url + '?REQUEST=GetMap&SERVICE=' + A.layer.wmsRequest.service + '&SRS=EPSG:54004' + '&VERSION=' + A.layer.wmsRequest.version + '&FORMAT=' + A.layer.wmsRequest.format + '&LAYERS=' + A.layer.wmsRequest.layers + '&STYLES=' + A.layer.wmsRequest.styles + '&TRANSPARENT=' + A.layer.wmsRequest.transparent + '&BGCOLOR=' + A.layer.wmsRequest.bgColor + '&BBOX=' + m1.x + ',' + m1.y + ',' + m2.x + ',' + m2.y + '&WIDTH=256&HEIGHT=256&zoomlevel=' + this.o; } if (A.element != null && A.element.parentNode != null && A.element.relativeSrc != bs) { this.cj.removeChild(A.element); } var bz = this.aL[cb]; if (!bz) { bz = this.aL[cb] = this.eo(bs); } bz.onload = null; if (bz.image) { bz.image.onload = null; } if (!bz.parentNode) { A.element = this.cj.appendChild(bz); } if (A.element != null) { A.element.style.zIndex = A.layer.zIndex; } }, toMercatorMeters: function (lat, lon) { a = 6378137.0; f = 1 / 298.257223563; e = Math.sqrt(2 * f - Math.pow(f, 2)); ctrmerid = 0.0; px = lon * Math.PI / 180; py = lat * Math.PI / 180; pc = ctrmerid * Math.PI / 180; x = a * (px - pc); y = a * (Math.log(Math.tan((45.0 * Math.PI / 180) + py / 2.0) * Math.pow((1.0 - e * Math.sin(py)) / (1.0 + e * Math.sin(py)), e / 2.0))); return new Coordinate(x, y, "EPSG:54004"); }, toggleMapStyle: function () { if (this.bt == 0) { this.bt = 1; } else { this.bt = 0; } this.cG(); this.bD({ 'x': 0, 'y': 0 }); }, eo: function (bs) { var an = document.createElement('img'); an.src = bs; an.alt = "Loading Tile..."; an.relativeSrc = bs; an.className = 'tile'; an.style.width = this.ag + 'px'; an.style.height = this.ag + 'px'; an.style.top = "-256px"; an.style.left = "-256px"; an.style.position = 'absolute'; return an; }, aT: function () { this.hideAnnotationPopup(); this.fa = null; for (fe in this.aL) { var an = this.aL[fe]; an.onload = null; an.src = 'http://tsadm.webatlas.no/sh/2/v/090602/media/interface/blank.png'; if (an.image) { an.image.onload = null; } if (an.parentNode != null) { this.cj.removeChild(an); } } this.aL = {}; this.aL['blank'] = new Image(); this.aL['loading'] = this.aL['blank']; }, release: function (am, cZ) { if (!(am.x + am.y) == 0) { this.bq.style.top = 0 + "px"; this.bq.style.left = 0 + "px"; this.al += am.x; this.aj += am.y; this.fl(am); this.ao = { 'x': 0, 'y': 0 }; this.v.left -= am.x; this.v.right -= am.x; this.v.top -= am.y; this.v.bottom -= am.y; var mouseLat = NGTools.ad(this.v.top + this.C.y, this.o); var mouseLon = NGTools.ac(this.v.left + this.C.x, this.o); this.ar = new Coordinate(mouseLon, mouseLat, 'EPSG:4326'); this.ar = this.ar.transform(this.as); this.updateBB(); $(this.B).fire("map:moved", { 'mouseMapCoords': this.ar, 'mouseCoords': this.C, 'boundingBox': this.at, 'move': am }); if (this.cA == true) $(this.B).fire("map:dragEnd", { 'mouseMapCoords': this.ar, 'mouseCoords': this.C, 'boundingBox': this.at }); this.cA = false; this.updateWMSLayers(); clearTimeout(this.cz); this.cz = setTimeout(this.dm.bind(this), 350); } this.cT = false; this.cE.style.zIndex = '0'; }, updateBB: function () { var eA = this.dC - this.F * this.bV; var eC = this.dD + this.I * this.bV; this.at = { 'bottom': eA, 'left': this.dD, 'top': this.dC, 'right': eC }; var bottom = NGTools.ad(this.v.bottom, this.o); var top = NGTools.ad(this.v.top, this.o); var left = NGTools.ac(this.v.left, this.o); var right = NGTools.ac(this.v.right, this.o); var ll = new Coordinate(left, bottom, 'EPSG:4326'); var ur = new Coordinate(right, top, 'EPSG:4326'); var m1 = this.toMercatorMeters(ll.y, ll.x); var m2 = this.toMercatorMeters(ur.y, ur.x); this.bp = { 'bottom': m1.y, 'left': m1.x, 'top': m2.y, 'right': m2.x }; ll = this.bn(ll); ur = this.bn(ur); this.at = { 'bottom': ll.y, 'left': ll.x, 'top': ur.y, 'right': ur.x }; clearTimeout(this.cz); this.cz = setTimeout(this.dm.bind(this), 350); }, dm: function () { if (this.dk == true) { var an = document.createElement('img'); var extra = ''; if (this.logClientIP != null && this.logMode.length > 0) { extra = '&ATLASEXTRA=clientip~' + this.logClientIP + '_addressid~' + this.logAddressID + '_custid~' + this.logCustID + '_mode~' + this.logMode; } an.src = "maphandlers/mapusage.ashx?" + "WMS-REQUEST=BBOX=" + this.at.left + "," + this.at.bottom + "," + this.at.right + "," + this.at.top + "&MAPSTYLE=" + this.bt + "&ZOOMLEVEL=" + AJAXMAP.ZOOMLEVELS[this.o] + "&PROVIDER=" + this.bT + "&CUSTOMER=" + this.bT + "&SERVER=" + this.webatlasTileServerLowerBound + extra; an = null; } }, disableLogging: function () { this.dk = false; }, getOSMName: function (db, fo, au) { var eL = parseInt(Math.floor((fo + 180) / 360 * (Math.pow(2, au)))); var eR = parseInt(Math.floor((1 - Math.log(Math.tan(db * Math.PI / 180) + 1 / Math.cos(db * Math.PI / 180)) / Math.PI) / 2 * (Math.pow(2, au)))); return ("" + au + "/" + eL + "/" + eR); }, addWMSLayer: function (bm, dn, dG) { if (bm.id == null) { bm.id = this.aN.length; } eU = dn ? dn : 0; fj = dG ? dG : 99; bm.lb = eU; bm.ub = fj; for (var i = 0; i < this.aN.length; i++) { if (bm.id == this.aN[i].id) { this.aN[i] = bm; this.updateWMSLayers(); return bm.id; } } this.aN.push(bm); this.updateWMSLayers(); return bm.id; }, removeWMSLayer: function (fh) { for (var i = 0; i < this.aN.length; i++) { if (fh == this.aN[i].id) { this.aN.splice(i, 1); this.updateWMSLayers(); return; } } }, updateWMSLayers: function () { var tilelayer = this.bq; for (var i = 0; i < this.bM.length; i++) { tilelayer.removeChild(this.bM[i]); } this.bM = []; for (var i = 0; i < this.aN.length; i++) { var req = this.aN[i]; if (req.lb <= this.o && req.ub >= this.o) { var img = document.createElement('img'); var url = req.url; var aH = $H({ "REQUEST": "GetMap", "SERVICE": req.service, "VERSION": req.version, "SRS": "EPSG:54004", "FORMAT": req.format, "LAYERS": req.layers, "TRANSPARENT": "true", "STYLES": req.styles, "WIDTH": this.I, "HEIGHT": this.F, "BBOX": [this.bp.left, this.bp.bottom, this.bp.right, this.bp.top].join(',') }); if (typeof (req.sendPixelValues) != 'undefined') if (req.sendPixelValues == true) { aH.set('ZOOMLEVEL', this.o); aH.set('PIXELLEFT', parseInt(this.v.left)); aH.set('PIXELRIGHT', parseInt(this.v.right)); aH.set('PIXELBOTTOM', parseInt(this.v.bottom)); aH.set('PIXELTOP', parseInt(this.v.top)); } var bB = ""; if (url.indexOf("?") == -1) { bB = "?"; } else if (!(url.endsWith("?") || url.endsWith("&"))) { bB = "&"; } url = url + bB + aH.toQueryString(); img.src = url; img.alt = "Loading custom layer..."; img.relativeSrc = this.aN[i].serverURL; img.className = 'overlay'; img.style.position = 'absolute'; img.style.top = 0 + 'px'; img.style.left = 0 + 'px'; tilelayer.appendChild(img); this.bM.push(img) } } this.dN(); }, dN: function () { var tilelayer = this.cj; for (var i = 0; i < this.bL.length; i++) { tilelayer.removeChild(this.bL[i]); } this.bL = []; for (var i = 0; i < this.H.length; i++) { if (this.H[i].type == 'wmsoverlay') { var req = this.H[i].wmsRequest; var img = document.createElement('img'); var url = req.url; var aH = $H({ "REQUEST": "GetMap", "SERVICE": req.service, "VERSION": req.version, "SRS": "EPSG:54004", "FORMAT": req.format, "LAYERS": req.layers, "TRANSPARENT": "true", "STYLES": req.styles, "WIDTH": this.I, "HEIGHT": this.F, "BBOX": [this.bp.left, this.bp.bottom, this.bp.right, this.bp.top].join(',') }); if (typeof (req.sendPixelValues) != 'undefined') if (req.sendPixelValues == true) { aH.set('ZOOMLEVEL', this.o); aH.set('PIXELLEFT', parseInt(this.v.left)); aH.set('PIXELRIGHT', parseInt(this.v.right)); aH.set('PIXELBOTTOM', parseInt(this.v.bottom)); aH.set('PIXELTOP', parseInt(this.v.top)); } var bB = ""; if (url.indexOf("?") == -1) { bB = "?"; } else if (!(url.endsWith("?") || url.endsWith("&"))) { bB = "&"; } url = url + bB + aH.toQueryString(); img.src = url; img.alt = "Loading custom layer..."; img.className = 'overlay'; img.style.position = 'absolute'; img.style.top = 0 + 'px'; img.style.left = 0 + 'px'; img.style.zIndex = this.H[i].zIndex; tilelayer.appendChild(img); this.bL.push(img) } } }, getDistancelatlon: function (ae) { var dH = 0.0; var R = 6371; for (var i = 0; i < ae.length - 1; i++) { var point1 = ae[i]; var point2 = ae[i + 1]; point1 = this.UTMToLatLon(point1); point2 = this.UTMToLatLon(point2); var distance = Math.acos(Math.sin(point1.y * Math.PI / 180) * Math.sin(point2.y * Math.PI / 180) + Math.cos(point1.y * Math.PI / 180) * Math.cos(point2.y * Math.PI / 180) * Math.cos((point2.x - point1.x) * Math.PI / 180)) * R; dH += distance; } return dH; }, getHeight: function () { return this.F; }, getWidth: function () { return this.I; }, getZoomlevelMax: function () { return this.bC; }, getZoomlevelMin: function () { return this.bO; }, setZoomlevelMax: function (au) { this.bC = au; }, setZoomlevelMin: function (au) { this.bO = au; }, setCRS: function (as) { this.as = as; }, getCRS: function (as) { return this.as; }, getDrawLayer: function () { return this.bq; }, getStaticDrawLayer: function () { return this.dr; }, getMouseLayer: function () { return this.aO; }, getMapContainer: function () { return this.B; }, getTrackCoords: function () { tmpcoord = this.trackCoords; this.trackCoords = null; return tmpcoord; }, getCenterCoordinate: function () { var cU = NGTools.ad(this.v.top + this.F / 2, this.o); var fi = NGTools.ac(this.v.left + this.I / 2, this.o); var eK = new Coordinate(fi, cU, 'EPSG:4326'); return eK.transform(this.as); }, getBoundingBox: function () { return this.at; }, setMapStyle: function (eI) { this.bt = eI; this.cG(); this.bD({ 'x': 0, 'y': 0 }); }, disableAnnotationInfo: function () { this.cs = false; }, setAnnotationPopupBehaviour: function (ea, du) { this.bW = ea; if (ea != WAAnnotationOpenBehaviour.Disable) { this.cs = true; } if (typeof du != "undefined") this.dA = du; }, enableAnnotationInfo: function () { this.cs = true; }, getMapStyle: function () { return this.bt; }, getCurrentMouseCoords: function () { return this.C; }, getMouseDownCoords: function () { return this.Q; }, getMouseDownMapCoords: function () { return this.cY.transform(this.as); }, getMouseMapCoords: function () { return this.ar.transform(this.as); ; }, setMouseZoom: function (et) { this.bA = et; }, allowMouseNavigation: function () { this.bP = true; }, disallowMouseNavigation: function () { this.bP = false; }, getZoomLevel: function () { return this.o; }, cp: function (cn) { bQ = cn.offsetTop; aR = cn.offsetParent; while (aR != null) { bQ += aR.offsetTop; if (aR != null) { aR = aR.offsetParent; } } return bQ; }, cq: function (cn) { bQ = cn.offsetLeft; aR = cn.offsetParent; while (aR != null) { bQ += aR.offsetLeft; aR = aR.offsetParent; } return bQ; }, dx: function (K) { if (K.which == null) { dv = (K.button < 2) ? "LEFT" : ((K.button == 4) ? "MIDDLE" : "RIGHT"); } else { dv = (K.which < 2) ? "LEFT" : ((K.which == 2) ? "MIDDLE" : "RIGHT"); } return dv; }, bn: function (P) { return P.transform(this.as); }, geoToScreenCoordinates: function (am) { var latlon = am.transform('EPSG:4326'); var al = NGTools.aF(latlon.y, latlon.x, this.o)[0]; var aj = NGTools.aF(latlon.y, latlon.x, this.o)[1]; return { 'x': al, 'y': aj }; }, geoToLocalScreenCoordinates: function (am) { var latlon = am.transform('EPSG:4326'); var al = NGTools.aF(latlon.y, latlon.x, this.o)[0]; var aj = NGTools.aF(latlon.y, latlon.x, this.o)[1]; al = al - this.v.left; aj = aj - this.v.top; return { 'x': al, 'y': aj }; }, getPixelLatLon: function (pixel) { var lon = NGTools.ac(this.v.left + pixel.x, this.o); var lat = NGTools.ad(this.v.top + pixel.y, this.o); latLon = new Coordinate(lon, lat, 'EPSG:4326'); return latLon; }, decimalDegreesToUTM: function (am) { return am.toUTM(am.x, am.y, am.epsgToZone(this.as)); }, UTMToLatLon: function (cS) { return cS.fromUTM(cS.x, cS.y, '33'); }, getDistance: function (L) { var t = 0.0; for (var i = 0; i < L.length - 1; i++) { var point1 = L[i]; var point2 = L[i + 1]; var distance = Math.sqrt((point2.x - point1.x) * (point2.x - point1.x) + (point1.y - point2.y) * (point1.y - point2.y)); t += distance; } return this.cK(t, 0); }, getCircuit: function (L) { var t = 0.0; if (L.length > 2) { for (var i = 0; i < L.length - 1; i++) { var point1 = L[i]; var point2 = L[i + 1]; var distance = Math.sqrt((point2.x - point1.x) * (point2.x - point1.x) + (point1.y - point2.y) * (point1.y - point2.y)); t += distance; } } if (L.length > 2) { var distance = Math.sqrt((L[L.length - 1].x - L[0].x) * (L[L.length - 1].x - L[0].x) + (L[0].y - L[L.length - 1].y) * (L[0].y - L[L.length - 1].y)); t += distance; } return this.cK(t, 0); }, getArea: function (L) { var t = 0.0; if (L.length > 2) { var numt_points = L.length; t = (L[L.length - 1].x * L[0].y) - (L[0].x * L[L.length - 1].y); for (var i = 0; i < numt_points - 1; i++) { t = t + (L[i].x * L[i + 1].y) - (L[i + 1].x * L[i].y); } t = t / 2; } if (t < 0) { t = -t; } return this.cK(t, 0); }, cK: function (Num, Places) { if (Places > 0) { if ((Num.toString().length - Num.toString().lastIndexOf('.')) > (Places + 1)) { var Rounder = Math.pow(10, Places); return Math.round(Num * Rounder) / Rounder; } else return Num; } else return Math.round(Num); }, dE: function (K) { var bK = 0; if (!K) { K = window.event; } if (K.wheelDelta) { bK = K.wheelDelta / 120; } else if (K.detail) { bK = -K.detail / 3; } if (bK) { this.eZ(bK); } if (K.preventDefault) { K.preventDefault(); } K.returnValue = false; }, eZ: function (bK) { if (!this.bZ) { if (bK < 0) { if (this.bP) this.mouseZoomOut(); } else { if (this.bP) this.mouseZoomIn(); } } } }; function Annotation(am, de, dw, dh, bu, bw, dS, dO, dK) { this.parent = null; this.id = ++annotationStatic.annotationCount; this.coordinate = am; this.title = de ? de : ""; this.description = dw ? dw : ""; this.lowerbound = dS ? dS : 0; this.upperbound = dO ? dO : 99; this.xOffset = bu ? parseInt(bu) : 0; this.yOffset = bw ? parseInt(bw) : 0; this.group = dK ? dK : 0; this.x = 0; this.y = 0; this.img = null; this.iconURL = dh ? dh : 'http://www.webatlas.no/webatlasapi/v/071009/media/interface/default/markers/flag_blue.gif'; this.element = null; }; var annotationStatic = { 'annotationCount': 0 }; Annotation.prototype = { cQ: function (K) { if (this.parent.bW == WAAnnotationOpenBehaviour.Click) { this.parent.showAnnotationPopup(this); } $(this.element).fire("annotation:mouseClicked", { 'annotation': this }); }, cH: function (K) { $(this.element).fire("annotation:mouseUp", { 'annotation': this, 'mouseMapCoords': this.parent.ar, 'mouseCoords': this.parent.C }); }, cW: function (K) { $(this.element).fire("annotation:mouseDown", { 'annotation': this, 'mouseMapCoords': this.parent.ar, 'mouseCoords': this.parent.C }); }, cN: function (K) { $(this.element).fire("annotation:mouseOut", { 'annotation': this }); if (this.parent.dA == WAAnnotationCloseBehaviour.IconMouseOut) { this.parent.hideAnnotationPopup(); } }, cX: function (K) { $(this.element).fire("annotation:mouseIn", { 'annotation': this }); if (this.parent.bW == WAAnnotationOpenBehaviour.Hover) { this.parent.showAnnotationPopup(this); } } }; function Layer(aq) { this.type = aq.type ? aq.type : 'webatlastile'; this.name = aq.name ? aq.name : ''; this.zIndex = aq.zIndex ? aq.zIndex : 0; this.wmsRequest = aq.wmsrequest ? aq.wmsrequest : null; if (aq.visible != 'undefined' && aq.visible != null) this.visible = aq.visible; else this.visible = true; this.lowerBound = aq.lowerBound ? aq.lowerBound : 0; this.upperBound = aq.upperBound ? aq.upperBound : 99; this.WATilePath = aq.WATilePath ? aq.WATilePath : 'qt_basic'; }; Layer.prototype = {}; function Coordinate(al, aj, as) { this.x = al; this.y = aj; this.lat = aj; this.lon = al; this.srs = as ? as : 'EPSG:32633'; }; Coordinate.prototype = { toUTM: function (x, y, zone) { var eg = parseFloat(x); var cU = parseFloat(y); var bE = Math.PI; var fC = bE / 4; var cv = bE / 180; var cB = 180.0 / bE; var bN = 6378137; var J = 0.00669438; var bY = 0.9996; var bS; var bj; var cJ; var aY; var bv; var ah; var ca; var eT = (eg + 180) - parseInt((eg + 180) / 360) * 360 - 180; var aJ = cU * cv; var eW = eT * cv; var ee; var bR; bR = Math.abs(zone); bS = (bR - 1) * 6 - 180 + 3; ee = bS * cv; bj = (J) / (1 - J); cJ = bN / Math.sqrt(1 - J * Math.sin(aJ) * Math.sin(aJ)); aY = Math.tan(aJ) * Math.tan(aJ); bv = bj * Math.cos(aJ) * Math.cos(aJ); ah = Math.cos(aJ) * (eW - ee); ca = bN * ((1 - J / 4 - 3 * J * J / 64 - 5 * J * J * J / 256) * aJ - (3 * J / 8 + 3 * J * J / 32 + 45 * J * J * J / 1024) * Math.sin(2 * aJ) + (15 * J * J / 256 + 45 * J * J * J / 1024) * Math.sin(4 * aJ) - (35 * J * J * J / 3072) * Math.sin(6 * aJ)); var eu = (bY * cJ * (ah + (1 - aY + bv) * ah * ah * ah / 6 + (5 - 18 * aY + aY * aY + 72 * bv - 58 * bj) * ah * ah * ah * ah * ah / 120) + 500000.0); var dM = (bY * (ca + cJ * Math.tan(aJ) * (ah * ah / 2 + (5 - aY + 9 * bv + 4 * bv * bv) * ah * ah * ah * ah / 24 + (61 - 58 * aY + aY * aY + 600 * bv - 330 * bj) * ah * ah * ah * ah * ah * ah / 720))); if (zone < 0) dM += 10000000.0; return new Coordinate(eu, dM, zone >= 0 ? "EPSG:326" + zone : "EPSG:327" + (-zone)); }, fromUTM: function (x, y, zone) { var bE = Math.PI; var cv = bE / 180; var cB = 180.0 / bE; var bY = 0.9996; var bN = 6378137; var J = 0.00669438; var bj = (J) / (1 - J); var aI = (1 - Math.sqrt(1 - J)) / (1 + Math.sqrt(1 - J)); var cI, ba, aM, dT, ai, ca; var bS; var cl, es, aG; var bR = zone; var y0 = 0; if (bR < 0) { y0 = 10000000.0; } bS = (bR - 1) * 6 - 180 + 3; ca = (y - y0) / bY; cl = ca / (bN * (1 - J / 4 - 3 * J * J / 64 - 5 * J * J * J / 256)); aG = cl + (3 * aI / 2 - 27 * aI * aI * aI / 32) * Math.sin(2 * cl) + (21 * aI * aI / 16 - 55 * aI * aI * aI * aI / 32) * Math.sin(4 * cl) + (151 * aI * aI * aI / 96) * Math.sin(6 * cl); es = aG * cB; cI = bN / Math.sqrt(1 - J * Math.sin(aG) * Math.sin(aG)); ba = Math.tan(aG) * Math.tan(aG); aM = bj * Math.cos(aG) * Math.cos(aG); dT = bN * (1 - J) / Math.pow(1 - J * Math.sin(aG) * Math.sin(aG), 1.5); ai = (x - 500000.0) / (cI * bY); Lat = aG - (cI * Math.tan(aG) / dT) * (ai * ai / 2 - (5 + 3 * ba + 10 * aM - 4 * aM * aM - 9 * bj) * ai * ai * ai * ai / 24 + (61 + 90 * ba + 298 * aM + 45 * ba * ba - 252 * bj - 3 * aM * aM) * ai * ai * ai * ai * ai * ai / 720); Lat = Lat * cB; Long = (ai - (1 + 2 * ba + aM) * ai * ai * ai / 6 + (5 - 2 * aM + 28 * ba - 3 * aM * aM + 8 * bj + 24 * ba * ba) * ai * ai * ai * ai * ai / 120) / Math.cos(aG); Long = bS + Long * cB; return new Coordinate(Long, Lat, "EPSG:4326"); }, epsgToZone: function (epsg_code) { if (epsg_code.indexOf("EPSG:") == 0) { if (epsg_code.substr(5, 3) == "326") return parseInt(epsg_code.substr(8, 3)); if (epsg_code.substr(5, 3) == "327") return -parseInt(epsg_code.substr(8, 3)); } return 0; }, transform: function (to_srs) { if (this.srs == to_srs) return new Coordinate(this.x, this.y, this.srs); var from_zone = this.epsgToZone(this.srs); var to_zone = this.epsgToZone(to_srs); if (from_zone == 0 && this.srs != "EPSG:4326") throw "Unknown coordinate system: " + this.srs; if (to_zone == 0 && to_srs != "EPSG:4326") throw "Unknown coordinate system: " + to_srs; if (from_zone == 0 && to_zone != 0) return this.toUTM(this.x, this.y, to_zone); if (from_zone != 0 && to_zone == 0) return this.fromUTM(this.x, this.y, from_zone); if (from_zone != 0 && to_zone != 0) { var geo = this.fromUTM(this.x, this.y, from_zone); return geo.toUTM(geo.x, geo.y, to_zone); } throw "Unable to transform between " + this.srs + " and " + to_srs; } }; function Move(al, aj) { this.x = al; this.y = aj; }; Move.prototype = {}; function WMSRequest(el, H, dy, dj, di, dL, dF, dB) { this.id = ++WMSRequestStatic.WMSRequestCount; this.url = el; this.layers = H; this.format = dy ? dy : 'image/png'; this.service = dj ? dj : 'WMS'; this.styles = di ? di : ''; this.version = dL ? dL : '1.1'; this.transparent = dF ? dF : 'true'; this.bgColor = dB ? dB : '0xFFFFFF'; this.srs = 'EPSG:54004'; }; var WMSRequestStatic = { 'WMSRequestCount': 0 }; WMSRequest.prototype = { addLayer: function (bH) { this.layers += ',' + bH; } }; function WAPICanvas() { var m = document.createElement('canvas'); m.setAttribute('width', 100); m.setAttribute('height', 100); m.style.position = "absolute"; m.style.top = "0px"; m.style.left = "0px"; m.style.width = "100%"; m.style.height = "100%"; m.style.zIndex = 1000; this.element = m; this.surface = null; this.lines = []; this.parent = null; this.D = { 'X': 0, 'Y': 0 }; this.G = { 'X': 200, 'Y': 200 }; this.useex = false; this.m_groups = new Hash(); this.m_defaultGroupName = "_default"; Event.observe(document, 'map:resized', this.redraw.bindAsEventListener(this)); Event.observe(document, 'map:moved', this.redraw.bindAsEventListener(this)); Event.observe(document, 'map:zoomed', this.redraw.bindAsEventListener(this)); }; WAPICanvas.prototype = { addPolyLine: function (fp, ab) { ab = this._parseOptions(ab); var aP = this.m_groups.get(ab.group); if (aP == null) { aP = []; this.m_groups.set(ab.group, aP); } aP.push(fp); if (typeof !ab.supressRedraw == 'undefined' || !ab.supressRedraw) this.redraw(); }, redraw: function () { this.surface.clearRect(0, 0, this.element.width, this.element.height); this.D = { 'X': 0, 'Y': 0 }; this.G = { 'X': this.parent.getWidth(), 'Y': this.parent.getHeight() }; var dJ = this.m_groups.values(); for (var g = 0; g < dJ.length; g++) { var aP = dJ[g]; for (var i = 0; i < aP.length; i++) { this.surface.beginPath(); this.surface.strokeStyle = aP[i].rgba; this.surface.lineWidth = aP[i].lineWidth; this.surface.lineCap = 'round'; var ce = []; for (var j = 0; j < aP[i].coordinates.length; j++) { var cC = this.parent.geoToLocalScreenCoordinates(aP[i].coordinates[j]); ce.push(cC); } for (var j = 0; j < ce.length; j++) { if (j != ce.length - 1) { var cC = ce[j]; var eh = ce[j + 1]; var lineSegment = { 'Start': { 'X': parseInt(cC.x), 'Y': parseInt(cC.y) }, 'End': { 'X': parseInt(eh.x), 'Y': parseInt(eh.y)} }; lineSegment.Dy = lineSegment.End.Y - lineSegment.Start.Y; lineSegment.Dx = lineSegment.End.X - lineSegment.Start.X; var intersects = true; var skipPoint = false; if (lineSegment.Start.X == lineSegment.End.X && lineSegment.Start.Y == lineSegment.End.Y) skipPoint = true; if (skipPoint == false) { if (this.surface.useex) intersects = this.clipLine(lineSegment); if (intersects == true) { this.surface.moveTo(lineSegment.Start.X, lineSegment.Start.Y); this.surface.lineTo(lineSegment.End.X, lineSegment.End.Y); } } } } this.surface.stroke(); } } }, clear: function (ab) { ab = this._parseOptions(ab); if (ab.group == this.m_defaultGroupName) { this.m_groups = new Hash(); } else this.m_groups.unset(ab.group); if (!ab.supressRedraw) this.redraw(); }, _parseOptions: function (ab) { var bX = false; var ct = this.m_defaultGroupName; var co = typeof ab; if (co != "undefined") { if (co == "boolean") { bX = ab; } else if (co == "string" && (ab == "true" || ab == "false")) { bX = ab == "true"; } else if (co == "string") { ct = ab; } else { var cd = ab.supressRedraw; bX = typeof cd == "boolean" ? cd : bX; cd = ab.group; ct = typeof cd == "string" ? cd : ct; } } return { supressRedraw: bX, group: ct }; }, aB: function (line) { line.Start.X += line.Dx * (this.D.Y - line.Start.Y) / line.Dy; line.Start.Y = this.D.Y; }, az: function (line) { line.Start.X += line.Dx * (this.G.Y - line.Start.Y) / line.Dy; line.Start.Y = this.G.Y; }, ay: function (line) { line.Start.Y += line.Dy * (this.G.X - line.Start.X) / line.Dx; line.Start.X = this.G.X; }, aA: function (line) { line.Start.Y += line.Dy * (this.D.X - line.Start.X) / line.Dx; line.Start.X = this.D.X; }, aD: function (line) { line.End.X += line.Dx * (this.D.Y - line.End.Y) / line.Dy; line.End.Y = this.D.Y; }, aw: function (line) { line.End.X += line.Dx * (this.G.Y - line.End.Y) / line.Dy; line.End.Y = this.G.Y; }, ax: function (line) { line.End.Y += line.Dy * (this.G.X - line.End.X) / line.Dx; line.End.X = this.G.X; }, aC: function (line) { line.End.Y += line.Dy * (this.D.X - line.End.X) / line.Dx; line.End.X = this.D.X; }, clipt_line: function (k) { var aX = 0; if (k.End.Y < this.D.Y) aX += 8; else if (k.End.Y > this.G.Y) aX += 4; if (k.End.X > this.G.X) aX += 2; else if (k.End.X < this.D.X) aX += 1; if (k.Start.Y < this.D.Y) aX += 128; else if (k.Start.Y > this.G.Y) aX += 64; if (k.Start.X > this.G.X) aX += 32; else if (k.Start.X < this.D.X) aX += 16; switch (aX) { case 0: return true; case 1: this.aC(k); return true; case 2: this.ax(k); return true; case 4: this.aw(k); return true; case 5: this.aC(k); if (k.End.Y > this.G.Y) this.aw(k); return true; case 6: this.ax(k); if (k.End.Y > this.G.Y) this.aw(k); return true; case 8: this.aD(k); return true; case 9: this.aC(k); if (k.End.Y < this.D.Y) this.aD(k); return true; case 10: this.ax(k); if (k.End.Y < this.D.Y) this.aD(k); return true; case 16: this.aA(k); return true; case 18: this.aA(k); this.ax(k); return true; case 20: this.aA(k); if (k.Start.Y > this.G.Y) return false; this.aw(k); return true; case 22: this.aA(k); if (k.Start.Y > this.G.Y) return false; this.aw(k); if (k.End.X > this.G.X) this.ax(k); return true; case 24: this.aA(k); if (k.Start.Y < this.D.Y) return false; this.aD(k); return true; case 26: this.aA(k); if (k.Start.Y < this.D.Y) return false; this.aD(k); if (k.End.X > this.G.X) this.ax(k); return true; case 32: this.ay(k); return true; case 33: this.ay(k); this.aC(k); return true; case 36: this.ay(k); if (k.Start.Y > this.G.Y) return false; this.aw(k); return true; case 37: this.ay(k); if (k.Start.Y > this.G.Y) return false; this.aw(k); if (k.End.X < this.D.X) this.aC(k); return true; case 40: this.ay(k); if (k.Start.Y < this.D.Y) return false; this.aD(k); return true; case 41: this.ay(k); if (k.Start.Y < this.D.Y) return false; this.aD(k); if (k.End.X < this.D.X) this.aC(k); return true; case 64: this.az(k); return true; case 65: this.az(k); if (k.Start.X < this.D.X) return false; this.aC(k); if (k.End.Y > this.G.Y) this.aw(k); return true; case 66: this.az(k); if (k.Start.X > this.G.X) return false; this.ax(k); return true; case 72: this.az(k); this.aD(k); return true; case 73: this.az(k); if (k.Start.X < this.D.X) return false; this.aC(k); if (k.End.Y < this.D.Y) this.aD(k); return true; case 74: this.az(k); if (k.Start.X > this.G.X) return false; this.ax(k); if (k.End.Y < this.D.Y) this.aD(k); return true; case 80: this.aA(k); if (k.Start.Y > this.G.Y) this.az(k); return true; case 82: this.ax(k); if (k.End.Y > this.G.Y) return false; this.az(k); if (k.Start.X < this.D.X) this.aA(k); return true; case 88: this.aD(k); if (k.End.X < this.D.X) return false; this.az(k); if (k.Start.X < this.D.X) this.aA(k); return true; case 90: this.aA(k); if (k.Start.Y < this.D.Y) return false; this.ax(k); if (k.End.Y > this.G.Y) return false; if (k.Start.Y > this.G.Y) this.az(k); if (k.End.Y < this.D.Y) this.aD(k); return true; case 96: this.ay(k); if (k.Start.Y > this.G.Y) this.az(k); return true; case 97: this.aC(k); if (k.End.Y > this.G.Y) return false; this.az(k); if (k.Start.X > this.G.X) this.ay(k); return true; case 104: this.aD(k); if (k.End.X > this.G.X) return false; this.ay(k); if (k.Start.Y > this.G.Y) this.az(k); return true; case 105: this.aC(k); if (k.End.Y > this.G.Y) return false; this.ay(k); if (k.Start.Y < this.D.Y) return false; if (k.End.Y < this.D.Y) this.aD(k); if (k.Start.Y > this.G.Y) this.az(k); return true; case 128: this.aB(k); return true; case 129: this.aB(k); if (k.Start.X < this.D.X) return false; this.aC(k); return true; case 130: this.aB(k); if (k.Start.X > this.G.X) return false; this.ax(k); return true; case 132: this.aB(k); this.aw(k); return true; case 133: this.aB(k); if (k.Start.X < this.D.X) return false; this.aC(k); if (k.End.Y > this.G.Y) this.aw(k); return true; case 134: this.aB(k); if (k.Start.X > this.G.X) return false; this.ax(k); if (k.End.Y > this.G.Y) this.aw(k); return true; case 144: this.aA(k); if (k.Start.Y < this.D.Y) this.aB(k); return true; case 146: this.ax(k); if (k.End.Y < this.D.Y) return false; this.aB(k); if (k.Start.X < this.D.X) this.aA(k); return true; case 148: this.aw(k); if (k.End.X < this.D.X) return false; this.aA(k); if (k.Start.Y < this.D.Y) this.aB(k); return true; case 150: this.aA(k); if (k.Start.Y > this.G.Y) return false; this.ax(k); if (k.End.Y < this.D.Y) return false; if (k.Start.Y < this.D.Y) this.aB(k); if (k.End.Y > this.G.Y) this.aw(k); return true; case 160: this.ay(k); if (k.Start.Y < this.D.Y) this.aB(k); return true; case 161: this.aC(k); if (k.End.Y < this.D.Y) return false; this.aB(k); if (k.Start.X > this.G.X) this.ay(k); return true; case 164: this.aw(k); if (k.End.X > this.G.X) return false; this.ay(k); if (k.Start.Y < this.D.Y) this.aB(k); return true; case 165: this.aC(k); if (k.End.Y < this.D.Y) return false; this.ay(k); if (k.Start.Y > this.G.Y) return false; if (k.End.Y > this.G.Y) this.aw(k); if (k.Start.Y < this.D.Y) this.aB(k); return true; } return false; } }; function PolyLine(ae, ab) { this.coordinates = ae ? ae : []; if (ab) { this.rgba = ab.rgba ? ab.rgba : "rgba(0,0,0,1.0)"; this.lineWidth = ab.lineWidth ? ab.lineWidth : 2; } else { this.rgba = "rgba(0,0,0,1.0)"; this.lineWidth = 2; } }; PolyLine.prototype = { addPoint: function (aE) { this.coordinates.push(aE); } }; function GUI(aK) { this.aU = "http://www.webatlas.no/webatlasapi/v/latest/media/interface/default/"; this.aK = aK ? aK : 'small'; this.mapControl = null; this.element = document.createElement('div'); divIdName = 'guibackground'; this.element.style.position = "absolute"; this.element.style.left = "16px"; this.element.setAttribute('id', divIdName); Event.observe(this.element, 'mouseup', this.cL.bindAsEventListener(this)); Event.observe(this.element, 'dblclick', this.cL.bindAsEventListener(this)); Event.observe(this.element, 'mousedown', this.cL.bindAsEventListener(this)); var bl = document.createElement('div'); bl.style.background = "url(" + this.aU + this.aK + "/east.jpg)"; bl.style.position = "absolute"; bl.style.width = "16px"; bl.style.height = "16px"; bl.style.left = "32px"; bl.style.top = "34px"; bl.setAttribute('id', 'eastButton'); this.element.appendChild(bl); Event.observe(bl, 'click', this.eq.bindAsEventListener(this)); var bo = document.createElement('div'); bo.style.background = "url(" + this.aU + this.aK + "/west.jpg)"; bo.style.position = "absolute"; bo.style.width = "16px"; bo.style.height = "16px"; bo.style.left = "0px"; bo.style.top = "34px"; bo.setAttribute('id', 'westButton'); this.element.appendChild(bo); Event.observe(bo, 'click', this.ej.bindAsEventListener(this)); var bd = document.createElement('div'); bd.style.background = "url(" + this.aU + this.aK + "/north.jpg)"; bd.style.position = "absolute"; bd.style.width = "16px"; bd.style.height = "16px"; bd.style.left = "16px"; bd.style.top = "17px"; bd.setAttribute('id', 'northButton'); this.element.appendChild(bd); Event.observe(bd, 'click', this.ep.bindAsEventListener(this)); var bk = document.createElement('div'); bk.style.background = "url(" + this.aU + this.aK + "/south.jpg)"; bk.style.position = "absolute"; bk.style.width = "16px"; bk.style.height = "16px"; bk.style.left = "16px"; bk.style.top = "50px"; bk.setAttribute('id', 'southButton'); this.element.appendChild(bk); Event.observe(bk, 'click', this.fs.bindAsEventListener(this)); var bc = document.createElement('div'); bc.style.background = "url(" + this.aU + this.aK + "/normal.jpg)"; bc.style.position = "absolute"; bc.style.width = "48px"; bc.style.height = "16px"; bc.style.left = "0px"; bc.style.top = "104px"; bc.setAttribute('id', 'style_normalButton'); this.element.appendChild(bc); Event.observe(bc, 'click', this.ft.bindAsEventListener(this)); var bi = document.createElement('div'); bi.style.background = "url(" + this.aU + this.aK + "/ortho.jpg)"; bi.style.position = "absolute"; bi.style.width = "48px"; bi.style.height = "16px"; bi.style.left = "0px"; bi.style.top = "122px"; bi.setAttribute('id', 'style_orthoButton'); this.element.appendChild(bi); Event.observe(bi, 'click', this.fq.bindAsEventListener(this)); var aZ = document.createElement('div'); aZ.style.background = "url(" + this.aU + this.aK + "/hybrid.jpg)"; aZ.style.position = "absolute"; aZ.style.width = "48px"; aZ.style.height = "16px"; aZ.style.left = "0px"; aZ.style.top = "140px"; aZ.setAttribute('id', 'style_hybridButton'); this.element.appendChild(aZ); Event.observe(aZ, 'click', this.fk.bindAsEventListener(this)); var bh = document.createElement('div'); bh.style.background = "url(" + this.aU + this.aK + "/zoom_In.jpg)"; bh.style.position = "absolute"; bh.style.width = "16px"; bh.style.height = "16px"; bh.style.left = "16px"; bh.style.top = "68px"; bh.setAttribute('id', 'zoomInButton'); this.element.appendChild(bh); Event.observe(bh, 'click', this.eB.bindAsEventListener(this)); var bg = document.createElement('div'); bg.style.background = "url(" + this.aU + this.aK + "/zoom_Out.jpg)"; bg.style.position = "absolute"; bg.style.width = "16px"; bg.style.height = "16px"; bg.style.left = "16px"; bg.style.top = "86px"; bg.setAttribute('id', 'zoomOutButton'); this.element.appendChild(bg); Event.observe(bg, 'click', this.eF.bindAsEventListener(this)); }; GUI.prototype = { fs: function (ap) { ao = new Move(0, parseInt(-this.mapControl.getHeight() / 3)); this.mapControl.move(ao); ap.stop(); }, ep: function (ap) { ao = new Move(0, parseInt(this.mapControl.getHeight() / 3)); this.mapControl.move(ao); ap.stop(); }, eq: function (ap) { ao = new Move(parseInt(-this.mapControl.getWidth() / 3), 0); this.mapControl.move(ao); ap.stop(); }, ej: function (ap) { ao = new Move(parseInt(this.mapControl.getHeight() / 3), 0); this.mapControl.move(ao); ap.stop(); }, ft: function (ap) { this.mapControl.setMapStyle(0); ap.stop(); }, fq: function (ap) { this.mapControl.setMapStyle(1); ap.stop(); }, fk: function (ap) { this.mapControl.setMapStyle(2); ap.stop(); }, eB: function (ap) { this.mapControl.zoomIn(); ap.stop(); }, eF: function (ap) { this.mapControl.zoomOut(); ap.stop(); }, cL: function (ap) { ap.stop(); } }; var NGTools = Class.create(); NGTools.prototype = { cy: 6378137, cw: null, cO: null, dX: -85.05112878, ed: 85.05112878, eJ: -180, fn: 180, ag: 256, initialize: function () { this.cw = this.cy * 2.0 * Math.PI; this.cO = this.cw / 2; }, bU: function (eE, eQ, er) { return Math.min(Math.max(eE, eQ), er); }, bx: function (be) { return this.ag << be; }, ey: function (aW, be) { aW = this.bU(aW, this.dX, this.ed); return Math.cos(aW * Math.PI / 180) * 2 * Math.PI * this.cy / this.bx(be); }, fA: function (aW, be, eS) { return ey(aW, be) * eS / 0.0254; }, aF: function (aW, cR, be) { var aW = this.bU(aW, this.dX, this.ed); var cR = this.bU(cR, this.eJ, this.fn); var x = (cR + 180) / 360; var ds = Math.sin(aW * Math.PI / 180); var y = 0.5 - Math.log((1 + ds) / (1 - ds)) / (4 * Math.PI); var bx = this.bx(be); var bI = parseInt(this.bU(x * bx + 0.5, 0, bx - 1)); var bG = parseInt(this.bU(y * bx + 0.5, 0, bx - 1)); return [bI, bG]; }, ec: function (bI, bG) { var ck = bI / this.ag; var cg = bG / this.ag; return [parseInt(ck), parseInt(cg)]; }, eb: function (bI, bG) { var ck = parseInt(bI / this.ag); var cg = parseInt(bG / this.ag); var ff = ck * this.ag; var eV = cg * this.ag; var fc = bI - ff; var fb = bG - eV; return [parseInt(fc), parseInt(fb)]; }, fr: function (ck, cg, be) { var dU = ""; for (var i = be; i > 0; i--) { var cu = '0'; var dW = 1 << (i - 1); if ((ck & dW) != 0) { cu++; } if ((cg & dW) != 0) { cu++; cu++; } dU += cu; } return dU; }, ad: function (y, au) { var cV = this.cw / ((1 << au) * this.ag); var ek = this.cO - (y * cV); var a = Math.exp(ek * 2 / this.cy); var cF = this.ei(Math.asin((a - 1) / (a + 1))); return cF }, ac: function (x, au) { var cV = this.cw / ((1 << au) * this.ag); var ez = (x * cV) - this.cO; var cF = this.ei(ez / this.cy); return cF }, ei: function (d) { return d / Math.PI * 180.0; } }; var NGTools = new NGTools();
