var IconsAvailable = new Array(); var gPoints = false; var gDatabase = false; var gMenu = null; var gaInit = false; var routeLayer = null; var routeMarkerLayer = null; var MapArray = new Array(); function CMapArrayElement(ctrlname, mapobj) { this.ctrlname = ctrlname; this.mapobj = mapobj; } function GetIconName(cat) { var icon = "0"; for (i=0;iBCX © 2007-2010"; //this.cCopyright = null; this.nCopyrightXMargin = 0; this.csBranding = "http://api.maps.brabys.com/img/aclogo.png"; this.nBranding_width=105; this.nBranding_height=42; this.csBrandingTooltip = "Brabys"; this.csBrandingUrl = "http://www.brabys.com"; this.cBranding = null; this.PositionCopyright = fPositionCopyright; this.cSlider = null; this.nScaleXOffset = 0; this.RedrawCallback = null; this.nSliderPressed = false; this.nSliderZoom = 0; this.PopupMenuCallback = null; this.aLayers = new Array(); this.hybridLayer = null; this.numbersLayer = null; this.routeStartX=0; this.routeStartY=0; this.routeEndX=0; this.routeEndY=0; this.KeyDeltaX = 0; this.KeyDeltaY = 0; this.KeyTimerActive = 0; this.isSatellite = true; this.bNavigate = true; this.bScaleBar = true; this.sImageBase = ScriptBase()+"img/"; this.bModeButtons = true; this.bPointsButtons = true; this.baseOverride = ""; this.bPopupMenu = false; this.statusImg = null; this.AJAX_Status_Callback=null; this.NoStatusCallback = false; this.status_url=""; // d=drag; z=zoom this.dragMode = "m"; this.dragRect = null; this.bHotKeyAssoc = false; this.bUseHotkeys = true; this.bMouseAssoc = false; this.bUseMouse = true; this.snaps = new Array ( 10.24, 5.12, 2.56, 1.28, 0.64, 0.32, 0.16, 0.08, 0.02, 0.01, 0.005, 0.0025, 0.00125, 0.000625 ); } CAatMap.prototype.SetHotkeys = function(val) { this.bUseHotkeys = val; } CAatMap.prototype.SetMouse = function(val) { this.bUseMouse = val; } CAatMap.prototype.XRelative = function(pixels) { if (BrowserDetect.browser=="Explorer") return pixels; return pixels + this.nCtrlAbsLeft; } // returns an array (x1,y1,x2,y2) CAatMap.prototype.GetBounds = function() { return new Array( this.GetX()-this.DegWidth()/2, this.GetY()+this.DegHeight()/2, this.GetX()+this.DegWidth()/2, this.GetY()-this.DegHeight()/2 ); } CAatMap.prototype.YRelative = function(pixels) { if (BrowserDetect.browser=="Explorer") return pixels; return pixels + this.nCtrlAbsTop; } /** * Gets the Base URL of this page */ CAatMap.prototype.GetBaseUrl = function() { return this.baseOverride==""?BaseUrl():this.baseOverride; } /** * Sets the visibility of the mode buttons (map|hybrid|satellite). false=off, true=on */ CAatMap.prototype.SetModeButtons = function(visible) { this.bModeButtons = visible; } /** * Sets the visibility of the buttons if they're greyed. false=off, true=on */ CAatMap.prototype.SetShowGreyButtons = function(visible) { this.bShowGreyButtons = visible; } /** * Sets the visibility of the point button (points). false=off, true=on */ CAatMap.prototype.SetPointsButtons = function(visible) { this.bPointsButtons = visible; } /** * Sets the image base, where the system images are kept - default is "img\" */ CAatMap.prototype.SetImageBase = function(p) { this.sImageBase = p; } /** * Sets the visibility of the navigation controls on the map. false=off, true=on */ CAatMap.prototype.SetNavigate = function(visible) { this.bNavigate = visible; } /** * Sets the visibility of the scale on the map. false=off, true=on */ CAatMap.prototype.SetScaleBar = function(visible) { this.bScaleBar = visible; } /** * Sets the X-Coordinate of the map */ CAatMap.prototype.SetX = function(p) { this.nX = p; } /** * Sets the Y-Coordinate of the map */ CAatMap.prototype.SetY = function(p) { this.nY = p; } CAatMap.prototype.SetPopupMenu = function(p) { this.bPopupMenu = p; } CAatMap.prototype.SetShowProgress = function(p) { this.bShowProgress = p; } /** * Sets the zoom level at a tile level. Must be a valid zoom level. * @see CAatmap@snaps */ CAatMap.prototype.SetTileZoom = function(p) { // make sure this is a valid zoom level var okay = false; for (var l=0;l"; var gInfoDiv = null; var thumb_slider_top = 17; var thumb_slider_left = 12; function MapURL(obj,layer,width,height,scale,x,y) { switch (layer) { case "map" : case "num" : ret = obj.parent.GetBaseUrl()+"/maptile/"+layer+"/"+String(width)+"_"+String(height)+"/"+String(scale)+"/"+String(y.toFixed(6))+"_"+String(x.toFixed(6))+".png"; break; case "sat" : ret = obj.parent.GetBaseUrl()+"/maptile/"+layer+"/"+String(width)+"_"+String(height)+"/"+String(scale)+"/"+String(y.toFixed(6))+"_"+String(x.toFixed(6))+".jpg"; break; case "hyb" : ret = obj.parent.GetBaseUrl()+"/maptile/"+layer+"/"+String(width)+"_"+String(height)+"/"+String(scale)+"/"+String(y.toFixed(6))+"_"+String(x.toFixed(6))+".png"; break; case "custom" : ret = obj.GetCustomUrl(); ret = ret.replace(/%width%/gi, String(width)); ret = ret.replace(/%height%/gi, String(height)); ret = ret.replace(/%scale%/gi, String(scale)); ret = ret.replace(/%x%/gi, String(x.toFixed(6))); ret = ret.replace(/%y%/gi, String(y.toFixed(6))); ret = ret.replace(/%baseurl%/gi, obj.parent.GetBaseUrl()); break; case "maproute" : case "route" : ret = obj.parent.GetBaseUrl()+"/maptile/"+layer+"/"+String(width)+"_"+String(height)+"/"+String(scale)+"/"+String(y.toFixed(6))+"_"+String(x.toFixed(6))+"/"+String(obj.routeStartX.toFixed(6))+"/"+String(obj.routeStartY.toFixed(6))+"/"+String(obj.routeEndX.toFixed(6))+"/"+String(obj.routeEndY.toFixed(6))+".png"; break; case "multiroute" : ret = obj.parent.GetBaseUrl()+"/maptile/multiroute/"+String(width)+"_"+String(height)+"/"+String(scale)+"/"+String(y.toFixed(6))+"_"+String(x.toFixed(6))+"/"+obj.args1+".png"; break; case "stats" : ret = obj.parent.GetBaseUrl()+"/aatmap/render_stat.asp?width="+String(width)+"&height="+String(height)+"&scale="+String(scale)+"&x="+String(x)+"&y="+String(y)+"&df="+obj.userData[0]+"&ds="+obj.userData[1]; break; } return PNG_Check_Str(ret); } function CAatPoint(pX,pY,pCaption,id,parent) { this.pX = pX; this.pY = pY; this.id = id; this.pCaption = pCaption; this.layer = null; this.cDiv = null; this.cTable = null; this.cDivBG = null; this.cTableBG = null; this.pixX = 0; this.pixY = 0; this.pixW = 0; this.pixH = 0; this.parent = parent; this.img_fg_width = 20; this.img_fg_height = 32; this.img_bg_width = 32; this.img_bg_height = 32; this.style = "default"; this.icon = null; this.tooltip = ""; this.clickBehaviour = ""; this.clickCallback = null; this.rawLabel = ""; this.userRef = ""; this.uniqueid = String(Math.random()); this.labelX = 0; this.labelY = 0; this.labelW = 0; this.labelH = 0; this.iconAnchorX = "left"; this.iconAnchorY = "top"; this.iconX = 0; this.iconY = 0; this.iconW = 0; this.iconH = 0; this.iconSizeX = 16; this.iconSizeY = 16; this.labelAnchorX = "left"; this.labelAnchorY = "top"; this.visibleMin = 0; this.visibleMax = 99; this.labelMin = 0; this.labeleMax = 0; this.dirtySize = true; this.img_fg = this.parent.sImageBase+"bubble_yellow.png"; this.img_bg = this.parent.sImageBase+"bubble_shadow.png"; } CAatPoint.prototype.SetCaption = function(c) { this.pCaption=c; } CAatPoint.prototype.SetCallback = function(c) { this.clickCallback=c; } function RectIntersect(ax1, ay1, ax2, ay2, bx1, by1, bx2, by2) { var ret = false; if ( ( (ax1bx1) || (ax1bx2) || (ax1>bx1 && ax2by1) || (ay1>by1 && ay2by2) || (ay1>by2 && ay2by1 && ay2by2) ) ) ret = true; return ret; } CAatPoint.prototype.SetIconSize = function(x,y) { this.iconSizeX=x; this.iconSizeY=y; } CAatPoint.prototype.ProcessClickJump = function(event, element) { StopPropagation(event); this.style="label"; for (pl=0;plthis.parent.nCtrlWidth) deltaX = ((this.labelX+pnt.labelW)-this.parent.nCtrlWidth)+32; if (this.labelY+pnt.labelH>this.parent.nCtrlHeight) deltaY = ((this.labelY+pnt.labelH)-this.parent.nCtrlHeight)+16; if (deltaX!=0 || deltaY!=0) { var signX = deltaX>0?-1:1; var signY = deltaY>0?-1:1; var scX = Math.abs(deltaX * (this.parent.DegWidth() / this.parent.nCtrlWidth )); var scY = Math.abs(deltaY * (this.parent.DegHeight() / this.parent.nCtrlHeight )); newSetTimeout(SmoothMove,10,this.parent,0,0,20,scX,scY,signX,signY,0); } // if (deltaX!=0 || deltaY!=0) { } else this.style="icon"; this.parent.Init(false); break; } } return false; } CAatPoint.prototype.SetVisible = function(min,max) { this.visibleMin=min; this.visibleMax=max; } CAatPoint.prototype.SetLabelVisible = function(min,max) { this.labelMin=min; this.labelMax=max; this.style="labellimited" } CAatPoint.prototype.SetClickBehaviour = function(cb) { this.clickBehaviour = cb; } CAatPoint.prototype.SetStyle = function(style) { this.style = style; } CAatPoint.prototype.GetStyle = function() { return this.style; } CAatPoint.prototype.SetTooltip = function(tip) { this.tooltip = tip; } CAatPoint.prototype.SetRawLabel= function(lbl) { this.rawLabel = lbl; } CAatPoint.prototype.SetIcon = function(icon) { this.icon = icon; } CAatPoint.prototype.SetImgFG = function(url,width,height) { this.img_fg = url; if (!isUndefined(width)) this.img_fg_width=width; if (!isUndefined(height)) this.img_fg_height=height; } CAatPoint.prototype.SetImgBG = function(url,width,height) { this.img_bg = url; if (!isUndefined(width)) this.img_bg_width=width; if (!isUndefined(height)) this.img_bg_height=height; } CAatPoint.prototype.SetIconAnchor = function(ax,ay) { this.iconAnchorX=ax; this.iconAnchorY=ay; } CAatPoint.prototype.SetLabelAnchor = function(ax,ay) { this.labelAnchorX=ax; this.labelAnchorY=ay; } CAatPointLayer.prototype.GetZoom = function() { return this.parent.nZoom; } CAatPointLayer.prototype.GetTileZoom = function() { return this.parent.nTileZoom; } CAatPointLayer.prototype.GetX = function() { return this.parent.nX; } CAatPointLayer.prototype.GetY = function() { return this.parent.nY; } CAatPointLayer.prototype.SetAnchor = function(ax,ay) { this.anchorX=ax; this.anchorY=ay; } CAatPointLayer.prototype.SetDefaultAnchor = function(ax,ay) { this.anchorX=ax; this.anchorY=ay; } /** * Returns the bounds of the layer in an array with format (x, y, x1, y1) */ CAatPointLayer.prototype.GetBounds = function() { var x=null, y=null, x1=null, y1=null; for (pl=0;plx1 || x1==null) x1=pt.pX; if (pt.pY>y1 || y1==null) y1=pt.pY; } } return new Array(x,y,x1,y1); } CAatPointLayer.prototype.RenderLayer = function(copyDiv, zIndex) { var ret = new Array(); var scale = this.parent.nZoom*2 / this.parent.nCtrlWidth; for (pl=0;pl=pt.visibleMin && this.parent.GetTileZoom()<=pt.visibleMax) { vDiv = CopyLayerDiv(copyDiv); vDiv.style.zIndex=zIndex; pt.cDiv = vDiv; vDivBG = null; dX = pt.pX - this.GetX(); dY = pt.pY - this.GetY(); plotX = dX / scale; plotY = dY / scale; vTable = document.createElement("table"); pt.cTable = vTable; vDiv.appendChild(vTable); vRow = vTable.insertRow(-1); vCell = vRow.insertCell(-1); vTable.style.position = "relative"; vTable.cellSpacing = 0; vTable.cellPadding = 0; var anchorX = this.parent.anchorX; var anchorY = this.parent.anchorY; // work out the size of the icon //iconCapt = ""; iconCapt = PNG(pt.icon,pt.iconSizeX,pt.iconSizeY,pt.tooltip,0,0,"mappoint_"+Math.random(),"default"); MurderChildren(this.parent.cScratch); var scDiv = document.createElement("div"); scDiv.innerHTML = iconCapt; this.parent.cScratch.appendChild(scDiv); pt.iconW = scDiv.offsetWidth; pt.iconH = scDiv.offsetHeight; // work out the size of the label if (pt.rawLabel.length==0) { labelCapt = pt.pCaption; labelCapt = ""+ ""+ "" "" "" "
"+labelCapt+"
"; } else { labelCapt = "
"+pt.rawLabel+"
"; } MurderChildren(this.parent.cScratch); var scDiv = document.createElement("div"); scDiv.innerHTML = labelCapt; this.parent.cScratch.appendChild(scDiv); if (pt.rawLabel.length==0) { if (scDiv.offsetWidth > this.parent.nCtrlWidth/2) { // max size = 1/2 the width of the map labelCapt = ""+ ""+ "" "" "" "
"+pt.pCaption+"
"; } else { labelCapt = ""+ ""+ "" "" "" "
"+pt.pCaption+"
"; } } else { labelCapt = "
"+pt.rawLabel+"
"; } MurderChildren(this.parent.cScratch); var scDiv = document.createElement("div"); scDiv.innerHTML = labelCapt; this.parent.cScratch.appendChild(scDiv); pt.labelW = scDiv.offsetWidth; pt.labelH = scDiv.offsetHeight; pt.labelH += pt.iconH; var usestyle=pt.style; if (pt.labelMin>0 || pt.labelMax>0) { if ( (this.parent.GetTileZoom()pt.labelMax) && usestyle=="labellimited") usestyle="icon"; } switch (usestyle) { case "default" : default : vCell.innerHTML = "
"+PNG(pt.img_fg,pt.img_fg_width,pt.img_fg_height,pt.pCaption)+"
"; vDivBG = CopyLayerDiv(copyDiv); pt.cDivBG = vDivBG; if (pt.img_bg.length) { vTableBG = document.createElement("table"); pt.cTableBG = vTableBG; vDivBG.appendChild(vTableBG); vRowBG = vTableBG.insertRow(-1); vCellBG = vRowBG.insertCell(-1); vTableBG.style.position = "relative"; vTableBG.cellSpacing = 0; vTableBG.cellPadding = 0; vCellBG.innerHTML = "
"+PNG(pt.img_bg,pt.img_bg_width,pt.img_bg_height,pt.pCaption)+"
"; } else { pt.cTableBG = null; } obWidth = pt.img_fg_width; obHeight = pt.img_fg_height; break; case "icon" : vCell.innerHTML = iconCapt; vCell.onclick = associateObjWithEvent(pt, "ProcessClick"); anchorX = pt.iconAnchorX; anchorY = pt.iconAnchorY; vDiv.style.zIndex=zIndex; break; case "label" : case "labellimited" : vCell.innerHTML = labelCapt if (pt.clickBehaviour=="toggle_all_label") { vCell.onclick = associateObjWithEvent(pt, "ProcessClick"); vCell.style.cursor = "pointer"; } vRow2 = vTable.insertRow(-1); vCell2 = vRow2.insertCell(-1); vCell2.innerHTML = iconCapt vCell2.onclick = associateObjWithEvent(pt, "ProcessClick"); anchorX = pt.labelAnchorX; anchorY = pt.labelAnchorY; vDiv.style.zIndex=zIndex+1; break; } // use the anchor to calculate offsets switch (pt.labelAnchorX) { case "left" : default: pt.labelX = this.parent.nCtrlWidth/2 + plotX + 0; break; case "center" : pt.labelX = this.parent.nCtrlWidth/2 + plotX - pt.iconW/2; break; case "labelcenter" : pt.labelX = this.parent.nCtrlWidth/2 + plotX -pt.labelW/2 - pt.iconW/2; break; case "right" : pt.labelX = this.parent.nCtrlWidth/2 + plotX -pt.labelW; break; } switch (pt.labelAnchorY) { case "top" : default: pt.labelY = this.parent.nCtrlHeight/2 - plotY + 0; break; case "center" : pt.labelY = this.parent.nCtrlHeight/2 - plotY - pt.labelH + pt.iconH/2; break; case "labelcenter" : pt.labelY = this.parent.nCtrlHeight/2 - plotY -pt.labelH/2 + pt.iconH/2; break; case "bottom" : pt.labelY = this.parent.nCtrlHeight/2 - plotY -pt.labelH; break; } //pt.labelX -= pt.iconW/2; //pt.labelY += pt.iconH/2; switch (pt.iconAnchorX) { case "left" : default: pt.iconX = this.parent.nCtrlWidth/2 + plotX + 0; break; case "center" : pt.iconX = this.parent.nCtrlWidth/2 + plotX -pt.iconW/2; break; case "right" : pt.iconX = this.parent.nCtrlWidth/2 + plotX -pt.iconW; break; } switch (pt.iconAnchorY) { case "top" : default: pt.iconY = this.parent.nCtrlHeight/2 - plotY + 0; break; case "center" : pt.iconY = this.parent.nCtrlHeight/2 - plotY -pt.iconH/2; break; case "bottom" : pt.iconY = this.parent.nCtrlHeight/2 - plotY -pt.iconH; break; } switch (usestyle) { case "label" : case "labellimited" : pt.pixX = pt.labelX; pt.pixY = pt.labelY; pt.pixW = pt.labelW; pt.pixH = pt.labelH; break; case "icon" : pt.pixX = pt.iconX; pt.pixY = pt.iconY; pt.pixW = pt.iconW; pt.pixH = pt.iconH; break; } if (vDivBG!=null) { vTableBG.style.left = PX(pt.pixX); vTableBG.style.top = PX(pt.pixY); ret.push(vDivBG); } vTable.style.left = PX(pt.pixX); vTable.style.top = PX(pt.pixY); vDiv.style.width = PX(pt.pixW); vDiv.style.height = PX(pt.pixH); this.aPoints[pl] = pt; this.Revert(pt,pt.pixX,pt.pixY,this.parent); ret.push(vDiv); MurderChildren(this.parent.cScratch); } // is visible } return ret; } CAatPointLayer.prototype.SetZoom = function(zoom) { } CAatPointLayer.prototype.Revert = function(pt, newX, newY, map) { // reposition the div if (isNull(pt.cDiv)) return; pt.cDiv.style.left = PX(map.XRelative(newX)); pt.cDiv.style.top = PX(map.YRelative(newY)); if (pt.dirtySize) { pt.cDiv.style.width = PX(pt.pixW); pt.cDiv.style.height = PX(pt.pixH); pt.dirtySize = false; } pt.pixX = newX; pt.pixY = newY; // do clipping if necessary if (newX<=0) { if (BrowserDetect.browser=="Explorer") pt.cDiv.style.left = 0; else pt.cDiv.style.left = PX(XRelative(map.nCtrlLeft,map.cContainer)); if (newX+pt.pixW>0) { pt.cDiv.style.width = PX(newX+pt.pixW); pt.cTable.style.left = PX(newX); } else pt.cDiv.style.width = "0px"; pt.dirtySize = true; } else { pt.cTable.style.left = "0px"; if (newX+pt.pixW>=map.nCtrlWidth) { pt.dirtySize = true; if (newX>=map.nCtrlWidth) { pt.cDiv.style.width="0px"; pt.cTable.style.left = PX(map.nCtrlWidth); } else pt.cDiv.style.width = PX(map.nCtrlWidth-newX); } } if (newY<=0) { if (BrowserDetect.browser=="Explorer") pt.cDiv.style.top = 0; else pt.cDiv.style.top = YRelative(map.nCtrlTop,map.cContainer); if (newY+pt.pixH>0) { pt.cDiv.style.height = PX(newY+pt.pixH); pt.cTable.style.top = PX(newY); } else { pt.cDiv.style.height = PX(0); } pt.dirtySize = true; } else { pt.cTable.style.top = 0; if (newY+pt.pixH>=map.nCtrlHeight) { if (newY>=map.nCtrlHeight) { pt.cDiv.style.height=PX(0); pt.cTable.style.top = map.nCtrlHeight; } else { pt.cDiv.style.height = PX(map.nCtrlHeight-newY); } pt.dirtySize = true; } } } CAatPointLayer.prototype.MoveScreen = function(pDeltaX, pDeltaY, pixels) { if (pixels) { deltaX = pDeltaX; deltaY = pDeltaY; } else { var nPixScale = (this.GetZoom()*2) / this.parent.nCtrlWidth; deltaX = pDeltaX / nPixScale; deltaY = pDeltaY / nPixScale; } for (al=0;al"; // return PNG(url,width,height,""); } CAatMap.prototype.SetCursor = function(parm1) { for (l=0;lb.pos) return -1; return 0; } CAatMap.prototype.RemoveLayer = function(ref) { for (l=0;ltargetx) stepx=targetx-currx; if (curry+stepy>targety) stepy=targety-curry; currx += stepx; curry += stepy; objt.SetX(objt.GetX()-signx*stepx); objt.SetY(objt.GetY()+signy*stepy); for (layer=0;layer0.01) { alert("You need to zoom in closer to use this function."); return; } */ gPoints = !gPoints; if (gPoints) gDatabase = false; if (this.RedrawCallback!=null) { this.RedrawCallback(this,this.GetX(),this.GetY(),"doPoints"); } return false; } CAatMap.prototype.doDragModeMove = function(event, element) { if (this.dragMode=="m") return; this.dragMode = "m"; this.Init(); } CAatMap.prototype.doDragModeZoom = function(event, element) { if (this.dragMode=="z") return; this.dragMode = "z"; this.Init(); } CAatMap.prototype.doControlMap = function(event, element) { for (l=0;l0) { this.SetTileZoom(this.snaps[l-1]); this.Init(); return false; } } return false; } CAatMap.prototype.doSliderMouseDown = function(event, element) { StopPropagation(event); this.nSliderPressed = true; this.nSliderClick=event.clientY; return false; } CAatMap.prototype.doSliderMouseMove = function(event, element) { var nLeft = thumb_slider_left; var nTop = thumb_slider_top+4; if (!this.nSliderPressed) return; StopPropagation(event); var ydelta = event.clientY - this.nSliderClick; var spos = event.clientY - thumb_slider_top; // spos -= getAbsoluteTop(this.cContainer); spos -= getViewTop(this.cContainer); if (spos<8) spos=8; if (spos>111) spos=111; var tick = Math.floor((spos-4) / 8); this.nSliderZoom = this.snaps[tick]; this.cSlider.style.top = YRelative(nTop + spos - 18, this.cOutput); return false; } CAatMap.prototype.doSliderMouseUp = function(event, element) { if (!this.nSliderPressed) return; StopPropagation(event); if (this.nSliderPressed) { this.JumpTo(this.GetX(),this.GetY(),this.nSliderZoom); } this.nSliderPressed = false; return false; } CAatMap.prototype.SliderUpdate = function() { var nLeft = thumb_slider_left; var nTop = thumb_slider_top+4; // bottom to top, the zoom amounts // find out where we are in this array ourPos = 0; for (l=0;l1000) sDist = (nDist/1000).toFixed(1) + "km"; if (nDist>10000) sDist = (nDist/1000).toFixed(0) + "km"; var html = ""+ ""+ ""+ ""+ "
 0km"+sDist+" 
"; newDiv.innerHTML = html; newDiv.style.left = PX( XRelative(5+this.nScaleXOffset, this.cContainer) ); newDiv.style.top = PX( YRelative(this.nCtrlHeight - 21, this.cContainer) ); this.cContainer.appendChild(newDiv); var newDiv = document.createElement("div"); newDiv.style.position = "absolute"; newDiv.style.zIndex = this.nZIndexBase+25; var html = ""+ ""+ ""+ ""+ "
 0km"+sDist+" 
"; newDiv.innerHTML = html; newDiv.style.left = PX( XRelative(4+this.nScaleXOffset, this.cContainer) ); newDiv.style.top = PX( YRelative(this.nCtrlHeight - 22, this.cContainer) ); this.cContainer.appendChild(newDiv); var newDivU = document.createElement("div"); newDivU.style.zIndex = this.nZIndexBase+24; newDivU.innerHTML = GIF(imgname,imgwidth,imgheight,""); newDivU.style.left = PX( XRelative(4+this.nScaleXOffset, this.cContainer) ); newDivU.style.top = PX( YRelative(this.nCtrlHeight - 20, this.cContainer) ); newDivU.style.overflow = "hidden"; newDivU.style.position = "absolute"; newDivU.style.width = PX(4); newDivU.style.height = PX(18); this.cContainer.appendChild(newDivU); newDivU = document.createElement("div"); newDivU.style.zIndex = this.nZIndexBase+24; newDivU.innerHTML = GIF(imgname,imgwidth,imgheight,"",-4,0); newDivU.style.left = PX( XRelative(8+this.nScaleXOffset, this.cContainer) ); newDivU.style.top = PX( YRelative(this.nCtrlHeight - 20, this.cContainer) ); newDivU.style.overflow = "hidden"; newDivU.style.position = "absolute"; newDivU.style.width = PX(width); newDivU.style.height = PX(18); this.cContainer.appendChild(newDivU); newDivU = document.createElement("div"); newDivU.style.zIndex = this.nZIndexBase+24; newDivU.innerHTML = GIF(imgname,imgwidth,imgheight,"",-507,0); newDivU.style.left = PX( XRelative(8+this.nScaleXOffset + width, this.cContainer) ); newDivU.style.top = PX( YRelative(this.nCtrlHeight - 20, this.cContainer) ); newDivU.style.overflow = "hidden"; newDivU.style.position = "absolute"; newDivU.style.width = PX(4); newDivU.style.height = PX(18); this.cContainer.appendChild(newDivU); } CAatMap.prototype.SetupControls = function() { var CENTER = -999; var controls = new Array ( new Array (CENTER,0,this.sImageBase+"icons.png,64,256","doControlUp",32,17,"Pan North"), new Array (0,CENTER,this.sImageBase+"icons.png,0,256","doControlLeft",17,32,"Pan West"), new Array (-16,CENTER,this.sImageBase+"icons.png,30,256","doControlRight",17,32,"Pan East"), new Array (CENTER,-17,this.sImageBase+"icons.png,96,256","doControlDown",32,17,"Pan South"), new Array (6,0,this.sImageBase+"icons.png,129,252","doControlZoomOut",19,19,"Zoom Out"), new Array (4,thumb_slider_top,this.sImageBase+"thumb_slider.png","*thumb",19,11,"Drag to zoom in/out"), new Array (6,19,this.sImageBase+"icons.png,230,170","*slider",17,119,"Drag to zoom in/out"), new Array (6,138,this.sImageBase+"icons.png,148,257","doControlZoomIn",19,19,"Zoom Closer"), new Array (-80,0,this.sImageBase+"icons.png,0,57,sat","doControlSatellite",78,19,"View Map as Aerial Photos"), new Array (-149,0,this.sImageBase+"icons.png,0,0,hybrid","doControlHybrid",78,19,"View Map as Street Map overlaying Aerial Photos"), new Array (-218,0,this.sImageBase+"icons.png,0,114,map","doControlMap",78,19 ,"View Map as a Street Map"), new Array (-18,30,this.sImageBase+"icons.png,0,171,points","doPoints",19,78,"Turn Places On and Off"), new Array (-18,98,this.sImageBase+"icons.png,57,171,nums","doControlNumbers",19,78,"View Road Numbers"), new Array (30,0,this.sImageBase+"icons.png,95,0,modemove","doDragModeMove",75,19,"Makes the map move when you hold down the mouse button and drag"), new Array (105,0,this.sImageBase+"icons.png,95,38,modezoom","doDragModeZoom",69,19,"When you hold the left mouse button and drag, it will zoom into the area") // new Array (4,-21,this.sImageBase+"icons.png,168,256","*info",14,14,"") ); offsetLeft = 0; offsetTop = 0; // set up some things var lMap = "off"; var lHybrid = "off"; var lNumbers = "off"; var lSat = "off"; var lPoints = "off"; var lModeMove = "off"; var lModeZoom = "off"; for (l=0;l0.01) { lPoints="disabled"; } */ if (this.GetTileZoom()>0.0025) { lNumbers="disabled"; } if (!this.isSatellite) { lSat = "disabled"; lHybrid = "disabled"; } if (this.dragMode=="m") lModeMove = "on"; if (this.dragMode=="z") lModeZoom = "on"; for (al=0;al1) { picName = picSplit[0]; picX = picSplit[1]*1; picY = picSplit[2]*1; picType = picSplit[3]; newDiv.id = "userctrl_"+picType; } else { picName = picSplit[0]; newDiv.id = "userctrl_"+String(al); } // need modifiers for the stateful buttons if (picType=="hybrid") { if (lHybrid=="on") inFront = true; if (lHybrid=="off") picY+=el[5]*1; if (lHybrid=="disabled") picY+=el[5]*2; if (!this.bModeButtons) drawThis=false; if (lHybrid=="disabled" && !this.bShowGreyButtons) drawThis=false; } if (picType=="nums") { if (lNumbers=="on") inFront = true; if (lNumbers=="off") picX+=el[4]*1; if (lNumbers=="disabled") picX+=el[4]*2; if (!this.bPointsButtons) drawThis=false; if (lNumbers=="disabled" && !this.bShowGreyButtons) drawThis=false; } if (picType=="sat") { if (lSat=="on") inFront = true; if (lSat=="off") picY+=el[5]*1; if (lSat=="disabled") picY+=el[5]*2; if (!this.bModeButtons) drawThis=false; if (lSat=="disabled" && !this.bShowGreyButtons) drawThis=false; } if (picType=="map") { if (lMap=="on") inFront = true; if (lMap=="off") picY+=el[5]*1; if (lMap=="disabled") picY+=el[5]*2; if (!this.bModeButtons) drawThis=false; if (lMap=="disabled" && !this.bShowGreyButtons) drawThis=false; } if (picType=="points") { if (lPoints=="on") inFront = true; if (lPoints=="off") picX+=el[4]*1; if (lPoints=="disabled") picX+=el[4]*2; if (!this.bPointsButtons) drawThis=false; if (lPoints=="disabled" && !this.bShowGreyButtons) drawThis=false; } if (picType=="modemove") { if (lModeMove=="on") inFront = true; if (lModeMove=="off") picY+=el[5]*1; } if (picType=="modezoom") { if (lModeZoom=="on") inFront = true; if (lModeZoom=="off") picY+=el[5]*1; } png = el[2]; if (picName.length>0) { html = PNG(picName,el[4],el[5],el[6],picX,picY,'userctrl_'+String(al)); } else { html = PNG(png,el[4],el[5],el[6],0,0,'userctrl_'+String(al)); } if (drawThis) { if ((el[3]=="doControlHybrid" || el[3]=="doControlSatellite") && lSat=="disabled" ) notHot = true; if (el[3]=="doPoints" && lPoints=="disabled" ) notHot = true; if (el[3]=="doControlNumbers" && lPoints=="disabled" ) notHot = true; if (el[3].length && el[3].slice(0,1)!="*" && !notHot) { newDiv.onclick = associateObjWithEvent(this, el[3]); } newDiv.innerHTML = html; newDiv.style.position = "absolute"; if (!notHot) newDiv.style.cursor = "pointer"; zIndex = this.nZIndexBase+25; if (isModeButton && png.indexOf("_on")>0) zIndex++; if (inFront) zIndex++; newDiv.style.zIndex = zIndex; var pLeft = el[0]; var pTop = el[1]; if (pLeft==CENTER) { pLeft = this.nCtrlWidth/2 - el[4]/2; } if (pTop==CENTER) { pTop = this.nCtrlHeight/2 - el[5]/2; } var posX = 0; if (pLeft>=0) posX = pLeft + offsetLeft; else { posX = this.nCtrlWidth + pLeft - offsetLeft + 1; if (BrowserDetect.browser=="Explorer") posX-=2; } var posY = 0; if (pTop>=0) posY = pTop + offsetTop; else posY = this.nCtrlHeight + pTop - offsetTop + 1; posY = YRelative(posY, this.cContainer); posX = XRelative(posX, this.cContainer); newDiv.style.left = PX(posX); newDiv.style.top = PX(posY); this.cContainer.appendChild(newDiv); if (el[3]=="*slider") { // special setup for the slider newDiv.style.cursor = ""; } if (el[3]=="*info") { gInfoDiv = newDiv; } if (el[3]=="*thumb") { // special setup for the thumb slider newDiv.style.zIndex = this.nZIndexBase+50; newDiv.style.left = PX(posX-20); newDiv.style.top = PX(posY-10); newDiv.innerHTML = "
"+PNG(el[2],el[4],el[5],"",0,0,"thumbtracker","pointer")+"
"; // newDiv.onmousemove = associateObjWithEvent(this, "doSliderMouseMove"); newDiv.onmouseup = associateObjWithEvent(this, "doSliderMouseUp"); newDiv.style.cursor = this.sHandCursor; // the clicks on the background need to feed through to the main map newDiv.onmousedown = associateObjWithEvent(this, "doMouseDown"); this.cSlider=newDiv; getObj("thumbtracker").onmousedown = associateObjWithEvent(this, "doSliderMouseDown"); this.SliderUpdate(); } } // drawThis } } CAatMap.prototype.BrandingClick = function(event, element) { window.open(this.csBrandingUrl,"brandingwindow"); } function fPositionCopyright() { if (this.bNoBranding) return; // put this at the bottom-right var newDiv = document.createElement("div"); newDiv.innerHTML = ""+this.csCopyright+""; newDiv.style.position = "absolute"; newDiv.style.zIndex = this.nZIndexBase+25; newDiv.style.textAlign="right"; this.cContainer.appendChild(newDiv); newDiv.style.left = PX( XRelative(this.nCtrlWidth - newDiv.clientWidth - 4 - this.nCopyrightXMargin, this.cContainer) ); newDiv.style.top = PX( YRelative(this.nCtrlHeight - newDiv.clientHeight - 2, this.cContainer) ); newDiv = document.createElement("div"); newDiv.innerHTML = ""+this.csCopyright+""; newDiv.style.position = "absolute"; newDiv.style.textAlign="right"; newDiv.style.zIndex = this.nZIndexBase+25; this.cContainer.appendChild(newDiv); newDiv.style.left = PX( XRelative(this.nCtrlWidth - newDiv.clientWidth - 5 - this.nCopyrightXMargin, this.cContainer) ); newDiv.style.top = PX( YRelative(this.nCtrlHeight - newDiv.clientHeight - 3, this.cContainer) ); var brDiv = document.createElement("div"); brDiv.style.cursor = "pointer"; this.csBranding = "http://api.maps.brabys.com/img/aclogo.png"; this.nBranding_width=105; this.nBranding_height=42; this.csBrandingTooltip = "Brabys"; this.csBrandingUrl = "http://www.brabys.com"; if (!isUndefined(this.csBranding) && this.nCtrlHeight>300) { if (!isNull(this.csBranding) && this.csBranding.length>0) { brDiv.innerHTML = PNG(this.csBranding,this.nBranding_width,this.nBranding_height,this.csBrandingTooltip); } if (this.csBrandingUrl.length>3) { brDiv.onmousedown = associateObjWithEvent(this, "BrandingClick"); } } if (!isUndefined(this.csBranding) && this.nCtrlHeight>300) { if (!isNull(this.csBranding) && this.csBranding.length>0) { brDiv.innerHTML = PNG(this.csBranding,this.nBranding_width,this.nBranding_height,this.csBrandingTooltip); } if (this.csBrandingUrl.length>3) { brDiv.onmousedown = associateObjWithEvent(this, "BrandingClick"); } } brDiv.style.position = "absolute"; brDiv.style.zIndex = this.nZIndexBase+25; this.cContainer.appendChild(brDiv); brDiv.style.left = PX( XRelative(this.nCtrlWidth - brDiv.clientWidth - this.nCopyrightXMargin - 4, this.cContainer) ); brDiv.style.top = PX( YRelative((this.nCtrlHeight - brDiv.clientHeight - newDiv.clientHeight) -4, this.cContainer) ); this.cCopyright = newDiv; this.cBranding = newDiv; } CAatBitmapLayer.prototype.MoveScreen = function(pDeltaX, pDeltaY, pixels) { // move the layer by the specified amounts (map coordinates) var vTable = this.cMasterTable; if (pixels) { deltaX = pDeltaX; deltaY = pDeltaY; } else { var nPixScale = (this.GetZoom()*2) / this.parent.nCtrlWidth; deltaX = pDeltaX / nPixScale; deltaY = pDeltaY / nPixScale; } this.nOffsetX += deltaX; this.nOffsetY += deltaY; vTable.style.left = PX(this.nOffsetX); vTable.style.top = PX(this.nOffsetY); } function IntersectRectNve(ax1,ay1,ax2,ay2, bx1,by1,bx2,by2) { return ( (ax1>=bx1 && ax1<=bx2 || ax2>=bx1 && ax2<=bx2 || ax1<=bx1 && ax2>=bx2 ) && (ay1<=by1 && ay1>=by2 || ay2<=by1 && ay2>=by2 || ay1<=by1 && ay2>=by2 || ay1>=by1 && ay2<=by2) ); } function IntersectRect(ax1,ay1,ax2,ay2, bx1,by1,bx2,by2) { return ( (ax1>=bx1 && ax1<=bx2 || ax2>=bx1 && ax2<=bx2 || ax1<=bx1 && ax2>=bx2 ) && (ay1>=by1 && ay1<=by2 || ay2>=by1 && ay2<=by2 || ay1>=by1 && ay2<=by2 ) ); } CAatBitmapLayer.prototype.MoveMap = function(pDeltaX, pDeltaY) { var vOrigTable = this.cMasterTable; var vTable = vOrigTable.cloneNode(true); var updated = false; // work out how many pixels to move by var scaler = this.nTileSize / this.GetTileZoom(); pixX = pDeltaX * scaler; pixY = pDeltaY * scaler; // work out the coordinates covered in this map var left = this.GetX() - this.parent.DegWidth()/2; var top = this.GetY() + this.parent.DegHeight()/2; var right = this.GetX() + this.parent.DegWidth()/2; var bottom = this.GetY() - this.parent.DegHeight()/2; // this.parent.DebugPrint("Before: left="+String(left)+", top="+String(top)+", right="+String(right)+", bottom="+String(bottom)); var nTileDegree = this.GetTileZoom() * 2; // now we need to check if we've gone out of bounds for displayed stuff while (left<=this.gridLeft) { // too far left .. insert a column there added=0; this.gridLeft -= nTileDegree; this.nOffsetX -= this.nTileSize; for (ly=0;ly=this.gridRight) { // too far right ... insert a column there added=0; this.gridRight += nTileDegree; for (ly=0;ly=this.gridTop) { // too far up ... insert a row there added=0; this.gridTop += nTileDegree; var vRow = vTable.rows[0]; var colcount = vRow.cells.length; vRow = vTable.insertRow(0); this.nOffsetY -= this.nTileSize; for (lx=0;lx= 1) { vOrigTable.removeChild(vOrigTable.firstChild); } } CheckOffscreen(this); } CheckOffscreen = function(obj) { // check if anything onscreen needs the image loaded for (al=0;al0) al--; newSetTimeout(CheckOffscreen,100,obj); return; */ } } } } CAatMap.prototype.ShowRoute = function(x,y,x1,y1,obj) { if (routeLayer==null) { // if not, add it routeLayer = this.AddLayer("route",99,"route"); } // set the routing layer routeLayer.routeStartX = x; routeLayer.routeStartY = y; routeLayer.routeEndX = x1; routeLayer.routeEndY = y1; } CAatMap.prototype.CalcRoute = function(x,y,x1,y1,obj) { if (routeMarkerLayer==null) { routeMarkerLayer=this.AddLayer("point",99,"route"); routeMarkerLayer.SetDefaultAnchor("center","bottom"); } routeMarkerLayer.DeletePoint("route.start"); var pt = routeMarkerLayer.AddPoint(x,y,"Route Start","route.start"); pt.SetStyle("label"); pt.SetIcon("icon_small/0.png"); pt.SetIconAnchor("center","center"); pt.SetLabelAnchor("left","bottom"); routeMarkerLayer.DeletePoint("route.end"); var pt = routeMarkerLayer.AddPoint(x1,y1,"Route End","route.end"); pt.SetStyle("label"); pt.SetIcon("icon_small/0.png"); pt.SetIconAnchor("center","center"); pt.SetLabelAnchor("left","bottom"); this.ShowRoute(x,y,x1,y1,obj); MurderChildren(getObj("resultsarea")); sUrl = ScriptBase()+"ajax_route.asp?raw=1&fmt=js&jscb=AJAX_Route&x1="+String(x)+"&y1="+String(y)+"&x2="+String(x1)+"&y2="+String(y1) // turn off points or database pane if they're there gPoints = false; gDatabase = false; callObj = new JSONscriptRequest(sUrl); callObj.Go(this.bShowProgress); this.Init(false); } CAatMap.prototype.MenuCallback = function(selected, x, y, obj) { cX = getXRelative(x,obj.cContainer)-obj.nCtrlWidth/2; cX *= (obj.DegWidth()/obj.nCtrlWidth); cX += obj.GetX(); cY = getYRelative(y,obj.cContainer)-obj.nCtrlHeight/2; cY *= (obj.DegHeight()/obj.nCtrlHeight); cY = obj.GetY() - cY; var mapReload = false; var processed = false; dirUpdate = false; if (selected=="abs.dir.from") { selected = "dir.from"; cX = x; cY = y; processed=true; } if (selected=="abs.dir.to") { selected = "dir.to"; cX = x; cY = y; processed=true; mapReload=true; } if (selected=="dir.from") { routeStartX = cX; routeStartY = cY; dirUpdate = true; if (routeMarkerLayer==null) { routeMarkerLayer=obj.AddLayer("point",99,"route"); routeMarkerLayer.SetDefaultAnchor("center","bottom"); } routeMarkerLayer.DeletePoint("route.start"); var pt = routeMarkerLayer.AddPoint(cX,cY,"Route Start","route.start"); pt.SetStyle("label"); pt.SetIcon("icon_small/0.png"); pt.SetIconAnchor("center","center"); pt.SetLabelAnchor("left","bottom"); processed=true; mapReload=true; } if (selected=="dir.to") { routeEndX = cX; routeEndY = cY; dirUpdate = true; if (routeMarkerLayer==null) { routeMarkerLayer=obj.AddLayer("point",99,"route"); routeMarkerLayer.SetDefaultAnchor("center","bottom"); } routeMarkerLayer.DeletePoint("route.end"); var pt = routeMarkerLayer.AddPoint(cX,cY,"Route End","route.end"); pt.SetStyle("label"); pt.SetIcon("icon_small/0.png"); pt.SetIconAnchor("center","center"); pt.SetLabelAnchor("left","bottom"); processed=true; mapReload=true; } if (selected=="dir.clear") { routeStartX = 0; routeStartY = 0; routeEndX = 0; routeEndY = 0; if (routeLayer!=null) { obj.RemoveLayer(routeLayer); routeLayer=null; if (routeMarkerLayer!=null) { routeMarkerLayer.DeletePoint("route.start"); routeMarkerLayer.DeletePoint("route.end"); } getObj("resultsarea").innerHTML=gResultsAreaHTML; obj.Init(); } mapReload=true; processed=true; } if (dirUpdate) { // re-initialise map obj.Init(); if (routeStartX!=0 && routeStartY!=0 && routeEndX!=0 && routeEndY!=0) { obj.CalcRoute(routeStartX,routeStartY,routeEndX,routeEndY,this); } } else { if (mapReload) obj.Init(); } if (!processed && obj.PopupMenuCallback!=null) { obj.PopupMenuCallback(obj,selected,cX,cY); } } function ShowZoomRect(obj,x,y,wid,hei) { if (obj.dragRect==null) { obj.dragRect = document.createElement("div"); obj.dragRect.onmousemove = associateObjWithEvent(obj, "doMouseMove"); obj.dragRect.onmouseup = associateObjWithEvent(obj, "doMouseUp"); obj.dragRect.id = "drag_rect"; obj.cContainer.appendChild(obj.dragRect); obj.dragRect.innerHTML="
"; obj.dragRect.style.cursor = obj.sMagnifyCursor; obj.dragRect.style.overflow = "hidden"; obj.dragRect.style.position = "absolute"; obj.dragRect.style.zIndex = this.nZIndexBase+50; } if (BrowserDetect.browser=="Explorer") { x -= getAbsoluteLeft(obj.cContainer); y -= getAbsoluteTop(obj.cContainer); } // take into account the scroll x += getScrollX(); y += getScrollY(); if (wid<0) { obj.dragRect.style.left = PX(x+wid-1); obj.dragRect.style.width = PX(-wid); } else { obj.dragRect.style.left = x; obj.dragRect.style.width = PX(wid); } if (hei<0) { obj.dragRect.style.top = PX(y+hei-1); obj.dragRect.style.height = PX(-hei); } else { obj.dragRect.style.height = PX(hei); obj.dragRect.style.top = PX(y); } } function CAatMenu(container,x,y,obj) { this.x=x; this.y=y; this.container=container; this.menuDiv=null; this.tableMain=null; this.MenuCallback = null; this.obj=obj; } CAatMenu.prototype.doMouseDown = function(event, element) { StopPropagation(event); return false; } function SrcElement(ev) { if (BrowserDetect.browser=="Explorer") return ev.srcElement; var node = ev.target; while(node.nodeType != node.ELEMENT_NODE) node = node.parentNode; return node; } CAatMenu.prototype.doMouseOver = function(event, element) { element.className = "rcmenu_hover"; StopPropagation(event); return false; } CAatMenu.prototype.doMouseOut = function(event, element) { element.className = "rcmenu_option"; StopPropagation(event); return false; } CAatMenu.prototype.Remove = function() { MurderChildren(this.menuDiv); } CAatMenu.prototype.doMouseClick = function(event, element) { MurderChildren(this.menuDiv); StopPropagation(event); retX = this.x; retY = this.y; if (BrowserDetect.browser=="Explorer") { retX -= getAbsoluteLeft(this.container); retY -= getAbsoluteTop(this.container); } this.MenuCallback(element.id,retX,retY,this.obj); return false; } CAatMenu.prototype.doCloseMenu = function(event, element) { if (SrcElement(event)==this.tableMain) { MurderChildren(this.menuDiv); StopPropagation(event); } return false; } CAatMenu.prototype.AddMenuOption = function(vTable, caption, icon, id) { var vRow = vTable.insertRow(-1); var vCell = vRow.insertCell(-1); if (icon.length>0) vCell.innerHTML = PNG(icon); var vCell = vRow.insertCell(-1); vCell.innerHTML = caption; vCell.className = "rcmenu_option"; vCell.noWrap = true; vCell.onmouseover = associateObjWithEvent(this, "doMouseOver"); vCell.onmouseout = associateObjWithEvent(this, "doMouseOut"); vCell.onclick = associateObjWithEvent(this, "doMouseClick"); vCell.id = id; } CAatMenu.prototype.AddMenuDivider = function(vTable) { var vRow = vTable.insertRow(-1); vRow.style.height="5px"; var vCell = vRow.insertCell(-1); vCell.colSpan = 2; vCell.innerHTML = ""; } CAatMenu.prototype.ShowMenu = function() { this.menuDiv = document.createElement("div"); this.menuDiv.id = "menudiv"; this.menuDiv.style.position = "absolute"; this.menuDiv.style.zIndex = 250; document.body.appendChild(this.menuDiv); var vTable = document.createElement("table"); this.tableMain = vTable; vTable.onmouseout = associateObjWithEvent(this, "doCloseMenu"); vTable.className = "rcmenu"; vTable.cellSpacing = 0; vTable.cellPadding = 2; vTable.id ="vtable"; var vRow = vTable.insertRow(-1); var vCell = vRow.insertCell(-1); vCell.colSpan=2; vCell.innerHTML = "Select An Option"; vCell.noWrap = true; vCell.className = "rcmenu_heading"; this.AddMenuOption(vTable,"Directions FROM Here","img/dir_from.png","dir.from"); this.AddMenuOption(vTable,"Directions TO Here","img/dir_to.png","dir.to"); this.AddMenuOption(vTable,"Clear Directions","","dir.clear"); this.AddMenuOption(vTable,"Zoom to Street Level Here","","zoom.street"); this.AddMenuOption(vTable,"Attach Your Photo here","","user.photo"); this.AddMenuDivider(vTable); this.AddMenuOption(vTable,"Personal Placemarkers","",""); this.AddMenuOption(vTable,"Add Personal Placemarker here","","placemarker.add"); this.AddMenuOption(vTable,"Remove all Personal Placemarkers","","placemarker.remove"); this.AddMenuDivider(vTable); this.AddMenuOption(vTable,"Close Menu","",""); vTable.style.visibility = "hidden"; this.menuDiv.appendChild(vTable); this.menuDiv.style.left = 0; this.menuDiv.style.top = 0; // make sure it stays in the container placeX = this.x-4; placeY = this.y-16; rightside = placeX+vTable.clientWidth-getAbsoluteLeft(this.container); bottomside = placeY+vTable.clientHeight-getAbsoluteTop(this.container); if (rightside > this.container.clientWidth) { placeX += (this.container.clientWidth - rightside); placeX -= 8; // placeX = (this.container.clientWidth - vTable.clientWidth-8) + getAbsoluteLeft(this.container); } if (bottomside > this.container.clientHeight) { placeY += (this.container.clientHeight - bottomside); placeY -= 8; } vTable.style.visibility = "visible"; this.menuDiv.style.left = placeX; this.menuDiv.style.top = placeY; } CAatMap.prototype.doMouseUp = function(event, element) { // pixels to count as a single click singleclick_threshold = 3; if (event.button==REF_RIGHT_BUTTON()) { // rt button if (this.bPopupMenu) { if (gMenu!=null) { gMenu.Remove(); gMenu=null; } gMenu = new CAatMenu(this.cOutput, event.clientX, event.clientY, this); gMenu.MenuCallback=this.MenuCallback; gMenu.ShowMenu(); return false; } } else { var srcEl = SourceElement(event) if (srcEl.id.slice(0,9)=="userctrl_" || srcEl.id.slice(0,9)=="mappoint_") { // clicked on a user control or point - exit now this.SetCursor(this.GetBaseCursor()); this.bDragging = false; return; } retX = event.clientX - getAbsoluteLeft(this.cContainer) + getScrollX(); retY = event.clientY - getAbsoluteTop(this.cContainer) + getScrollY(); obj = this; cX = retX-obj.nCtrlWidth/2; cX *= (obj.DegWidth()/obj.nCtrlWidth); cX += obj.GetX(); cY = retY-obj.nCtrlHeight/2; cY *= (obj.DegHeight()/obj.nCtrlHeight); cY = obj.GetY() - cY; var deltaX = event.clientX-this.nOrigClickX; var deltaY = event.clientY-this.nOrigClickY; if (this.dragMode=="z") { if (!this.bDragging) return; this.SetCursor(this.GetBaseCursor()); this.bDragging = false; // check if this is a single click if (Math.sqrt(deltaX*deltaX + deltaY*deltaY) <= singleclick_threshold && this.ClickCallback!=null) { this.ClickCallback(this,cX,cY); return; } // we have end drag coords, find beginning retX2 = this.nClickX - getAbsoluteLeft(this.cContainer); retY2 = this.nClickY - getAbsoluteTop(this.cContainer); retY2 += getScrollY(); retX2 += getScrollX(); cX2 = retX2-obj.nCtrlWidth/2; cX2 *= (obj.DegWidth()/obj.nCtrlWidth); cX2 += obj.GetX(); cY2 = retY2-obj.nCtrlHeight/2; cY2 *= (obj.DegHeight()/obj.nCtrlHeight); cY2 = obj.GetY() - cY2; // find the center and zoom level cenX = (cX+cX2)/2; cenY = (cY+cY2)/2; xSize = Math.abs(cX-cX2); ySize = Math.abs(cY-cY2); if (xSize>ySize) cenZ = xSize/2; else cenZ = ySize/2; cenZ/=(this.nCtrlWidth/this.nTileSize); newZ = this.FindZoom(cenZ, cenZ, this.snaps[this.snaps.length-1]); if (newZ==this.nTileZoom) { newZ = this.FindSnap(cenZ); } this.JumpTo(cenX, cenY, newZ); MurderChildren(obj.dragRect); obj.dragRect=null; this.Init(); } if (this.dragMode=="m") { if (!this.bDragging) return; this.SetCursor(this.GetBaseCursor()); this.bDragging = false; // check if this is a single click if (Math.sqrt(deltaX*deltaX + deltaY*deltaY) <= singleclick_threshold && this.ClickCallback!=null) { this.ClickCallback(this,cX,cY); return; } this.DoStatusUpdate(); if (this.RedrawCallback!=null) { this.RedrawCallback(this,this.GetX(),this.GetY(),"doMouseUp"); } } // if (this.dragMode=="m") { return false; } } CAatMap.prototype.doMouseDown = function(event, element) { if (event.button==REF_LEFT_BUTTON()) { if (this.dragMode=="m" || this.dragMode=="z") { this.bDragging = true; this.nClickX = event.clientX; this.nClickY = event.clientY; this.nOrigClickX = event.clientX; this.nOrigClickY = event.clientY; } if (this.dragMode=="z") { // ShowZoomRect(this,this.nOrigClickX,this.nOrigClickY,1,1); } if (this.dragMode=="m") { this.SetCursor(this.sGrabCursor); } } return false; } CAatMap.prototype.doMouseMove = function(event, element) { if (this.dragMode=="m" || this.dragMode=="z") { if (!this.bDragging) return false; var deltaX = event.clientX-this.nClickX; var deltaY = event.clientY-this.nClickY; } if (this.dragMode=="z") { if (!this.bDragging) return false; ShowZoomRect(this,this.nOrigClickX,this.nOrigClickY,deltaX,deltaY); } if (this.dragMode=="m") { if (!this.bDragging) return false; var vTable = this.cMasterTable; var deltaX = event.clientX-this.nClickX; var deltaY = event.clientY-this.nClickY; var nPixScale = (this.nZoom*2) / this.nCtrlWidth; var pDeltaX = nPixScale * deltaX; var pDeltaY = nPixScale * deltaY; this.SetX(this.GetX()-pDeltaX); this.SetY(this.GetY()+pDeltaY); for (layer=0;layer0) { RemoveBubble(String(pt.userRef),"point."+String(pt.userRef),'fixedPoiLayer',pt.parent.csContainer); } else { ReplaceBubble(String(pt.userRef),"point."+String(pt.userRef),'fixedPoiLayer',pt.parent.csContainer); } } var fixedPoiLayer = null; var prevCreds = "X"; function AJAX_Status(ctrlname,dat) { gWait.Stop(); var obj = MapArray[ctrlname]; if (!isUndefined(obj)) { var map = obj.mapobj; if (!isUndefined(dat.results.error)) return; var dirty = false; if (!isUndefined(dat.results) && !isUndefined(dat.results.points)) { var exempt = new Array(); dirty = true; if (fixedPoiLayer==null) { fixedPoiLayer = map.AddLayer("point",80,"points"); fixedPoiLayer.SetDefaultAnchor("center","center"); } else { // see if anything's popped up var poppedUp = ""; for (var pl=0;pl0?exempt:null); } for (var l=0;lView Details"; var id = "point."+pnt.ref; var pt = fixedPoiLayer.AddPoint(pnt.x*1,pnt.y*1,htmlCaption,id); pt.userRef=pnt.ref; pt.SetStyle(id==poppedUp?"label":"icon"); pt.SetIcon(GetIconName(pnt.cat)); pt.SetCallback(ReplaceBubbleInplace); pt.SetTooltip(pnt.caption); pt.SetIconAnchor("center","center"); pt.SetLabelAnchor("center","center"); pt.SetClickBehaviour("toggle_icon_label"); } } } var creds = ""; if (!isUndefined(dat.results.credits)) { for (l=0;l0) { copybit = " ©" + cred[2]; } credbit = cred[0] + copybit + " " + cred[1] + "
"; creds = creds + credbit if (creds != prevCreds) { dirty = true; prevCreds = creds; } } } //map.csCopyright=creds; if (map.AJAX_Status_Callback!=null) { map.AJAX_Status_Callback(dat); } else { if (dirty) map.Init(); } } } CAatMap.prototype.Init = function(callbacks) { if (this.cContainer.clientWidth==0) { newSetTimeout(RedoInit,100,this); return; } if (!this.bHotKeyAssoc && this.bUseHotkeys) { document.onkeyup = associateObjWithEvent(this, "DocKeyUp"); document.onkeydown = associateObjWithEvent(this, "DocKeyDown");; this.bHotKeyAssoc = true; } if (this.cScratch==null) { // create a scratch div this.cScratch = document.createElement("div"); this.cScratch.style.position = "absolute"; this.cScratch.style.visibility = "hidden"; this.cScratch.style.left=PX(0); this.cScratch.style.top=PX(0); document.body.appendChild(this.cScratch); this.SetCopyright(); this.SetBranding(); } if (this.baseOverride=="") { var sc = document.getElementsByTagName('script'); for (l=0;l0) { src = src.substring(0,src.indexOf("aatmaps.js")-1) this.baseOverride = src; } } } if (this.cContainer==null) { this.DebugPrint("ERROR: Init - No Container Set"); return; } // clean out the div while (this.cContainer.childNodes.length >= 1) { this.cContainer.removeChild(this.cContainer.firstChild); } var oWidth = isNull(this.cContainer.clientWidth)?0:this.cContainer.clientWidth; var oHeight = isNull(this.cContainer.clientHeight)?0:this.cContainer.clientHeight; this.cOutput = document.createElement("div"); this.bMouseAssoc=false; this.cOutput.id = "map_workspace"; this.cContainer.appendChild(this.cOutput); this.cOutput.style.overflow = "hidden"; if (BrowserDetect.browser=="Firefox" || BrowserDetect.browser=="Mozilla") { oWidth-=2; oHeight-=2; } this.cOutput.style.width = PX(oWidth); this.cOutput.style.height = PX(oHeight); if (this.statusImg==null) { this.statusImg = document.createElement("img"); this.cContainer.appendChild(this.statusImg); this.statusImg.style.position = "absolute"; this.statusImg.style.visibility = "hidden"; } this.nCtrlWidth = this.cOutput.clientWidth; this.nCtrlHeight = this.cOutput.clientHeight; if (BrowserDetect.browser=="Explorer") { this.nCtrlLeft = getAbsoluteLeft(this.cOutput); this.nCtrlTop = getAbsoluteTop(this.cOutput); } this.nCtrlAbsLeft = getAbsoluteLeft(this.cOutput); this.nCtrlAbsTop = getAbsoluteTop(this.cOutput); var nXTiles = this.nCtrlWidth / this.nTileSize; if (this.nTileZoom==0) { // work out the tile zoom to fit in the entire country // needs to be 10.24 in total target = 8.5 / nXTiles; for (l=this.snaps.length-1;l>=0;l--) { if (this.snaps[l]>target) { this.nTileZoom = this.snaps[l]; break; } } } // work out the zoom, nNormalZoom = size for a tile this.nZoom = this.nTileZoom * nXTiles; this.nScrollStepX = this.nZoom * 1.5; this.nScrollStepY = this.nZoom * 1.5; if (this.bUseMouse && !this.bMouseAssoc) { this.cOutput.onmouseover = associateObjWithEvent(this, "doMouseEnter"); this.cOutput.onmouseout = associateObjWithEvent(this, "doMouseLeave"); this.cOutput.onmouseup = associateObjWithEvent(this, "doMouseUp"); if (BrowserDetect.browser=="Safari" && BrowserDetect.OS=="Mac") { this.cOutput.oncontextmenu = associateObjWithEvent(this, "doMouseUp"); } this.cOutput.onmousedown = associateObjWithEvent(this, "doMouseDown"); this.cOutput.onmousemove = associateObjWithEvent(this, "doMouseMove"); this.cOutput.ondblclick = associateObjWithEvent(this, "doDoubleClick"); this.bMouseAssoc = true; } document.onmouseout = associateObjWithEvent(this, "MouseOutDragArea"); // set the border of the container to something this.cOutput.style.border = "1px solid "+this.colBorder; this.PositionCopyright(); if (this.bNavigate) this.SetupControls(); if (this.bScaleBar) this.SetupScale(); for (layer=0;layerY: "+String(this.GetY().toFixed(6))+"
]"; } var doCallbacks = callbacks; if (isUndefined(callbacks)) doCallbacks = true; if (this.RedrawCallback!=null && doCallbacks) { this.RedrawCallback(this,this.GetX(),this.GetY(),"Init"); } this.DoStatusUpdate(); this.SetCursor(this.GetBaseCursor()); } CAatMap.prototype.DoStatusUpdate = function() { if (this.NoStatusCallback) return; var s = "m"; for (l=0;l"); // this.csDebug = ctrlname; this.cDebug = this.wDebug.document.getElementById("debugwindow"); // this.cDebug.value = ""; this.DebugPrint("Debug Activated"); } CAatMap.prototype.MouseOutDragArea = function(event, element) { var outWindow = false; if (BrowserDetect.browser=="Explorer") { outWindow = (window.event.toElement==null); } else { if (event.target.firstChild) { if (event.target.firstChild.tagName=="HEAD") outWindow=true; } } if (outWindow) { return this.doMouseUp(event,element); } } // dynamic google analytics integration var gaTicker = 0; var pageTracker = null; function CheckGA() { if (typeof _gat != 'undefined') { //pageTracker = _gat._getTracker("UA-3984417-1"); //pageTracker._initData(); //pageTracker._trackPageview("/main"); //return; } gaTicker++; if (gaTicker<100) { // setTimeout("CheckGA()", 100); } }