﻿Type.registerNamespace("Audley.Maps"); Audley.Maps.IDescriptionFormatter = function() { throw new Error.notImplemented(); }; Audley.Maps.IDescriptionFormatter.prototype = { format: function(object, map) { throw new Error.notImplemented(); } }; Audley.Maps.IDescriptionFormatter.registerInterface('Audley.Maps.IDescriptionFormatter'); if (typeof (Sys) !== "undefined") Sys.Application.notifyScriptLoaded(); Type.registerNamespace("Audley.Maps"); Audley.Maps.StaticData = function() { }; Audley.Maps.StaticData.getCategories = function(error) { return [["Popular places", "0"], ["Festivals & Events", "40697CB3-5DBD-4692-9999-14DA26107B8E"], ["Journeys & Cruises", "F7E1CD7B-A15F-4EF3-8657-F71E6CBAD068"], ["Safari & Wildlife ", "3CEE8EA6-1B57-453C-AD55-979C07CFAB3A"], ["Activities & Adventure", "5F861BFC-5BB0-4293-9201-7C0616D0887C"], ["Food & Drink ", "22D8EAC5-285C-4588-AEFF-D21BD5A4C469"], ["Beach & Relaxation", "8919136B-0B6B-4E90-9CCE-4DCD1CD8BBEC"], ["Landscape & Scenery", "56197803-FE83-4203-A70F-FF51A3F714B7"], ["History & Culture", "4B9DD064-798D-49FA-BA49-0A11206B749C"]] }; Audley.Maps.StaticData.registerClass('Audley.Maps.StaticData'); if (typeof (Sys) !== "undefined") Sys.Application.notifyScriptLoaded(); Type.registerNamespace("Audley.Maps"); Audley.Maps.PlaceFormatter = function() { }; Audley.Maps.PlaceFormatter.prototype = { format: function(object, map) { var result = document.createElement("div"); result.id = "container"; var leftdiv = document.createElement("div"); leftdiv.id = "container_left"; var rightdiv = document.createElement("div"); rightdiv.id = "container_right"; var imagediv = document.createElement("div"); imagediv.id = "thumbimage"; var image = document.createElement("img"); image.setAttribute("src", object.ImageUrl); var placenamediv = document.createElement("div"); placenamediv.id = "placename"; var placename = document.createTextNode(object.Name); var content = document.createTextNode(object.Description); var zoombutton = document.createElement("a"); zoombutton.id = "detailszoombut"; zoombutton.setAttribute("href", "#"); var zoombuttontext = document.createTextNode("Zoom in"); var readmorebutton = document.createElement("a"); readmorebutton.id = "readmore"; readmorebutton.setAttribute("href", object.MoreInfoUrl); var readmorebuttontext = document.createTextNode("Read more"); var linkdiv = document.createElement("div"); linkdiv.id = "links"; $addHandler(zoombutton, "click", function() { map.setZoom(15) }); placenamediv.appendChild(placename); imagediv.appendChild(image); rightdiv.appendChild(placenamediv); rightdiv.appendChild(content); leftdiv.appendChild(imagediv); zoombutton.appendChild(zoombuttontext); linkdiv.appendChild(zoombutton); readmorebutton.appendChild(readmorebuttontext); linkdiv.appendChild(readmorebutton); rightdiv.appendChild(linkdiv); result.appendChild(leftdiv); result.appendChild(rightdiv); return result } }; Audley.Maps.PlaceFormatter.registerClass('Audley.Maps.PlaceFormatter', null, Audley.Maps.IDescriptionFormatter); Audley.Maps.SelectionChangedEventArgs = function(newselection) { if (arguments.length !== 1) throw Error.parameterCount(); Audley.Maps.SelectionChangedEventArgs.initializeBase(this); this._newselection = newselection }; Audley.Maps.SelectionChangedEventArgs.prototype = { get_newSelection: function() { if (arguments.length !== 0) throw Error.parameterCount(); return this._newselection } }; Audley.Maps.SelectionChangedEventArgs.registerClass('Audley.Maps.SelectionChangedEventArgs', Sys.EventArgs); Audley.Maps.MapPointChangedEventArgs = function(id, lat, lon) { if (arguments.length !== 3) throw Error.parameterCount(); Audley.Maps.MapPointChangedEventArgs.initializeBase(this); this._id = id; this._lat = lat; this._lon = lon }; Audley.Maps.MapPointChangedEventArgs.prototype = { get_newId: function() { if (arguments.length !== 0) throw Error.parameterCount(); return this._id }, get_newLatitude: function() { if (arguments.length !== 0) throw Error.parameterCount(); return this._lat }, get_newLongitude: function() { if (arguments.length !== 0) throw Error.parameterCount(); return this._lon } }; Audley.Maps.MapPointChangedEventArgs.registerClass('Audley.Maps.MapPointChangedEventArgs', Sys.EventArgs); if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded(); function pageLoad() { var placeControl, placeId; var miniMapControl, isMiniMap; placeControl = $get("placeID"); if (placeControl != null) { placeId = placeControl.innerHTML; miniMapControl = $get("miniMap"); if (miniMapControl != null) { isMiniMap = miniMapControl.innerHTML } } else { placeId = null } $create(Audley.Maps.LocationMap, { "Bounds": $get("bounds").innerHTML, "CountryId": $get("countryID").innerHTML, "PlaceId": placeId, "IsMiniMap": isMiniMap }, null, null, $get("map_canvas")) } var GlobalCallQueue = { _callQueue: [], _callInProgressNames: [], _callInProgress: 0, _maxConcurrentCall: 2, call: function(servicePath, methodName, useGet, params, onSuccess, onFailure, userContext, timeout) { var queuedCall = new QueuedCall(servicePath, methodName, useGet, params, onSuccess, onFailure, userContext, timeout); for (var x = 0; x < GlobalCallQueue._callQueue.length; x++) { if (GlobalCallQueue._callQueue[x]._methodName == queuedCall._methodName) { Array.removeAt(GlobalCallQueue._callQueue, x); break } } Array.add(GlobalCallQueue._callQueue, queuedCall); GlobalCallQueue.run() }, run: function() { if (GlobalCallQueue._callInProgress < GlobalCallQueue._maxConcurrentCall) { if (0 == GlobalCallQueue._callQueue.length) { return } GlobalCallQueue._callInProgress++; var runIndex = -1; for (var x = 0; x < GlobalCallQueue._callQueue.length; x++) { var found = false; for (var y = 0; y < GlobalCallQueue._callInProgressNames.length; y++) { if (GlobalCallQueue._callQueue[x]._methodName == GlobalCallQueue._callInProgressNames[y]) { found = true; break } } if (!found) { runIndex = x; break } } if (runIndex != -1) { var queuedCall = GlobalCallQueue._callQueue[runIndex]; Array.removeAt(GlobalCallQueue._callQueue, runIndex); Array.add(GlobalCallQueue._callInProgressNames, queuedCall._methodName); queuedCall.execute() } else { GlobalCallQueue._callInProgress-- } } }, callComplete: function(methodName) { GlobalCallQueue._callInProgress--; for (var x = 0; x < GlobalCallQueue._callInProgressNames.length; x++) { if (GlobalCallQueue._callInProgressNames[x] == methodName) { Array.removeAt(GlobalCallQueue._callInProgressNames, x); break } } GlobalCallQueue.run() } }; QueuedCall = function(servicePath, methodName, useGet, params, onSuccess, onFailure, userContext, timeout) { this._servicePath = servicePath; this._methodName = methodName; this._useGet = useGet; this._params = params; this._onSuccess = onSuccess; this._onFailure = onFailure; this._userContext = userContext; this._timeout = timeout }; QueuedCall.prototype = { execute: function() { Sys.Net.WebServiceProxy.original_invoke(this._servicePath, this._methodName, this._useGet, this._params, Function.createDelegate(this, this.onSuccess), Function.createDelegate(this, this.onFailure), this._userContext, this._timeout) }, onSuccess: function(result, userContext, methodName) { GlobalCallQueue.callComplete(methodName); this._onSuccess(result, userContext, methodName) }, onFailure: function(result, userContext, methodName) { GlobalCallQueue.callComplete(methodName); this._onFailure(result, userContext, methodName) } }; Sys.Net.WebServiceProxy.original_invoke = Sys.Net.WebServiceProxy.invoke; Sys.Net.WebServiceProxy.invoke = function Sys$Net$WebServiceProxy$invoke(servicePath, methodName, useGet, params, onSuccess, onFailure, userContext, timeout) { GlobalCallQueue.call(servicePath, methodName, useGet, params, onSuccess, onFailure, userContext, timeout) }; if (typeof (Sys) !== "undefined") Sys.Application.notifyScriptLoaded(); Type.registerNamespace("Earthware.GMaps"); Earthware.GMaps.Utils = function() { }; Earthware.GMaps.Utils.parseBoundingBox = function(bb, delim) { if (delim == null) delim = ","; var latlons = bb.split(delim); var g = google.maps; if (latlons.length < 4) throw "too few values, has to be 4"; return new GLatLngBounds(new GLatLng(latlons[0], latlons[1]), new GLatLng(latlons[2], latlons[3])) }; Earthware.GMaps.Utils.registerClass('Earthware.GMaps.Utils'); google.maps.Marker.prototype.ref = ""; google.maps.Marker.prototype.tooltip = ""; if (typeof (Sys) !== "undefined") Sys.Application.notifyScriptLoaded(); function ExtInfoWindow(marker, windowId, html, opt_opts) { this.html_ = html; this.marker_ = marker; this.infoWindowId_ = windowId; this.infoWindowId = windowId; this.options_ = opt_opts === null ? {} : opt_opts; this.ajaxUrl_ = this.options_.ajaxUrl == null ? null : this.options_.ajaxUrl; this.callback_ = this.options_.ajaxCallback == null ? null : this.options_.ajaxCallback; this.maxContent_ = this.options_.maxContent == null ? null : this.options_.maxContent; this.maximizeEnabled_ = this.maxContent_ == null ? false : true; this.isMaximized_ = false; this.borderSize_ = this.options_.beakOffset == null ? 0 : this.options_.beakOffset; this.paddingX_ = this.options_.paddingX == null ? 0 + this.borderSize_ : this.options_.paddingX + this.borderSize_; this.paddingY_ = this.options_.paddingY == null ? 0 + this.borderSize_ : this.options_.paddingY + this.borderSize_; this.maxPanning_ = this.options_.maxPanning == null ? 500 : this.options_.maxPanning; this.map_ = null; this.container_ = document.createElement('div'); this.container_.style.position = 'relative'; this.container_.style.display = 'none'; this.contentDiv_ = document.createElement('div'); this.contentDiv_.id = this.infoWindowId_ + '_contents'; this.contentDiv_.innerHTML = this.html_; this.contentDiv_.style.display = 'block'; this.contentDiv_.style.visibility = 'hidden'; this.wrapperDiv_ = document.createElement('div') }; ExtInfoWindow.prototype = new GOverlay(); ExtInfoWindow.prototype.initialize = function(map) { this.map_ = map; if (this.maximizeEnabled_) { this.maxWidth_ = this.map_.getSize().width * 0.9; this.maxHeight_ = this.map_.getSize().height * 0.9 } this.defaultStyles = { containerWidth: this.map_.getSize().width / 2, borderSize: 1 }; this.wrapperParts = { tl: { t: 0, l: 0, w: 0, h: 0, domElement: null }, t: { t: 0, l: 0, w: 0, h: 0, domElement: null }, tr: { t: 0, l: 0, w: 0, h: 0, domElement: null }, l: { t: 0, l: 0, w: 0, h: 0, domElement: null }, r: { t: 0, l: 0, w: 0, h: 0, domElement: null }, bl: { t: 0, l: 0, w: 0, h: 0, domElement: null }, b: { t: 0, l: 0, w: 0, h: 0, domElement: null }, br: { t: 0, l: 0, w: 0, h: 0, domElement: null }, beak: { t: 0, l: 0, w: 0, h: 0, domElement: null }, close: { t: 0, l: 0, w: 0, h: 0, domElement: null} }; if (this.maximizeEnabled_) { this.wrapperParts.max = { t: 0, l: 0, w: 0, h: 0, domElement: null }; this.wrapperParts.min = { t: 0, l: 0, w: 0, h: 0, domElement: null} } for (var i in this.wrapperParts) { var tempElement = document.createElement('div'); tempElement.id = this.infoWindowId_ + '_' + i; tempElement.style.visibility = 'hidden'; document.body.appendChild(tempElement); tempElement = document.getElementById(this.infoWindowId_ + '_' + i); var tempWrapperPart = this.wrapperParts[i]; tempWrapperPart.w = parseInt(this.getStyle_(tempElement, 'width'), 10); tempWrapperPart.h = parseInt(this.getStyle_(tempElement, 'height'), 10); document.body.removeChild(tempElement) } for (var i in this.wrapperParts) { if (i == 'close') { this.wrapperDiv_.appendChild(this.contentDiv_) } var wrapperPartsDiv = null; if (this.wrapperParts[i].domElement == null) { wrapperPartsDiv = document.createElement('div'); this.wrapperDiv_.appendChild(wrapperPartsDiv) } else { wrapperPartsDiv = this.wrapperParts[i].domElement } wrapperPartsDiv.id = this.infoWindowId_ + '_' + i; wrapperPartsDiv.style.position = 'absolute'; wrapperPartsDiv.style.width = this.wrapperParts[i].w + 'px'; wrapperPartsDiv.style.height = this.wrapperParts[i].h + 'px'; wrapperPartsDiv.style.top = this.wrapperParts[i].t + 'px'; wrapperPartsDiv.style.left = this.wrapperParts[i].l + 'px'; this.wrapperParts[i].domElement = wrapperPartsDiv } this.map_.getPane(G_MAP_FLOAT_PANE).appendChild(this.container_); this.container_.id = this.infoWindowId_; var containerWidth = this.getStyle_(document.getElementById(this.infoWindowId_), 'width'); this.container_.style.width = (containerWidth == null ? this.defaultStyles.containerWidth : containerWidth); this.map_.getContainer().appendChild(this.contentDiv_); this.contentWidth = this.getDimensions_(this.container_).width; this.contentDiv_.style.width = this.contentWidth + 'px'; this.contentDiv_.style.position = 'absolute'; this.container_.appendChild(this.wrapperDiv_); if (this.maximizeEnabled_) { this.minWidth_ = this.getDimensions_(this.container_).width; console.log(this.minWidth_) } if (this.maximizeEnabled_) { thisMap = this.map_; thisMaxWidth = this.maxWidth_; thisMaxHeight = this.maxHeight_; thisContainer = this.container_; thisMaxContent = this.maxContent_; if (this.marker_) { GEvent.trigger(this.marker_, 'extinfowindowbeforeclose') } thisMinWidth = this.container_.style.width; thisMinHeight = this.container_.style.height; GEvent.addDomListener(this.wrapperParts.max.domElement, 'click', function() { var infoWindow = thisMap.getExtInfoWindow(); infoWindow.container_.style.width = thisMaxWidth + 'px'; infoWindow.ajaxRequest_(thisMaxContent); if (this.marker_) { GEvent.trigger(this.marker_, 'extinfowindowclose') } infoWindow.isMaximized_ = true; infoWindow.redraw(true); infoWindow.toggleMaxMin_() }); GEvent.addDomListener(this.wrapperParts.min.domElement, 'click', function() { var infoWindow = thisMap.getExtInfoWindow(); infoWindow.container_.style.width = thisMinWidth; infoWindow.container_.style.height = thisMinHeight; if (infoWindow.ajaxUrl_ != null) { infoWindow.ajaxRequest_(this.ajaxUrl_) } else { infoWindow.contentDiv_.innerHTML = infoWindow.html_ } infoWindow.isMaximized_ = false; infoWindow.redraw(true); infoWindow.resize(); infoWindow.toggleMaxMin_() }); this.toggleMaxMin_() } var stealEvents = ['mousedown', 'dblclick', 'DOMMouseScroll']; for (i = 0; i < stealEvents.length; i++) { GEvent.bindDom(this.container_, stealEvents[i], this, this.onClick_) } GEvent.trigger(this.map_, 'extinfowindowopen'); if (this.ajaxUrl_ != null) { this.ajaxRequest_(this.ajaxUrl_) } }; ExtInfoWindow.prototype.onClick_ = function(e) { if (navigator.userAgent.toLowerCase().indexOf('msie') != -1 && document.all) { window.event.cancelBubble = true; window.event.returnValue = false } else { e.stopPropagation() } }; ExtInfoWindow.prototype.remove = function() { if (this.map_.getExtInfoWindow() != null) { GEvent.trigger(this.map_, 'extinfowindowbeforeclose'); GEvent.clearInstanceListeners(this.container_); if (this.container_.outerHTML) { this.container_.outerHTML = '' } if (this.container_.parentNode) { this.container_.parentNode.removeChild(this.container_) } this.container_ = null; GEvent.trigger(this.map_, 'extinfowindowclose'); this.map_.setExtInfoWindow_(null) } }; ExtInfoWindow.prototype.copy = function() { return new ExtInfoWindow(this.marker_, this.infoWindowId_, this.html_, this.options_) }; ExtInfoWindow.prototype.redraw = function(force) { if (!force || this.container_ == null) return; var contentHeight = this.contentDiv_.offsetHeight; this.contentDiv_.style.height = contentHeight + 'px'; this.contentWidth = this.getDimensions_(this.container_).width; this.contentDiv_.style.width = this.container_.style.width; this.contentDiv_.style.left = this.wrapperParts.l.w + 'px'; this.contentDiv_.style.top = this.wrapperParts.tl.h + 'px'; this.contentDiv_.style.visibility = 'visible'; this.wrapperParts.tl.t = 0; this.wrapperParts.tl.l = 0; this.wrapperParts.t.l = this.wrapperParts.tl.w; this.wrapperParts.t.w = (this.wrapperParts.l.w + this.contentWidth + this.wrapperParts.r.w) - this.wrapperParts.tl.w - this.wrapperParts.tr.w; this.wrapperParts.t.h = this.wrapperParts.tl.h; this.wrapperParts.tr.l = this.wrapperParts.t.w + this.wrapperParts.tl.w; this.wrapperParts.l.t = this.wrapperParts.tl.h; this.wrapperParts.l.h = contentHeight; this.wrapperParts.r.l = this.contentWidth + this.wrapperParts.l.w; this.wrapperParts.r.t = this.wrapperParts.tr.h; this.wrapperParts.r.h = contentHeight; this.wrapperParts.bl.t = contentHeight + this.wrapperParts.tl.h; this.wrapperParts.b.l = this.wrapperParts.bl.w; this.wrapperParts.b.t = contentHeight + this.wrapperParts.tl.h; this.wrapperParts.b.w = (this.wrapperParts.l.w + this.contentWidth + this.wrapperParts.r.w) - this.wrapperParts.bl.w - this.wrapperParts.br.w; this.wrapperParts.b.h = this.wrapperParts.bl.h; this.wrapperParts.br.l = this.wrapperParts.b.w + this.wrapperParts.bl.w; this.wrapperParts.br.t = contentHeight + this.wrapperParts.tr.h; this.wrapperParts.beak.l = this.borderSize_ + (this.contentWidth / 2) - (this.wrapperParts.beak.w / 2); this.wrapperParts.beak.t = this.wrapperParts.bl.t + this.wrapperParts.bl.h - this.borderSize_; this.wrapperParts.close.l = this.wrapperParts.tr.l + this.wrapperParts.tr.w - this.wrapperParts.close.w - this.borderSize_; this.wrapperParts.close.t = this.borderSize_; if (this.maximizeEnabled_) { this.wrapperParts.max.l = this.wrapperParts.close.l - this.wrapperParts.max.w - 5; this.wrapperParts.max.t = this.wrapperParts.close.t; this.wrapperParts.min.l = this.wrapperParts.max.l; this.wrapperParts.min.t = this.wrapperParts.max.t } for (var i in this.wrapperParts) { if (i == 'close') { this.wrapperDiv_.insertBefore(this.contentDiv_, this.wrapperParts[i].domElement) } var wrapperPartsDiv = null; if (this.wrapperParts[i].domElement == null) { wrapperPartsDiv = document.createElement('div'); this.wrapperDiv_.appendChild(wrapperPartsDiv) } else { wrapperPartsDiv = this.wrapperParts[i].domElement } wrapperPartsDiv.id = this.infoWindowId_ + '_' + i; wrapperPartsDiv.style.position = 'absolute'; wrapperPartsDiv.style.width = this.wrapperParts[i].w + 'px'; wrapperPartsDiv.style.height = this.wrapperParts[i].h + 'px'; wrapperPartsDiv.style.top = this.wrapperParts[i].t + 'px'; wrapperPartsDiv.style.left = this.wrapperParts[i].l + 'px'; this.wrapperParts[i].domElement = wrapperPartsDiv } var currentMarker = this.marker_; var thisMap = this.map_; GEvent.addDomListener(this.wrapperParts.close.domElement, 'click', function() { thisMap.closeExtInfoWindow() }); var pixelLocation = this.map_.fromLatLngToDivPixel(this.marker_.getPoint()); this.container_.style.position = 'absolute'; var markerIcon = this.marker_.getIcon(); this.container_.style.left = (pixelLocation.x - (this.contentWidth / 2) - markerIcon.iconAnchor.x + markerIcon.infoWindowAnchor.x) + 'px'; this.container_.style.top = (pixelLocation.y - this.wrapperParts.bl.h - contentHeight - this.wrapperParts.tl.h - this.wrapperParts.beak.h - markerIcon.iconAnchor.y + markerIcon.infoWindowAnchor.y + this.borderSize_) + 'px'; this.container_.style.display = 'block'; if (this.map_.getExtInfoWindow() != null) { this.repositionMap_() } }; ExtInfoWindow.prototype.toggleMaxMin_ = function() { if (this.wrapperParts.max.domElement != null && this.wrapperParts.min.domElement != null) { if (this.isMaximized_) { this.wrapperParts.max.domElement.style.display = 'none'; this.wrapperParts.min.domElement.style.display = 'block' } else { this.wrapperParts.max.domElement.style.display = 'block'; this.wrapperParts.min.domElement.style.display = 'none' } } }; ExtInfoWindow.prototype.resize = function() { var thisMapContainer = this.map_.getContainer(); var tempElement = this.contentDiv_.cloneNode(true); tempElement.id = this.infoWindowId_ + '_tempContents'; tempElement.style.visibility = 'hidden'; tempElement.style.height = 'auto'; thisMapContainer.appendChild(tempElement); tempElement = document.getElementById(this.infoWindowId_ + '_tempContents'); var contentHeight = tempElement.offsetHeight; thisMapContainer.removeChild(tempElement); this.contentDiv_.style.height = contentHeight + 'px'; var contentWidth = this.container_.offsetWidth; var pixelLocation = this.map_.fromLatLngToDivPixel(this.marker_.getPoint()); var oldWindowHeight = this.wrapperParts.t.domElement.offsetHeight + this.wrapperParts.l.domElement.offsetHeight + this.wrapperParts.b.domElement.offsetHeight; var oldWindowPosTop = this.wrapperParts.t.domElement.offsetTop; this.wrapperParts.l.domElement.style.height = contentHeight + 'px'; this.wrapperParts.r.domElement.style.height = contentHeight + 'px'; var newPosTop = this.wrapperParts.b.domElement.offsetTop - contentHeight; this.wrapperParts.l.domElement.style.top = newPosTop + 'px'; this.wrapperParts.r.domElement.style.top = newPosTop + 'px'; this.contentDiv_.style.top = newPosTop + 'px'; windowTHeight = parseInt(this.wrapperParts.t.domElement.style.height, 10); newPosTop -= windowTHeight; this.wrapperParts.close.domElement.style.top = newPosTop + this.borderSize_ + 'px'; this.wrapperParts.tl.domElement.style.top = newPosTop + 'px'; this.wrapperParts.t.domElement.style.top = newPosTop + 'px'; this.wrapperParts.tr.domElement.style.top = newPosTop + 'px'; this.repositionMap_() }; ExtInfoWindow.prototype.repositionMap_ = function() { var mapNE = this.map_.fromLatLngToDivPixel(this.map_.getBounds().getNorthEast()); var mapSW = this.map_.fromLatLngToDivPixel(this.map_.getBounds().getSouthWest()); var markerPosition = this.map_.fromLatLngToDivPixel(this.marker_.getPoint()); var panX = 0; var panY = 0; var paddingX = this.paddingX_; var paddingY = this.paddingY_; var infoWindowAnchor = this.marker_.getIcon().infoWindowAnchor; var iconAnchor = this.marker_.getIcon().iconAnchor; var windowT = this.wrapperParts.t.domElement; var windowL = this.wrapperParts.l.domElement; var windowB = this.wrapperParts.b.domElement; var windowR = this.wrapperParts.r.domElement; var windowBeak = this.wrapperParts.beak.domElement; var offsetTop = markerPosition.y - (-infoWindowAnchor.y + iconAnchor.y + this.getDimensions_(windowBeak).height + this.getDimensions_(windowB).height + this.getDimensions_(windowL).height + this.getDimensions_(windowT).height + this.paddingY_); if (offsetTop < mapNE.y) { panY = mapNE.y - offsetTop } else { var offsetBottom = markerPosition.y + this.paddingY_; if (offsetBottom >= mapSW.y) { panY = -(offsetBottom - mapSW.y) } } var offsetRight = Math.round(markerPosition.x + this.getDimensions_(this.container_).width / 2 + this.getDimensions_(windowR).width + this.paddingX_ + infoWindowAnchor.x - iconAnchor.x); if (offsetRight > mapNE.x) { panX = -(offsetRight - mapNE.x) } else { var offsetLeft = -(Math.round((this.getDimensions_(this.container_).width / 2 - this.marker_.getIcon().iconSize.width / 2) + this.getDimensions_(windowL).width + this.borderSize_ + this.paddingX_) - markerPosition.x - infoWindowAnchor.x + iconAnchor.x); if (offsetLeft < mapSW.x) { panX = mapSW.x - offsetLeft } } if (panX != 0 || panY != 0 && this.map_.getExtInfoWindow() != null) { if ((panY < 0 - this.maxPanning_ || panY > this.maxPanning_) && (panX < 0 - this.maxPanning_ || panX > this.maxPanning_)) { this.map_.setCenter(this.marker_.getPoint()) } else { this.map_.panBy(new GSize(panX, panY)) } } }; ExtInfoWindow.prototype.ajaxRequest_ = function(url) { var thisMap = this.map_; var thisCallback = this.callback_; GDownloadUrl(url, function(response, status) { if (thisMap.getExtInfoWindow() !== null) { var infoWindow = document.getElementById(thisMap.getExtInfoWindow().infoWindowId_ + '_contents'); if (response == null || status == -1) { infoWindow.innerHTML = '<span class="error">ERROR: The Ajax request failed to get HTML content from "' + url + '"</span>' } else { infoWindow.innerHTML = response } if (thisCallback != null) { thisCallback() } thisMap.getExtInfoWindow().resize() } GEvent.trigger(thisMap, 'extinfowindowupdate') }) }; ExtInfoWindow.prototype.setHTML = function(html) { var thisMap = this.map_; if (thisMap.getExtInfoWindow() !== null) { var infoWindow = document.getElementById(thisMap.getExtInfoWindow().infoWindowId_ + '_contents'); infoWindow.innerHTML = html; thisMap.getExtInfoWindow().resize() } GEvent.trigger(thisMap, 'extinfowindowupdate') }; ExtInfoWindow.prototype.setContentNode = function(node) { var thisMap = this.map_; if (thisMap.getExtInfoWindow() !== null) { var infoWindow = document.getElementById(thisMap.getExtInfoWindow().infoWindowId_ + '_contents'); infoWindow.innerHTML = ""; infoWindow.appendChild(node); thisMap.getExtInfoWindow().resize() } GEvent.trigger(thisMap, 'extinfowindowupdate') }; ExtInfoWindow.prototype.getDimensions_ = function(element) { var display = this.getStyle_(element, 'display'); if (display != 'none' && display != null) { return { width: element.offsetWidth, height: element.offsetHeight} } var els = element.style; var originalVisibility = els.visibility; var originalPosition = els.position; var originalDisplay = els.display; els.visibility = 'hidden'; els.position = 'absolute'; els.display = 'block'; var originalWidth = element.clientWidth; var originalHeight = element.clientHeight; els.display = originalDisplay; els.position = originalPosition; els.visibility = originalVisibility; return { width: originalWidth, height: originalHeight} }; ExtInfoWindow.prototype.getStyle_ = function(element, style) { var found = false; style = this.camelize_(style); if (element.id == this.infoWindowId_ && style == 'width' && element.style.display == 'none') { element.style.visibility = 'hidden'; element.style.display = '' } var value = element.style[style]; if (!value) { if (document.defaultView && document.defaultView.getComputedStyle) { var css = document.defaultView.getComputedStyle(element, null); value = css ? css[style] : null } else if (element.currentStyle) { value = element.currentStyle[style] } } if ((value == 'auto') && (style == 'width' || style == 'height') && (this.getStyle_(element, 'display') != 'none')) { if (style == 'width') { value = element.offsetWidth } else { value = element.offsetHeight } } if (element.id == this.infoWindowId_ && style == 'width' && element.style.display != 'none') { element.style.display = 'none'; element.style.visibility = 'visible' } return (value == 'auto') ? null : value }; ExtInfoWindow.prototype.camelize_ = function(element) { var parts = element.split('-'), len = parts.length; if (len == 1) return parts[0]; var camelized = element.charAt(0) == '-' ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1) : parts[0]; for (var i = 1; i < len; i++) { camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1) } return camelized }; GMap.prototype.ExtInfoWindowInstance_ = null; GMap.prototype.ClickListener_ = null; GMap.prototype.InfoWindowListener_ = null; GMarker.prototype.openExtInfoWindow = function(map, cssId, html, opt_opts) { if (map == null) { throw 'Error in GMarker.openExtInfoWindow: map cannot be null'; return false } if (cssId == null || cssId == '') { throw 'Error in GMarker.openExtInfoWindow: must specify a cssId'; return false } map.closeInfoWindow(); if (map.getExtInfoWindow() != null) { map.closeExtInfoWindow() } if (map.getExtInfoWindow() == null) { map.setExtInfoWindow_(new ExtInfoWindow(this, cssId, html, opt_opts)); if (map.ClickListener_ == null) { map.ClickListener_ = GEvent.addListener(map, 'click', function(event) { if (!event && map.getExtInfoWindow() != null) { map.closeExtInfoWindow() } }) } if (map.InfoWindowListener_ == null) { map.InfoWindowListener_ = GEvent.addListener(map, 'infowindowopen', function(event) { if (map.getExtInfoWindow() != null) { map.closeExtInfoWindow() } }) } map.addOverlay(map.getExtInfoWindow()) } }; GMarker.prototype.closeExtInfoWindow = function(map) { if (map.getExtInfoWindow() != null) { map.closeExtInfoWindow() } }; GMap2.prototype.getExtInfoWindow = function() { return this.ExtInfoWindowInstance_ }; GMap2.prototype.setExtInfoWindow_ = function(extInfoWindow) { this.ExtInfoWindowInstance_ = extInfoWindow }; GMap2.prototype.closeExtInfoWindow = function() { if (this.getExtInfoWindow() != null) { this.ExtInfoWindowInstance_.remove() } }; function MarkerClusterer(map, opt_markers, opt_opts) { var clusters_ = []; var map_ = map; var maxZoom_ = null; var me_ = this; var gridSize_ = 60; var sizes = [53, 56, 66, 78, 90]; var styles_ = []; var leftMarkers_ = []; var mcfn_ = null; var i = 0; for (i = 1; i <= 5; ++i) { styles_.push({ 'url': "http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/images/m" + i + ".png", 'height': sizes[i - 1], 'width': sizes[i - 1] }) } if (typeof opt_opts === "object" && opt_opts !== null) { if (typeof opt_opts.gridSize === "number" && opt_opts.gridSize > 0) { gridSize_ = opt_opts.gridSize } if (typeof opt_opts.maxZoom === "number") { maxZoom_ = opt_opts.maxZoom } if (typeof opt_opts.styles === "object" && opt_opts.styles !== null && opt_opts.styles.length !== 0) { styles_ = opt_opts.styles } } function addLeftMarkers_() { if (leftMarkers_.length === 0) { return } var leftMarkers = []; for (i = 0; i < leftMarkers_.length; ++i) { me_.addMarker(leftMarkers_[i], true, null, null, true) } leftMarkers_ = leftMarkers } this.getStyles_ = function() { return styles_ }; this.clearMarkers = function() { for (var i = 0; i < clusters_.length; ++i) { if (typeof clusters_[i] !== "undefined" && clusters_[i] !== null) { clusters_[i].clearMarkers() } } clusters_ = []; leftMarkers_ = [] }; function isMarkerInViewport_(marker) { return map_.getBounds().containsLatLng(marker.getLatLng()) } function reAddMarkers_(markers) { var len = markers.length; var clusters = []; for (var i = len - 1; i >= 0; --i) { me_.addMarker(markers[i].marker, true, markers[i].isAdded, clusters, true) } addLeftMarkers_() } this.addMarker = function(marker, opt_isNodraw, opt_isAdded, opt_clusters, opt_isNoCheck) { if (opt_isNoCheck !== true) { if (!isMarkerInViewport_(marker)) { leftMarkers_.push(marker); return } } var isAdded = opt_isAdded; var clusters = opt_clusters; var pos = map_.fromLatLngToDivPixel(marker.getLatLng()); if (typeof isAdded !== "boolean") { isAdded = false } if (typeof clusters !== "object" || clusters === null) { clusters = clusters_ } var length = clusters.length; var cluster = null; for (var i = length - 1; i >= 0; i--) { cluster = clusters[i]; var center = cluster.getCenter(); if (center === null) { continue } center = map_.fromLatLngToDivPixel(center); if (pos.x >= center.x - gridSize_ && pos.x <= center.x + gridSize_ && pos.y >= center.y - gridSize_ && pos.y <= center.y + gridSize_) { cluster.addMarker({ 'isAdded': isAdded, 'marker': marker }); if (!opt_isNodraw) { cluster.redraw_() } return } } cluster = new Cluster(this, map); cluster.addMarker({ 'isAdded': isAdded, 'marker': marker }); if (!opt_isNodraw) { cluster.redraw_() } clusters.push(cluster); if (clusters !== clusters_) { clusters_.push(cluster) } }; this.removeMarker = function(marker) { for (var i = 0; i < clusters_.length; ++i) { if (clusters_[i].remove(marker)) { clusters_[i].redraw_(); return } } }; this.redraw_ = function() { var clusters = this.getClustersInViewport_(); for (var i = 0; i < clusters.length; ++i) { clusters[i].redraw_(true) } }; this.getClustersInViewport_ = function() { var clusters = []; var curBounds = map_.getBounds(); for (var i = 0; i < clusters_.length; i++) { if (clusters_[i].isInBounds(curBounds)) { clusters.push(clusters_[i]) } } return clusters }; this.getMaxZoom_ = function() { return maxZoom_ }; this.getMap_ = function() { return map_ }; this.getGridSize_ = function() { return gridSize_ }; this.getTotalMarkers = function() { var result = 0; for (var i = 0; i < clusters_.length; ++i) { result += clusters_[i].getTotalMarkers() } return result }; this.getTotalClusters = function() { var result = 0; for (var i = 0; i < clusters_.length; ++i) { if (clusters_[i].getTotalMarkers() > 1) result += 1 } return result }; this.getMarkerByRef = function(ref) { for (var i = 0; i < leftMarkers_.length; ++i) { if (leftMarkers_[i].ref == ref) return leftMarkers_[i] } for (var i = 0; i < clusters_.length; ++i) { var mkrs = clusters_[i].getMarkers(); for (var j = 0; j < mkrs.length; ++j) { if (mkrs[j].marker.ref.toString() == ref) return mkrs[j].marker } } }; this.resetViewport = function() { var clusters = this.getClustersInViewport_(); var tmpMarkers = []; var removed = 0; for (var i = 0; i < clusters.length; ++i) { var cluster = clusters[i]; var oldZoom = cluster.getCurrentZoom(); if (oldZoom === null) { continue } var curZoom = map_.getZoom(); if (curZoom !== oldZoom) { var mks = cluster.getMarkers(); for (var j = 0; j < mks.length; ++j) { var newMarker = { 'isAdded': false, 'marker': mks[j].marker }; tmpMarkers.push(newMarker) } cluster.clearMarkers(); removed++; for (j = 0; j < clusters_.length; ++j) { if (cluster === clusters_[j]) { clusters_.splice(j, 1) } } } } reAddMarkers_(tmpMarkers); this.redraw_() }; this.addMarkers = function(markers) { for (var i = 0; i < markers.length; ++i) { this.addMarker(markers[i], true) } this.redraw_() }; if (typeof opt_markers === "object" && opt_markers !== null) { this.addMarkers(opt_markers) } mcfn_ = GEvent.addListener(map_, "moveend", function() { me_.resetViewport() }) } function Cluster(markerClusterer) { var center_ = null; var markers_ = []; var markerClusterer_ = markerClusterer; var map_ = markerClusterer.getMap_(); var clusterMarker_ = null; var zoom_ = map_.getZoom(); this.getMarkers = function() { return markers_ }; this.isInBounds = function(bounds) { if (center_ === null) { return false } if (!bounds) { bounds = map_.getBounds() } var sw = map_.fromLatLngToDivPixel(bounds.getSouthWest()); var ne = map_.fromLatLngToDivPixel(bounds.getNorthEast()); var centerxy = map_.fromLatLngToDivPixel(center_); var inViewport = true; var gridSize = markerClusterer.getGridSize_(); if (zoom_ !== map_.getZoom()) { var dl = map_.getZoom() - zoom_; gridSize = Math.pow(2, dl) * gridSize } if (ne.x !== sw.x && (centerxy.x + gridSize < sw.x || centerxy.x - gridSize > ne.x)) { inViewport = false } if (inViewport && (centerxy.y + gridSize < ne.y || centerxy.y - gridSize > sw.y)) { inViewport = false } return inViewport }; this.getCenter = function() { return center_ }; this.addMarker = function(marker) { if (center_ === null) { center_ = marker.marker.getLatLng() } markers_.push(marker) }; this.removeMarker = function(marker) { for (var i = 0; i < markers_.length; ++i) { if (marker === markers_[i].marker) { if (markers_[i].isAdded) { map_.removeOverlay(markers_[i].marker) } markers_.splice(i, 1); return true } } return false }; this.getCurrentZoom = function() { return zoom_ }; this.redraw_ = function(isForce) { if (!isForce && !this.isInBounds()) { return } zoom_ = map_.getZoom(); var i = 0; var mz = markerClusterer.getMaxZoom_(); if (mz === null) { mz = map_.getCurrentMapType().getMaximumResolution() } if (zoom_ >= mz || this.getTotalMarkers() === 1) { for (i = 0; i < markers_.length; ++i) { if (markers_[i].isAdded) { if (markers_[i].marker.isHidden()) { markers_[i].marker.show() } } else { map_.addOverlay(markers_[i].marker); markers_[i].isAdded = true } } if (clusterMarker_ !== null) { clusterMarker_.hide() } } else { for (i = 0; i < markers_.length; ++i) { if (markers_[i].isAdded && (!markers_[i].marker.isHidden())) { markers_[i].marker.hide() } } if (clusterMarker_ === null) { clusterMarker_ = new ClusterMarker_(center_, this.getTotalMarkers(), markerClusterer_.getStyles_(), markerClusterer_.getGridSize_()); map_.addOverlay(clusterMarker_) } else { if (clusterMarker_.isHidden()) { clusterMarker_.show() } clusterMarker_.redraw(true) } } }; this.clearMarkers = function() { if (clusterMarker_ !== null) { map_.removeOverlay(clusterMarker_) } for (var i = 0; i < markers_.length; ++i) { if (markers_[i].isAdded) { map_.removeOverlay(markers_[i].marker) } } markers_ = [] }; this.getTotalMarkers = function() { return markers_.length } } function ClusterMarker_(latlng, count, styles, padding) { var index = 0; var dv = count; while (dv !== 0) { dv = parseInt(dv / 10, 10); index++ } if (styles.length < index) { index = styles.length } this.url_ = styles[index - 1].url; this.height_ = styles[index - 1].height; this.width_ = styles[index - 1].width; this.textColor_ = styles[index - 1].opt_textColor; this.anchor_ = styles[index - 1].opt_anchor; this.latlng_ = latlng; this.index_ = index; this.styles_ = styles; this.text_ = count; this.padding_ = padding } ClusterMarker_.prototype = new GOverlay(); ClusterMarker_.prototype.initialize = function(map) { this.map_ = map; var div = document.createElement("div"); var latlng = this.latlng_; var pos = map.fromLatLngToDivPixel(latlng); pos.x -= parseInt(this.width_ / 2, 10); pos.y -= parseInt(this.height_ / 2, 10); var mstyle = ""; if (document.all) { mstyle = 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="' + this.url_ + '");' } else { mstyle = "background:url(" + this.url_ + ");" } if (typeof this.anchor_ === "object") { if (typeof this.anchor_[0] === "number" && this.anchor_[0] > 0 && this.anchor_[0] < this.height_) { mstyle += 'height:' + (this.height_ - this.anchor_[0]) + 'px;padding-top:' + this.anchor_[0] + 'px;' } else { mstyle += 'height:' + this.height_ + 'px;line-height:' + this.height_ + 'px;' } if (typeof this.anchor_[1] === "number" && this.anchor_[1] > 0 && this.anchor_[1] < this.width_) { mstyle += 'width:' + (this.width_ - this.anchor_[1]) + 'px;padding-left:' + this.anchor_[1] + 'px;' } else { mstyle += 'width:' + this.width_ + 'px;text-align:center;' } } else { mstyle += 'height:' + this.height_ + 'px;line-height:' + this.height_ + 'px;'; mstyle += 'width:' + this.width_ + 'px;text-align:center;' } var txtColor = this.textColor_ ? this.textColor_ : 'black'; div.style.cssText = mstyle + 'cursor:pointer;top:' + pos.y + "px;left:" + pos.x + "px;color:" + txtColor + ";position:absolute;font-size:11px;" + 'font-family:Arial,sans-serif;font-weight:bold'; div.innerHTML = ''; /*this.text_;*/ div.title = "click to zoom in"; map.getPane(G_MAP_MAP_PANE).appendChild(div); var padding = this.padding_; GEvent.addDomListener(div, "click", function() { var pos = map.fromLatLngToDivPixel(latlng); var sw = new GPoint(pos.x - padding, pos.y + padding); sw = map.fromDivPixelToLatLng(sw); var ne = new GPoint(pos.x + padding, pos.y - padding); ne = map.fromDivPixelToLatLng(ne); var zoom = map.getBoundsZoomLevel(new GLatLngBounds(sw, ne), map.getSize()); map.setCenter(latlng, zoom) }); this.div_ = div }; ClusterMarker_.prototype.remove = function() { this.div_.parentNode.removeChild(this.div_) }; ClusterMarker_.prototype.copy = function() { return new ClusterMarker_(this.latlng_, this.index_, this.text_, this.styles_, this.padding_) }; ClusterMarker_.prototype.redraw = function(force) { if (!force) { return } var pos = this.map_.fromLatLngToDivPixel(this.latlng_); pos.x -= parseInt(this.width_ / 2, 10); pos.y -= parseInt(this.height_ / 2, 10); this.div_.style.top = pos.y + "px"; this.div_.style.left = pos.x + "px" }; ClusterMarker_.prototype.hide = function() { this.div_.style.display = "none" }; ClusterMarker_.prototype.show = function() { this.div_.style.display = "" }; ClusterMarker_.prototype.isHidden = function() { return this.div_.style.display === "none" }; Type.registerNamespace("Earthware.Ajax"); Earthware.Ajax.PageUtils = function() { this._qsvalues; this._hvalues }; Earthware.Ajax.PageUtils.onFailed = function(error) { var stackTrace = error.get_stackTrace(); var message = error.get_message(); var statusCode = error.get_statusCode(); var exceptionType = error.get_exceptionType(); var timedout = error.get_timedOut(); var RsltElem = "Stack Trace: " + stackTrace + "<br/>" + "Service Error: " + message + "<br/>" + "Status Code: " + statusCode + "<br/>" + "Exception Type: " + exceptionType + "<br/>" + "Timedout: " + timedout; alert(RsltElem) }; Earthware.Ajax.PageUtils.getQueryStringValue = function(keyname) { if (this._qsvalues == null) { this._qsvalues = new Array(); var query = window.location.search.substring(1); var parms = query.split('&'); for (var i = 0; i < parms.length; i++) { var pos = parms[i].indexOf('='); if (pos > 0) { var key = parms[i].substring(0, pos); var val = parms[i].substring(pos + 1); this._qsvalues[key] = val } } } return this._qsvalues[keyname] }; Earthware.Ajax.PageUtils.getHashValue = function(keyname) { this._hvalues = new Array(); var query = window.location.hash.substring(1); var parms = query.split('&'); for (var i = 0; i < parms.length; i++) { var pos = parms[i].indexOf('='); if (pos > 0) { var key = parms[i].substring(0, pos); var val = parms[i].substring(pos + 1); this._hvalues[key] = val } } return this._hvalues[keyname] }; Earthware.Ajax.PageUtils.findAspControl = function(element) { if (arguments.length > 1) { for (var i = 0, elements = [], length = arguments.length; i < length; i++) elements.push($n(arguments[i])); return elements } if (typeof element == 'string') { var el = document.getElementById(element); if (el) return el } else return element; var regExp = new RegExp('_' + element + '$'); var formsLength = document.forms.length; for (var ii = 0; ii < formsLength; ii++) { var form = document.forms[ii]; var elementsLength = form.elements.length; for (var j = 0; j < elementsLength; j++) { element = form.elements[j]; if (element.id && element.id.match(regExp)) return element } } var imagesLength = document.images.length; for (var ii = 0; ii < imagesLength; ii++) { element = document.images[ii]; if (element.id && element.id.match(regExp)) return element } return null }; Earthware.Ajax.PageUtils.centreElementOnPage = function(element) { element.style.left = (this.getScreenWidth() - element.offsetWidth) / 2 + "px"; element.style.top = (this.getScreenHeight() - element.offsetHeight) / 2 + "px" }; Earthware.Ajax.PageUtils.getScreenWidth = function() { var result; if (typeof (window.innerWidth) == 'number') { return window.innerWidth } else if (document.documentElement && document.documentElement.clientWidth) { return document.documentElement.clientWidth } }; Earthware.Ajax.PageUtils.getScreenHeight = function() { var result; if (typeof (window.innerWidth) == 'number') { return window.innerHeight } else if (document.documentElement && document.documentElement.clientHeight) { return document.documentElement.clientHeight } }; Earthware.Ajax.PageUtils.setDropdownByValue = function(control, value) { for (var i = 0; i < control.options.length; i++) { if (control.options[i].value == value) { control.options[i].selected = true; return } } }; Earthware.Ajax.PageUtils.registerClass('Earthware.Ajax.PageUtils'); if (typeof (Sys) !== "undefined") Sys.Application.notifyScriptLoaded();
