﻿/* ExtInfoWindow, v1.1: See code.google.com/p/gmaps-utility-library for license and info */
function ExtInfoWindow(a, b, c, d) { this.html_ = c; this.marker_ = a; this.infoWindowId_ = b; this.options_ = d == null ? {} : d; this.ajaxUrl_ = this.options_.ajaxUrl == null ? null : this.options_.ajaxUrl; this.callback_ = this.options_.ajaxCallback == null ? null : this.options_.ajaxCallback; 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.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(a) { this.map_ = a; 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} }; for (var i in this.wrapperParts) { var b = document.createElement('div'); b.id = this.infoWindowId_ + '_' + i; b.style.visibility = 'hidden'; document.body.appendChild(b); b = document.getElementById(this.infoWindowId_ + '_' + i); var c = eval('this.wrapperParts.' + i); c.w = parseInt(this.getStyle_(b, 'width')); c.h = parseInt(this.getStyle_(b, 'height')); document.body.removeChild(b) } for (var i in this.wrapperParts) { if (i == 'close') { this.wrapperDiv_.appendChild(this.contentDiv_) } var d = null; if (this.wrapperParts[i].domElement == null) { d = document.createElement('div'); this.wrapperDiv_.appendChild(d) } else { d = this.wrapperParts[i].domElement } d.id = this.infoWindowId_ + '_' + i; d.style.position = 'absolute'; d.style.width = this.wrapperParts[i].w + 'px'; d.style.height = this.wrapperParts[i].h + 'px'; d.style.top = this.wrapperParts[i].t + 'px'; d.style.left = this.wrapperParts[i].l + 'px'; this.wrapperParts[i].domElement = d } this.map_.getPane(G_MAP_FLOAT_PANE).appendChild(this.container_); this.container_.id = this.infoWindowId_; var e = this.getStyle_(document.getElementById(this.infoWindowId_), 'width'); this.container_.style.width = (e == null ? this.defaultStyles.containerWidth : e); 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_); GEvent.bindDom(this.container_, 'mousedown', this, this.onClick_); GEvent.bindDom(this.container_, 'dblclick', this, this.onClick_); GEvent.bindDom(this.container_, 'DOMMouseScroll', 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(a) { if (!a || this.container_ == null) return; var b = this.contentDiv_.offsetHeight; this.contentDiv_.style.height = b + 'px'; 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 = b; this.wrapperParts.r.l = this.contentWidth + this.wrapperParts.l.w; this.wrapperParts.r.t = this.wrapperParts.tr.h; this.wrapperParts.r.h = b; this.wrapperParts.bl.t = b + this.wrapperParts.tl.h; this.wrapperParts.b.l = this.wrapperParts.bl.w; this.wrapperParts.b.t = b + 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 = b + this.wrapperParts.tr.h; this.wrapperParts.close.l = this.wrapperParts.tr.l + this.wrapperParts.tr.w - this.wrapperParts.close.w - this.borderSize_; this.wrapperParts.close.t = this.borderSize_; 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_; for (var i in this.wrapperParts) { if (i == 'close') { this.wrapperDiv_.insertBefore(this.contentDiv_, this.wrapperParts[i].domElement) } var c = null; if (this.wrapperParts[i].domElement == null) { c = document.createElement('div'); this.wrapperDiv_.appendChild(c) } else { c = this.wrapperParts[i].domElement } c.id = this.infoWindowId_ + '_' + i; c.style.position = 'absolute'; c.style.width = this.wrapperParts[i].w + 'px'; c.style.height = this.wrapperParts[i].h + 'px'; c.style.top = this.wrapperParts[i].t + 'px'; c.style.left = this.wrapperParts[i].l + 'px'; this.wrapperParts[i].domElement = c } var d = this.marker_; var e = this.map_; GEvent.addDomListener(this.wrapperParts.close.domElement, 'click', function() { e.closeExtInfoWindow() }); var f = this.map_.fromLatLngToDivPixel(this.marker_.getPoint()); this.container_.style.position = 'absolute'; var g = this.marker_.getIcon(); this.container_.style.left = (f.x - (this.contentWidth / 2) - g.iconAnchor.x + g.infoWindowAnchor.x) + 'px'; this.container_.style.top = (f.y - this.wrapperParts.bl.h - b - this.wrapperParts.tl.h - this.wrapperParts.beak.h - g.iconAnchor.y + g.infoWindowAnchor.y + this.borderSize_) + 'px'; this.container_.style.display = 'block'; if (this.map_.getExtInfoWindow() != null) { this.repositionMap_() } };
ExtInfoWindow.prototype.resize = function() { var a = this.contentDiv_.cloneNode(true); a.id = this.infoWindowId_ + '_tempContents'; a.style.visibility = 'hidden'; a.style.height = 'auto'; document.body.appendChild(a); a = document.getElementById(this.infoWindowId_ + '_tempContents'); var b = a.offsetHeight; document.body.removeChild(a); this.contentDiv_.style.height = b + 'px'; var c = this.contentDiv_.offsetWidth; var d = this.map_.fromLatLngToDivPixel(this.marker_.getPoint()); var e = this.wrapperParts.t.domElement.offsetHeight + this.wrapperParts.l.domElement.offsetHeight + this.wrapperParts.b.domElement.offsetHeight; var f = this.wrapperParts.t.domElement.offsetTop; this.wrapperParts.l.domElement.style.height = b + 'px'; this.wrapperParts.r.domElement.style.height = b + 'px'; var g = this.wrapperParts.b.domElement.offsetTop - b; this.wrapperParts.l.domElement.style.top = g + 'px'; this.wrapperParts.r.domElement.style.top = g + 'px'; this.contentDiv_.style.top = g + 'px'; windowTHeight = parseInt(this.wrapperParts.t.domElement.style.height); g -= windowTHeight; this.wrapperParts.close.domElement.style.top = g + this.borderSize_ + 'px'; this.wrapperParts.tl.domElement.style.top = g + 'px'; this.wrapperParts.t.domElement.style.top = g + 'px'; this.wrapperParts.tr.domElement.style.top = g + 'px'; this.repositionMap_() };
ExtInfoWindow.prototype.repositionMap_ = function() { var a = this.map_.fromLatLngToDivPixel(this.map_.getBounds().getNorthEast()); var b = this.map_.fromLatLngToDivPixel(this.map_.getBounds().getSouthWest()); var c = this.map_.fromLatLngToDivPixel(this.marker_.getPoint()); var d = 0; var e = 0; var f = this.paddingX_; var g = this.paddingY_; var h = this.marker_.getIcon().infoWindowAnchor; var i = this.marker_.getIcon().iconAnchor; var j = this.wrapperParts.t.domElement; var k = this.wrapperParts.l.domElement; var l = this.wrapperParts.b.domElement; var m = this.wrapperParts.r.domElement; var n = this.wrapperParts.beak.domElement; var o = c.y - (-h.y + i.y + this.getDimensions_(n).height + this.getDimensions_(l).height + this.getDimensions_(k).height + this.getDimensions_(j).height + this.paddingY_); if (o < a.y) { e = a.y - o } else { var p = c.y + this.paddingY_; if (p >= b.y) { e = -(p - b.y) } } var q = Math.round(c.x + this.getDimensions_(this.container_).width / 2 + this.getDimensions_(m).width + this.paddingX_ + h.x - i.x); if (q > a.x) { d = -(q - a.x) } else { var r = -(Math.round((this.getDimensions_(this.container_).width / 2 - this.marker_.getIcon().iconSize.width / 2) + this.getDimensions_(k).width + this.borderSize_ + this.paddingX_) - c.x - h.x + i.x); if (r < b.x) { d = b.x - r } } if (d != 0 || e != 0 && this.map_.getExtInfoWindow() != null) { this.map_.panBy(new GSize(d, e)) } };
ExtInfoWindow.prototype.ajaxRequest_ = function(d) { var e = this.map_; var f = this.callback_; GDownloadUrl(d, function(a, b) { var c = document.getElementById(e.getExtInfoWindow().infoWindowId_ + '_contents'); if (a == null || b == -1) { c.innerHTML = '<span class="error">ERROR: The Ajax request failed to get HTML content from "' + d + '"</span>' } else { c.innerHTML = a } if (f != null) { f() } e.getExtInfoWindow().resize(); GEvent.trigger(e, 'extinfowindowupdate') }) };
ExtInfoWindow.prototype.getDimensions_ = function(a) { var b = this.getStyle_(a, 'display'); if (b != 'none' && b != null) { return { width: a.offsetWidth, height: a.offsetHeight} } var c = a.style; var d = c.visibility; var e = c.position; var f = c.display; c.visibility = 'hidden'; c.position = 'absolute'; c.display = 'block'; var g = a.clientWidth; var h = a.clientHeight; c.display = f; c.position = e; c.visibility = d; return { width: g, height: h} };
ExtInfoWindow.prototype.getStyle_ = function(a, b) { var c = false; b = this.camelize_(b); var d = a.style[b]; if (!d) { if (document.defaultView && document.defaultView.getComputedStyle) { var e = document.defaultView.getComputedStyle(a, null); d = e ? e[b] : null } else if (a.currentStyle) { d = a.currentStyle[b] } } if ((d == 'auto') && (b == 'width' || b == 'height') && (this.getStyle_(a, 'display') != 'none')) { if (b == 'width') { d = a.offsetWidth } else { d = a.offsetHeight } } return (d == 'auto') ? null : d };
ExtInfoWindow.prototype.camelize_ = function(a) { var b = a.split('-'), len = b.length; if (len == 1) return b[0]; var c = a.charAt(0) == '-' ? b[0].charAt(0).toUpperCase() + b[0].substring(1) : b[0]; for (var i = 1; i < len; i++) { c += b[i].charAt(0).toUpperCase() + b[i].substring(1) } return c }; GMap.prototype.ExtInfoWindowInstance_ = null; GMap.prototype.ClickListener_ = null; GMap.prototype.InfoWindowListener_ = null; GMarker.prototype.openExtInfoWindow = function(b, c, d, e) { if (b == null) { throw 'Error in GMarker.openExtInfoWindow: map cannot be null'; return false } if (c == null || c == '') { throw 'Error in GMarker.openExtInfoWindow: must specify a cssId'; return false } b.closeInfoWindow(); if (b.getExtInfoWindow() != null) { b.closeExtInfoWindow() } if (b.getExtInfoWindow() == null) { b.setExtInfoWindow_(new ExtInfoWindow(this, c, d, e)); if (b.ClickListener_ == null) { b.ClickListener_ = GEvent.addListener(b, 'click', function(a) { if (!a && b.getExtInfoWindow() != null) { b.closeExtInfoWindow() } }) } if (b.InfoWindowListener_ == null) { b.InfoWindowListener_ = GEvent.addListener(b, 'infowindowopen', function(a) { if (b.getExtInfoWindow() != null) { b.closeExtInfoWindow() } }) } b.addOverlay(b.getExtInfoWindow()) } }; GMarker.prototype.closeExtInfoWindow = function(a) { if (a.getExtInfWindow() != null) { a.closeExtInfoWindow() } };
GMap2.prototype.getExtInfoWindow = function() { return this.ExtInfoWindowInstance_ };
GMap2.prototype.setExtInfoWindow_ = function(a) { this.ExtInfoWindowInstance_ = a }
GMap2.prototype.closeExtInfoWindow = function() { if (this.getExtInfoWindow() != null) { this.ExtInfoWindowInstance_.remove() } };
//-- labeledmarker_packed.js
function LabeledMarker(latlng, opt_opts) { this.latlng_ = latlng; this.opts_ = opt_opts; this.labelText_ = opt_opts.labelText || ""; this.labelClass_ = opt_opts.labelClass || "LabeledMarker_markerLabel"; this.labelOffset_ = opt_opts.labelOffset || new GSize(0, 0); this.clickable_ = opt_opts.clickable || true; this.title_ = opt_opts.title || ""; this.labelVisibility_ = true; if (opt_opts.draggable) { opt_opts.draggable = false } GMarker.apply(this, arguments) }; LabeledMarker.prototype = new GMarker(new GLatLng(0, 0)); LabeledMarker.prototype.initialize = function(map) { GMarker.prototype.initialize.apply(this, arguments); this.map_ = map; this.div_ = document.createElement("div"); this.div_.className = this.labelClass_; this.div_.innerHTML = this.labelText_; this.div_.style.position = "absolute"; this.div_.style.cursor = "pointer"; this.div_.title = this.title_; map.getPane(G_MAP_MARKER_PANE).appendChild(this.div_); if (this.clickable_) { function newEventPassthru(obj, event) { return function() { GEvent.trigger(obj, event) } } var eventPassthrus = ['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover', 'mouseout']; for (var i = 0; i < eventPassthrus.length; i++) { var name = eventPassthrus[i]; GEvent.addDomListener(this.div_, name, newEventPassthru(this, name)) } } }; LabeledMarker.prototype.redraw = function(force) { GMarker.prototype.redraw.apply(this, arguments); this.redrawLabel_() }; LabeledMarker.prototype.redrawLabel_ = function() { var p = this.map_.fromLatLngToDivPixel(this.latlng_); var z = GOverlay.getZIndex(this.latlng_.lat()); this.div_.style.left = (p.x + this.labelOffset_.width) + "px"; this.div_.style.top = (p.y + this.labelOffset_.height) + "px"; this.div_.style.zIndex = z }; LabeledMarker.prototype.remove = function() { GEvent.clearInstanceListeners(this.div_); if (this.div_.outerHTML) { this.div_.outerHTML = "" } if (this.div_.parentNode) { this.div_.parentNode.removeChild(this.div_) } this.div_ = null; GMarker.prototype.remove.apply(this, arguments) }; LabeledMarker.prototype.copy = function() { return new LabeledMarker(this.latlng_, this.opts_) }; LabeledMarker.prototype.show = function() { GMarker.prototype.show.apply(this, arguments); if (this.labelVisibility_) { this.showLabel() } else { this.hideLabel() } }; LabeledMarker.prototype.hide = function() { GMarker.prototype.hide.apply(this, arguments); this.hideLabel() }; LabeledMarker.prototype.setLatLng = function(latlng) { this.latlng_ = latlng; GMarker.prototype.setLatLng.apply(this, arguments); this.redrawLabel_() }; LabeledMarker.prototype.setLabelVisibility = function(visibility) { this.labelVisibility_ = visibility; if (!this.isHidden()) { if (this.labelVisibility_) { this.showLabel() } else { this.hideLabel() } } }; LabeledMarker.prototype.getLabelVisibility = function() { return this.labelVisibility_ }; LabeledMarker.prototype.hideLabel = function() { this.div_.style.visibility = 'hidden' }; LabeledMarker.prototype.showLabel = function() { this.div_.style.visibility = 'visible' };
//-- DragZoom.js
function DragZoomControl(opts_boxStyle, opts_other, opts_callbacks) { this.globals = { draggingOn: false, cornerTopDiv: null, cornerRightDiv: null, cornerBottomDiv: null, cornerLeftDiv: null, mapPosition: null, outlineDiv: null, mapWidth: 0, mapHeight: 0, mapRatio: 0, startX: 0, startY: 0, borderCorrection: 0 }; this.globals.style = { opacity: .2, fillColor: "#000", border: "2px solid blue" }; var style = this.globals.style; for (var s in opts_boxStyle) { style[s] = opts_boxStyle[s] } var borderStyleArray = style.border.split(' '); style.outlineWidth = parseInt(borderStyleArray[0].replace(/\D/g, '')); style.outlineColor = borderStyleArray[2]; style.alphaIE = 'alpha(opacity=' + (style.opacity * 100) + ')'; this.globals.backStack = []; this.globals.options = { buttonHTML: 'zoom ...', buttonStartingStyle: { width: '52px', border: '1px solid black', padding: '2px' }, buttonStyle: { background: '#FFF' }, backButtonHTML: 'zoom back', backButtonStyle: { background: '#FFF', display: 'none' }, buttonZoomingHTML: 'Drag a region on the map', buttonZoomingStyle: { background: '#FF0' }, overlayRemoveTime: 6000, backButtonEnabled: false, stickyZoomEnabled: false, rightMouseZoomOutEnabled: false, minDragSize: 0 }; for (var s in opts_other) { this.globals.options[s] = opts_other[s] } if (opts_callbacks == null) { opts_callbacks = {} } this.globals.callbacks = opts_callbacks }; DragZoomControl.prototype = new GControl(); DragZoomControl.prototype.saveMapContext = function(text) { if (this.globals.options.backButtonEnabled) { this.saveBackContext_(text, true); this.globals.backButtonDiv.style.display = 'block' } }; DragZoomControl.prototype.initiateZoom = function() { this.buttonclick_() }; DragZoomControl.prototype.initiateZoomBack = function() { if (this.globals.options.backButtonEnabled) this.backbuttonclick_() }; DragZoomControl.prototype.initButton_ = function(buttonContainerDiv) { var G = this.globals; var buttonDiv = document.createElement('div'); buttonDiv.innerHTML = G.options.buttonHTML; DragZoomUtil.style([buttonDiv], { cursor: 'pointer', zIndex: 200 }); DragZoomUtil.style([buttonDiv], G.options.buttonStartingStyle); DragZoomUtil.style([buttonDiv], G.options.buttonStyle); buttonContainerDiv.appendChild(buttonDiv); return buttonDiv }; DragZoomControl.prototype.initBackButton_ = function(buttonContainerDiv) { var G = this.globals; var backButtonDiv = document.createElement('div'); backButtonDiv.innerHTML = G.options.backButtonHTML; DragZoomUtil.style([backButtonDiv], { cursor: 'pointer', zIndex: 200 }); DragZoomUtil.style([backButtonDiv], G.options.buttonStartingStyle); DragZoomUtil.style([backButtonDiv], G.options.backButtonStyle); buttonContainerDiv.appendChild(backButtonDiv); return backButtonDiv }; DragZoomControl.prototype.setButtonMode_ = function(mode) { var G = this.globals; if (mode == 'zooming') { G.buttonDiv.innerHTML = G.options.buttonZoomingHTML; DragZoomUtil.style([G.buttonDiv], G.options.buttonStartingStyle); DragZoomUtil.style([G.buttonDiv], G.options.buttonZoomingStyle) } else { G.buttonDiv.innerHTML = G.options.buttonHTML; DragZoomUtil.style([G.buttonDiv], G.options.buttonStartingStyle); DragZoomUtil.style([G.buttonDiv], G.options.buttonStyle) } }; DragZoomControl.prototype.initialize = function(map) { var G = this.globals; var me = this; var mapDiv = map.getContainer(); var buttonContainerDiv = document.createElement("div"); DragZoomUtil.style([buttonContainerDiv], { cursor: 'pointer', zIndex: 150 }); var buttonDiv = this.initButton_(buttonContainerDiv); var backButtonDiv = this.initBackButton_(buttonContainerDiv); mapDiv.appendChild(buttonContainerDiv); var zoomDiv = document.createElement("div"); var DIVS_TO_CREATE = ['outlineDiv', 'cornerTopDiv', 'cornerLeftDiv', 'cornerRightDiv', 'cornerBottomDiv']; for (var i = 0; i < DIVS_TO_CREATE.length; i++) { var id = DIVS_TO_CREATE[i]; var div = document.createElement("div"); DragZoomUtil.style([div], { position: 'absolute', display: 'none' }); zoomDiv.appendChild(div); G[id] = div } DragZoomUtil.style([zoomDiv], { position: 'absolute', display: 'none', overflow: 'hidden', cursor: 'crosshair', zIndex: 101 }); mapDiv.appendChild(zoomDiv); GEvent.addDomListener(buttonDiv, 'click', function(e) { me.buttonclick_(e) }); GEvent.addDomListener(backButtonDiv, 'click', function(e) { me.backbuttonclick_(e) }); GEvent.addDomListener(zoomDiv, 'mousedown', function(e) { me.coverMousedown_(e) }); GEvent.addDomListener(document, 'mousemove', function(e) { me.drag_(e) }); GEvent.addDomListener(document, 'mouseup', function(e) { me.mouseup_(e) }); G.mapPosition = DragZoomUtil.getElementPosition(mapDiv); G.buttonDiv = buttonDiv; G.backButtonDiv = backButtonDiv; G.mapCover = zoomDiv; G.map = map; G.borderCorrection = G.style.outlineWidth * 2; this.setDimensions_(); this.initStyles_(); G.mapCover.onselectstart = function() { return false }; return buttonContainerDiv }; DragZoomControl.prototype.getDefaultPosition = function() { return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(3, 120)) }; DragZoomControl.prototype.coverMousedown_ = function(e) { var G = this.globals; var pos = this.getRelPos_(e); G.startX = pos.left; G.startY = pos.top; if (e.which) { var rightMouse = (e.which != 1) } else if (e.button) { var rightMouse = (e.button != 1) } G.draggingRightMouse = rightMouse; DragZoomUtil.style([G.mapCover], { background: 'transparent', opacity: 1, filter: 'alpha(opacity=100)' }); DragZoomUtil.style([G.outlineDiv], { left: G.startX + 'px', top: G.startY + 'px', display: 'block', width: '1px', height: '1px' }); G.draggingOn = true; G.cornerTopDiv.style.top = (G.startY - G.mapHeight) + 'px'; G.cornerTopDiv.style.display = 'block'; G.cornerLeftDiv.style.left = (G.startX - G.mapWidth) + 'px'; G.cornerLeftDiv.style.top = G.startY + 'px'; G.cornerLeftDiv.style.display = 'block'; G.cornerRightDiv.style.left = G.startX + 'px'; G.cornerRightDiv.style.top = G.startY + 'px'; G.cornerRightDiv.style.display = 'block'; G.cornerBottomDiv.style.left = G.startX + 'px'; G.cornerBottomDiv.style.top = G.startY + 'px'; G.cornerBottomDiv.style.width = '0px'; G.cornerBottomDiv.style.display = 'block'; if (G.callbacks.dragstart != null) { G.callbacks.dragstart(G.startX, G.startY) } return false }; DragZoomControl.prototype.drag_ = function(e) { var G = this.globals; if (G.draggingOn) { var pos = this.getRelPos_(e); var rect = this.getRectangle_(G.startX, G.startY, pos, G.mapRatio); if (rect.left) { addX = -rect.width } else { addX = 0 } if (rect.top) { addY = -rect.height } else { addY = 0 } DragZoomUtil.style([G.outlineDiv], { left: G.startX + addX + 'px', top: G.startY + addY + 'px', display: 'block', width: '1px', height: '1px' }); G.outlineDiv.style.width = rect.width + "px"; G.outlineDiv.style.height = rect.height + "px"; G.cornerTopDiv.style.height = ((G.startY + addY) - (G.startY - G.mapHeight)) + 'px'; G.cornerLeftDiv.style.top = (G.startY + addY) + 'px'; G.cornerLeftDiv.style.width = ((G.startX + addX) - (G.startX - G.mapWidth)) + 'px'; G.cornerRightDiv.style.top = G.cornerLeftDiv.style.top; G.cornerRightDiv.style.left = (G.startX + addX + rect.width + G.borderCorrection) + 'px'; G.cornerBottomDiv.style.top = (G.startY + addY + rect.height + G.borderCorrection) + 'px'; G.cornerBottomDiv.style.left = (G.startX - G.mapWidth + ((G.startX + addX) - (G.startX - G.mapWidth))) + 'px'; G.cornerBottomDiv.style.width = (rect.width + G.borderCorrection) + 'px'; if (G.callbacks.dragging != null) { G.callbacks.dragging(G.startX, G.startY, rect.endX, rect.endY) } return false } }; DragZoomControl.prototype.mouseup_ = function(e) { var G = this.globals; if (G.draggingOn) { var pos = this.getRelPos_(e); G.draggingOn = false; var rect = this.getRectangle_(G.startX, G.startY, pos, G.mapRatio); if (rect.left) rect.endX = rect.startX - rect.width; if (rect.top) rect.endY = rect.startY - rect.height; this.resetDragZoom_(); if (rect.width >= G.options.minDragSize && rect.height >= G.options.minDragSize) { var nwpx = new GPoint(rect.startX, rect.startY); var nepx = new GPoint(rect.endX, rect.startY); var sepx = new GPoint(rect.endX, rect.endY); var swpx = new GPoint(rect.startX, rect.endY); var nw = G.map.fromContainerPixelToLatLng(nwpx); var ne = G.map.fromContainerPixelToLatLng(nepx); var se = G.map.fromContainerPixelToLatLng(sepx); var sw = G.map.fromContainerPixelToLatLng(swpx); var zoomAreaPoly = new GPolyline([nw, ne, se, sw, nw], G.style.outlineColor, G.style.outlineWidth + 1, .4); try { G.map.addOverlay(zoomAreaPoly); setTimeout(function() { G.map.removeOverlay(zoomAreaPoly) }, G.options.overlayRemoveTime) } catch (e) { } var polyBounds = zoomAreaPoly.getBounds(); var ne = polyBounds.getNorthEast(); var sw = polyBounds.getSouthWest(); var se = new GLatLng(sw.lat(), ne.lng()); var nw = new GLatLng(ne.lat(), sw.lng()); if (G.options.rightMouseZoomOutEnabled && G.draggingRightMouse) { var mapSpan = G.map.getBounds().toSpan(); var polySpan = polyBounds.toSpan(); var dSize = Math.max(mapSpan.lat() / polySpan.lat(), mapSpan.lng() / polySpan.lng()); var zoomLevel = G.map.getZoom() - Math.ceil(Math.log(dSize, 2)) } else { var zoomLevel = G.map.getBoundsZoomLevel(polyBounds) } var center = polyBounds.getCenter(); G.map.setCenter(center, zoomLevel); if (G.callbacks.dragend != null) { G.callbacks.dragend(nw, ne, se, sw, nwpx, nepx, sepx, swpx) } } if (G.options.stickyZoomEnabled) { this.initCover_(); if (G.options.backButtonEnabled) this.saveBackContext_(G.options.backButtonHTML, false); G.backButtonDiv.style.display = 'none' } } }; DragZoomControl.prototype.setDimensions_ = function() { var G = this.globals; var mapSize = G.map.getSize(); G.mapWidth = mapSize.width; G.mapHeight = mapSize.height; G.mapRatio = G.mapHeight / G.mapWidth; DragZoomUtil.style([G.mapCover, G.cornerTopDiv, G.cornerRightDiv, G.cornerBottomDiv, G.cornerLeftDiv], { top: '0px', left: '0px', width: G.mapWidth + 'px', height: G.mapHeight + 'px' }) }; DragZoomControl.prototype.initStyles_ = function() { var G = this.globals; DragZoomUtil.style([G.mapCover, G.cornerTopDiv, G.cornerRightDiv, G.cornerBottomDiv, G.cornerLeftDiv], { filter: G.style.alphaIE, opacity: G.style.opacity, background: G.style.fillColor }); G.outlineDiv.style.border = G.style.border }; DragZoomControl.prototype.buttonclick_ = function() { var G = this.globals; G.backButtonDiv.style.display = 'none'; if (G.mapCover.style.display == 'block') { this.resetDragZoom_(); if (G.options.backButtonEnabled) { this.restoreBackContext_(); if (G.backStack.length == 0) G.backButtonDiv.style.display = 'none' } } else { this.initCover_(); if (G.options.backButtonEnabled) this.saveBackContext_(G.options.backButtonHTML, false) } }; DragZoomControl.prototype.backbuttonclick_ = function() { var G = this.globals; if (G.options.backButtonEnabled && G.backStack.length > 0) { this.restoreBackContext_(); if (G.callbacks['backbuttonclick'] != null) { G.callbacks.backbuttonclick(G.methodCall) } } }; DragZoomControl.prototype.saveBackContext_ = function(text, methodCall) { var G = this.globals; var backFrame = {}; backFrame["center"] = G.map.getCenter(); backFrame["zoom"] = G.map.getZoom(); backFrame["maptype"] = G.map.getCurrentMapType(); backFrame["text"] = G.backButtonDiv.innerHTML; backFrame["methodCall"] = methodCall; G.backStack.push(backFrame); G.backButtonDiv.innerHTML = text }; DragZoomControl.prototype.restoreBackContext_ = function() { var G = this.globals; var backFrame = G.backStack.pop(); G.map.setCenter(backFrame["center"], backFrame["zoom"], backFrame["maptype"]); G.backButtonDiv.innerHTML = backFrame["text"]; G.methodCall = backFrame["methodCall"]; if (G.backStack.length == 0) G.backButtonDiv.style.display = 'none' }; DragZoomControl.prototype.initCover_ = function() { var G = this.globals; G.mapPosition = DragZoomUtil.getElementPosition(G.map.getContainer()); this.setDimensions_(); this.setButtonMode_('zooming'); DragZoomUtil.style([G.mapCover], { display: 'block', background: G.style.fillColor }); DragZoomUtil.style([G.outlineDiv], { width: '0px', height: '0px' }); if (G.callbacks['buttonclick'] != null) { G.callbacks.buttonclick() } }; DragZoomControl.prototype.getRelPos_ = function(e) { var pos = DragZoomUtil.getMousePosition(e); var G = this.globals; return { top: (pos.top - G.mapPosition.top), left: (pos.left - G.mapPosition.left)} }; DragZoomControl.prototype.getRectangle_ = function(startX, startY, pos, ratio) { var left = false; var top = false; var dX = pos.left - startX; var dY = pos.top - startY; if (dX < 0) { dX = dX * -1; left = true } if (dY < 0) { dY = dY * -1; top = true } delta = dX > dY ? dX : dY; return { startX: startX, startY: startY, endX: startX + delta, endY: startY + parseInt(delta * ratio), width: delta, height: parseInt(delta * ratio), left: left, top: top} }; DragZoomControl.prototype.resetDragZoom_ = function() { var G = this.globals; DragZoomUtil.style([G.mapCover, G.cornerTopDiv, G.cornerRightDiv, G.cornerBottomDiv, G.cornerLeftDiv], { display: 'none', opacity: G.style.opacity, filter: G.style.alphaIE }); G.outlineDiv.style.display = 'none'; this.setButtonMode_('normal'); if (G.options.backButtonEnabled && (G.backStack.length > 0)) G.backButtonDiv.style.display = 'block' }; var DragZoomUtil = {}; DragZoomUtil.gE = function(sId) { return document.getElementById(sId) }; DragZoomUtil.getMousePosition = function(e) { var posX = 0; var posY = 0; if (!e) var e = window.event; if (e.pageX || e.pageY) { posX = e.pageX; posY = e.pageY } else if (e.clientX || e.clientY) { posX = e.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft); posY = e.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) } return { left: posX, top: posY} }; DragZoomUtil.getElementPosition = function(element) { var leftPos = element.offsetLeft; var topPos = element.offsetTop; var parElement = element.offsetParent; while (parElement != null) { leftPos += parElement.offsetLeft; topPos += parElement.offsetTop; parElement = parElement.offsetParent } return { left: leftPos, top: topPos} }; DragZoomUtil.style = function(elements, styles) { if (typeof (elements) == 'string') { elements = DragZoomUtil.getManyElements(elements) } for (var i = 0; i < elements.length; i++) { for (var s in styles) { elements[i].style[s] = styles[s] } } }; DragZoomUtil.getManyElements = function(idsString) { var idsArray = idsString.split(','); var elements = []; for (var i = 0; i < idsArray.length; i++) { elements[elements.length] = DragZoomUtil.gE(idsArray[i]) }; return elements };
//--SnapToRoute.js
eval(function(p, a, c, k, e, r) { e = function(c) { return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) }; if (!''.replace(/^/, String)) { while (c--) r[e(c)] = k[c] || e(c); k = [function(e) { return r[e] } ]; e = function() { return '\\w+' }; c = 1 }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p } ('6 7(a,c,b){3.B=[];3.E=1b.15();3.v=a;3.w=c;3.u=b;3.L()}7.8.L=6(){3.D();3.S()};7.8.1a=6(b,a){3.w=b||3.w;3.u=a||3.u;3.D()};7.8.S=6(){4 a=3;C.R(a.v,\'12\',C.Q(a,a.P));C.R(a.v,\'W\',C.Q(a,a.D))};7.8.D=6(){4 a=3.v.G();3.B=[];F(4 i=0;i<3.u.V();i++){4 b=3.E.J(3.u.A(i),a);3.B.1e(b)}};7.8.P=6(a){4 b=3.T(a);3.w.1c(b)};7.8.T=6(a){4 r=3.H(a);z 3.E.16(14 13(r.x,r.y),3.v.G())};7.8.11=6(a){9(10(Z)===\'Y\'){a=3.w.X()}4 r=3.H(a);z 3.O(r.i,r.N)};7.8.H=6(b){4 a=3.v.G();4 c=3.E.J(b,a);4 d=3.B;z 3.M(c,d)};7.8.O=6(c,a){4 b=3.u;4 d=0;F(4 n=1;n<c;n++){d+=b.A(n-1).K(b.A(n))}d+=b.A(c-1).K(b.A(c))*a;z d};7.8.M=6(l,d){4 q;4 o;4 f;4 x;4 y;4 i;4 g;9(d.I>1){F(4 n=1;n<d.I;n++){9(d[n].x!==d[n-1].x){4 a=(d[n].y-d[n-1].y)/(d[n].x-d[n-1].x);4 b=d[n].y-a*d[n].x;g=5.U(a*l.x+b-l.y)/5.t(a*a+1)}1d{g=5.U(l.x-d[n].x)}4 e=5.s(d[n].y-d[n-1].y,2)+5.s(d[n].x-d[n-1].x,2);4 m=5.s(d[n].y-l.y,2)+5.s(d[n].x-l.x,2);4 c=5.s(d[n-1].y-l.y,2)+5.s(d[n-1].x-l.x,2);4 k=5.s(g,2);4 p=m-k+c-k;9(p>e){g=5.t(5.19(m,c))}9((q==18)||(q>g)){o=5.t(c-k)/5.t(e);f=5.t(m-k)/5.t(e);q=g;i=n}}9(o>1){o=1}9(f>1){o=0;f=1}4 h=d[i-1].x-d[i].x;4 j=d[i-1].y-d[i].y;x=d[i-1].x-(h*o);y=d[i-1].y-(j*o)}z{\'x\':x,\'y\':y,\'i\':i,\'N\':o,\'17\':f}}', 62, 77, '|||this|var|Math|function|SnapToRoute|prototype|if|||||||||||||||||||pow|sqrt|polyline_|map_|marker_|||return|getVertex|routePixels_|GEvent|loadLineData_|normalProj_|for|getZoom|distanceToLines_|length|fromLatLngToPixel|distanceFrom|init_|getClosestPointOnLines_|to|getDistToLine_|updateMarkerLocation_|callback|addListener|loadMapListener_|getClosestLatLng|abs|getVertexCount|zoomend|getLatLng|undefined|opt_latlng|typeof|getDistAlongRoute|mousemove|GPoint|new|getProjection|fromPixelToLatLng|from|null|min|updateTargets|G_NORMAL_MAP|setLatLng|else|push'.split('|'), 0, {}))
