From 309d198e04e67f5dfc7ca6b5bc9e0026286a536f Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 9 Jul 2010 15:50:45 +0000 Subject: [PATCH] Removing stuff that was added twice in r10474 (see #2493). git-svn-id: http://svn.openlayers.org/trunk/openlayers@10476 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer/Google/v2.js | 346 --------------------------- lib/OpenLayers/Layer/Google/v3.js | 379 ------------------------------ tests/Layer/Google/v3.html | 215 ----------------- 3 files changed, 940 deletions(-) diff --git a/lib/OpenLayers/Layer/Google/v2.js b/lib/OpenLayers/Layer/Google/v2.js index ffc68860fe..b7e9b1a1ec 100644 --- a/lib/OpenLayers/Layer/Google/v2.js +++ b/lib/OpenLayers/Layer/Google/v2.js @@ -344,349 +344,3 @@ OpenLayers.Layer.Google.v2 = { } }; -/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD - * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the - * full text of the license. */ - - -/** - * @requires OpenLayers/Layer/Google.js - */ - -/** - * Constant: OpenLayers.Layer.Google.v2 - * - * Mixin providing functionality specific to the Google Maps API v2. - */ -OpenLayers.Layer.Google.v2 = { - - /** - * Property: termsOfUse - * {DOMElement} Div for Google's copyright and terms of use link - */ - termsOfUse: null, - - /** - * Property: poweredBy - * {DOMElement} Div for Google's powered by logo and link - */ - poweredBy: null, - - /** - * Property: dragObject - * {GDraggableObject} Since 2.93, Google has exposed the ability to get - * the maps GDraggableObject. We can now use this for smooth panning - */ - dragObject: null, - - /** - * Method: loadMapObject - * Load the GMap and register appropriate event listeners. If we can't - * load GMap2, then display a warning message. - */ - loadMapObject:function() { - if (!this.type) { - this.type = G_NORMAL_MAP; - } - var mapObject, termsOfUse, poweredBy; - var cache = OpenLayers.Layer.Google.cache[this.map.id]; - if (cache) { - // there are already Google layers added to this map - mapObject = cache.mapObject; - termsOfUse = cache.termsOfUse; - poweredBy = cache.poweredBy; - // increment the layer count - ++cache.count; - } else { - // this is the first Google layer for this map - - var container = this.map.viewPortDiv; - var div = document.createElement("div"); - div.id = this.map.id + "_GMap2Container"; - div.style.position = "absolute"; - div.style.width = "100%"; - div.style.height = "100%"; - container.appendChild(div); - - // create GMap and shuffle elements - try { - mapObject = new GMap2(div); - - // move the ToS and branding stuff up to the container div - termsOfUse = div.lastChild; - container.appendChild(termsOfUse); - termsOfUse.style.zIndex = "1100"; - termsOfUse.style.right = ""; - termsOfUse.style.bottom = ""; - termsOfUse.className = "olLayerGoogleCopyright"; - - poweredBy = div.lastChild; - container.appendChild(poweredBy); - poweredBy.style.zIndex = "1100"; - poweredBy.style.right = ""; - poweredBy.style.bottom = ""; - poweredBy.className = "olLayerGooglePoweredBy gmnoprint"; - - } catch (e) { - throw(e); - return; - } - // cache elements for use by any other google layers added to - // this same map - OpenLayers.Layer.Google.cache[this.map.id] = { - mapObject: mapObject, - termsOfUse: termsOfUse, - poweredBy: poweredBy, - count: 1 - }; - } - - this.mapObject = mapObject; - this.termsOfUse = termsOfUse; - this.poweredBy = poweredBy; - - // ensure this layer type is one of the mapObject types - if (OpenLayers.Util.indexOf(this.mapObject.getMapTypes(), - this.type) === -1) { - this.mapObject.addMapType(this.type); - } - - //since v 2.93 getDragObject is now available. - if(typeof mapObject.getDragObject == "function") { - this.dragObject = mapObject.getDragObject(); - } else { - this.dragPanMapObject = null; - } - - if(this.isBaseLayer === false) { - this.setGMapVisibility(this.div.style.display !== "none"); - } - - }, - - /** - * APIMethod: onMapResize - */ - onMapResize: function() { - // workaround for resizing of invisible or not yet fully loaded layers - // where GMap2.checkResize() does not work. We need to load the GMap - // for the old div size, then checkResize(), and then call - // layer.moveTo() to trigger GMap.setCenter() (which will finish - // the GMap initialization). - if(this.visibility && this.mapObject.isLoaded()) { - this.mapObject.checkResize(); - } else { - if(!this._resized) { - var layer = this; - var handle = GEvent.addListener(this.mapObject, "load", function() { - GEvent.removeListener(handle); - delete layer._resized; - layer.mapObject.checkResize(); - layer.moveTo(layer.map.getCenter(), layer.map.getZoom()); - }); - } - this._resized = true; - } - }, - - /** - * Method: setGMapVisibility - * Display the GMap container and associated elements. - * - * Parameters: - * visible - {Boolean} Display the GMap elements. - */ - setGMapVisibility: function(visible) { - var cache = OpenLayers.Layer.Google.cache[this.map.id]; - if (cache) { - var container = this.mapObject.getContainer(); - if (visible === true) { - this.mapObject.setMapType(this.type); - container.style.display = ""; - this.termsOfUse.style.left = ""; - this.termsOfUse.style.display = ""; - this.poweredBy.style.display = ""; - cache.displayed = this.id; - } else { - if (cache.displayed === this.id) { - delete cache.displayed; - } - if (!cache.displayed) { - container.style.display = "none"; - this.termsOfUse.style.display = "none"; - // move ToU far to the left in addition to setting display - // to "none", because at the end of the GMap2 load - // sequence, display: none will be unset and ToU would be - // visible after loading a map with a google layer that is - // initially hidden. - this.termsOfUse.style.left = "-9999px"; - this.poweredBy.style.display = "none"; - } - } - } - }, - - /** - * Method: getMapContainer - * - * Returns: - * {DOMElement} the GMap container's div - */ - getMapContainer: function() { - return this.mapObject.getContainer(); - }, - - // - // TRANSLATION: MapObject Bounds <-> OpenLayers.Bounds - // - - /** - * APIMethod: getMapObjectBoundsFromOLBounds - * - * Parameters: - * olBounds - {} - * - * Returns: - * {Object} A MapObject Bounds, translated from olBounds - * Returns null if null value is passed in - */ - getMapObjectBoundsFromOLBounds: function(olBounds) { - var moBounds = null; - if (olBounds != null) { - var sw = this.sphericalMercator ? - this.inverseMercator(olBounds.bottom, olBounds.left) : - new OpenLayers.LonLat(olBounds.bottom, olBounds.left); - var ne = this.sphericalMercator ? - this.inverseMercator(olBounds.top, olBounds.right) : - new OpenLayers.LonLat(olBounds.top, olBounds.right); - moBounds = new GLatLngBounds(new GLatLng(sw.lat, sw.lon), - new GLatLng(ne.lat, ne.lon)); - } - return moBounds; - }, - - - /************************************ - * * - * MapObject Interface Controls * - * * - ************************************/ - - - // Get&Set Center, Zoom - - /** - * APIMethod: setMapObjectCenter - * Set the mapObject to the specified center and zoom - * - * Parameters: - * center - {Object} MapObject LonLat format - * zoom - {int} MapObject zoom format - */ - setMapObjectCenter: function(center, zoom) { - this.mapObject.setCenter(center, zoom); - }, - - /** - * APIMethod: dragPanMapObject - * - * Parameters: - * dX - {Integer} - * dY - {Integer} - */ - dragPanMapObject: function(dX, dY) { - this.dragObject.moveBy(new GSize(-dX, dY)); - }, - - - // LonLat - Pixel Translation - - /** - * APIMethod: getMapObjectLonLatFromMapObjectPixel - * - * Parameters: - * moPixel - {Object} MapObject Pixel format - * - * Returns: - * {Object} MapObject LonLat translated from MapObject Pixel - */ - getMapObjectLonLatFromMapObjectPixel: function(moPixel) { - return this.mapObject.fromContainerPixelToLatLng(moPixel); - }, - - /** - * APIMethod: getMapObjectPixelFromMapObjectLonLat - * - * Parameters: - * moLonLat - {Object} MapObject LonLat format - * - * Returns: - * {Object} MapObject Pixel transtlated from MapObject LonLat - */ - getMapObjectPixelFromMapObjectLonLat: function(moLonLat) { - return this.mapObject.fromLatLngToContainerPixel(moLonLat); - }, - - - // Bounds - - /** - * APIMethod: getMapObjectZoomFromMapObjectBounds - * - * Parameters: - * moBounds - {Object} MapObject Bounds format - * - * Returns: - * {Object} MapObject Zoom for specified MapObject Bounds - */ - getMapObjectZoomFromMapObjectBounds: function(moBounds) { - return this.mapObject.getBoundsZoomLevel(moBounds); - }, - - /************************************ - * * - * MapObject Primitives * - * * - ************************************/ - - - // LonLat - - /** - * APIMethod: getMapObjectLonLatFromLonLat - * - * Parameters: - * lon - {Float} - * lat - {Float} - * - * Returns: - * {Object} MapObject LonLat built from lon and lat params - */ - getMapObjectLonLatFromLonLat: function(lon, lat) { - var gLatLng; - if(this.sphericalMercator) { - var lonlat = this.inverseMercator(lon, lat); - gLatLng = new GLatLng(lonlat.lat, lonlat.lon); - } else { - gLatLng = new GLatLng(lat, lon); - } - return gLatLng; - }, - - // Pixel - - /** - * APIMethod: getMapObjectPixelFromXY - * - * Parameters: - * x - {Integer} - * y - {Integer} - * - * Returns: - * {Object} MapObject Pixel from x and y parameters - */ - getMapObjectPixelFromXY: function(x, y) { - return new GPoint(x, y); - } - -}; diff --git a/lib/OpenLayers/Layer/Google/v3.js b/lib/OpenLayers/Layer/Google/v3.js index 590cb00210..97a59b37cf 100644 --- a/lib/OpenLayers/Layer/Google/v3.js +++ b/lib/OpenLayers/Layer/Google/v3.js @@ -405,382 +405,3 @@ OpenLayers.Layer.Google.v3 = { } }; -/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD - * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the - * full text of the license. */ - - -/** - * @requires OpenLayers/Layer/Google.js - */ - -/** - * Constant: OpenLayers.Layer.Google.v3 - * - * Mixin providing functionality specific to the Google Maps API v3. Note that - */ -OpenLayers.Layer.Google.v3 = { - - /** - * Constant: DEFAULTS - * {Object} It is not recommended to change the properties set here. Note - * that Google.v3 layers only work when sphericalMercator is set to true. - * - * (code) - * { - * maxExtent: new OpenLayers.Bounds( - * -128 * 156543.0339, - * -128 * 156543.0339, - * 128 * 156543.0339, - * 128 * 156543.0339 - * ), - * sphericalMercator: true, - * maxResolution: 156543.0339, - * units: "m", - * projection: "EPSG:900913" - * } - * (end) - */ - DEFAULTS: { - maxExtent: new OpenLayers.Bounds( - -128 * 156543.0339, - -128 * 156543.0339, - 128 * 156543.0339, - 128 * 156543.0339 - ), - sphericalMercator: true, - maxResolution: 156543.0339, - units: "m", - projection: "EPSG:900913" - }, - - /** - * Method: loadMapObject - * Load the GMap and register appropriate event listeners. If we can't - * load GMap2, then display a warning message. - */ - loadMapObject:function() { - if (!this.type) { - this.type = google.maps.MapTypeId.ROADMAP; - } - var mapObject, termsOfUse, poweredBy; - var cache = OpenLayers.Layer.Google.cache[this.map.id]; - if (cache) { - // there are already Google layers added to this map - mapObject = cache.mapObject; - // increment the layer count - ++cache.count; - } else { - // this is the first Google layer for this map - - var container = this.map.viewPortDiv; - var div = document.createElement("div"); - div.id = this.map.id + "_GMapContainer"; - div.style.position = "absolute"; - div.style.width = "100%"; - div.style.height = "100%"; - container.appendChild(div); - - // create GMap and shuffle elements - var center = this.map.getCenter(); - mapObject = new google.maps.Map(div, { - center: center ? - new google.maps.LatLng(center.lat, center.lon) : - new google.maps.LatLng(0, 0), - zoom: this.map.getZoom() || 0, - mapTypeId: this.type, - disableDefaultUI: true, - keyboardShortcuts: false, - draggable: false, - disableDoubleClickZoom: true, - scrollwheel: false - }); - - // cache elements for use by any other google layers added to - // this same map - cache = { - mapObject: mapObject, - count: 1 - }; - OpenLayers.Layer.Google.cache[this.map.id] = cache; - var layer = this; - this._googleOnIdle = google.maps.event.addListenerOnce(mapObject, "idle", function() { - var div = mapObject.getDiv().firstChild; - - // move the ToS and branding stuff up to the container div - var termsOfUse = div.lastChild; - container.appendChild(termsOfUse); - termsOfUse.style.zIndex = "1100"; - termsOfUse.style.bottom = ""; - termsOfUse.className = "olLayerGoogleCopyright olLayerGoogleV3"; - cache.termsOfUse = termsOfUse; - - var poweredBy = div.lastChild; - container.appendChild(poweredBy); - poweredBy.style.zIndex = "1100"; - poweredBy.style.bottom = ""; - poweredBy.className = "olLayerGooglePoweredBy olLayerGoogleV3 gmnoprint"; - cache.poweredBy = poweredBy; - - layer.setGMapVisibility(layer.div.style.display !== "none"); - }); - } - - this.mapObject = mapObject; - }, - - /** - * APIMethod: onMapResize - */ - onMapResize: function() { - // workaround for resizing of invisible or not yet fully loaded layers - // where GMap2.checkResize() does not work. We need to load the GMap - // for the old div size, then checkResize(), and then call - // layer.moveTo() to trigger GMap.setCenter() (which will finish - // the GMap initialization). - if(this.visibility) { - google.maps.event.trigger(this.mapObject, 'resize'); - } else { - if(!this._resized) { - var layer = this; - google.maps.event.addListenerOnce(this.mapObject, "tilesloaded", function() { - delete layer._resized; - google.maps.event.trigger(layer.mapObject, 'resize'); - layer.moveTo(layer.map.getCenter(), layer.map.getZoom()); - }); - } - this._resized = true; - } - }, - - /** - * Method: setGMapVisibility - * Display the GMap container and associated elements. - * - * Parameters: - * visible - {Boolean} Display the GMap elements. - */ - setGMapVisibility: function(visible) { - var cache = OpenLayers.Layer.Google.cache[this.map.id]; - if (cache) { - var container = this.mapObject.getDiv(); - if (visible === true) { - this.mapObject.setMapTypeId(this.type); - container.style.display = ""; - if(cache.termsOfUse) { - cache.termsOfUse.style.left = ""; - cache.termsOfUse.style.display = ""; - cache.poweredBy.style.display = ""; - } - cache.displayed = this.id; - } else { - if (cache.displayed === this.id) { - delete cache.displayed; - } - if (!cache.displayed) { - container.style.display = "none"; - if(cache.termsOfUse) { - cache.termsOfUse.style.display = "none"; - // move ToU far to the left in addition to setting - // display to "none", because at the end of the GMap - // load sequence, display: none will be unset and ToU - // would be visible after loading a map with a google - // layer that is initially hidden. - cache.termsOfUse.style.left = "-9999px"; - cache.poweredBy.style.display = "none"; - } - } - } - } - }, - - /** - * Method: getMapContainer - * - * Returns: - * {DOMElement} the GMap container's div - */ - getMapContainer: function() { - return this.mapObject.getDiv(); - }, - - // - // TRANSLATION: MapObject Bounds <-> OpenLayers.Bounds - // - - /** - * APIMethod: getMapObjectBoundsFromOLBounds - * - * Parameters: - * olBounds - {} - * - * Returns: - * {Object} A MapObject Bounds, translated from olBounds - * Returns null if null value is passed in - */ - getMapObjectBoundsFromOLBounds: function(olBounds) { - var moBounds = null; - if (olBounds != null) { - var sw = this.sphericalMercator ? - this.inverseMercator(olBounds.bottom, olBounds.left) : - new OpenLayers.LonLat(olBounds.bottom, olBounds.left); - var ne = this.sphericalMercator ? - this.inverseMercator(olBounds.top, olBounds.right) : - new OpenLayers.LonLat(olBounds.top, olBounds.right); - moBounds = new google.maps.LatLngBounds( - new google.maps.LatLng(sw.lat, sw.lon), - new google.maps.LatLng(ne.lat, ne.lon) - ); - } - return moBounds; - }, - - - /************************************ - * * - * MapObject Interface Controls * - * * - ************************************/ - - - // LonLat - Pixel Translation - - /** - * APIMethod: getMapObjectLonLatFromMapObjectPixel - * - * Parameters: - * moPixel - {Object} MapObject Pixel format - * - * Returns: - * {Object} MapObject LonLat translated from MapObject Pixel - */ - getMapObjectLonLatFromMapObjectPixel: function(moPixel) { - var size = this.map.getSize(); - var lon = this.getLongitudeFromMapObjectLonLat(this.mapObject.center); - var lat = this.getLatitudeFromMapObjectLonLat(this.mapObject.center); - var res = this.map.getResolution(); - - var delta_x = moPixel.x - (size.w / 2); - var delta_y = moPixel.y - (size.h / 2); - - var lonlat = new OpenLayers.LonLat( - lon + delta_x * res, - lat - delta_y * res - ); - - if (this.wrapDateLine) { - lonlat = lonlat.wrapDateLine(this.maxExtent); - } - return this.getMapObjectLonLatFromLonLat(lonlat.lon, lonlat.lat); - }, - - /** - * APIMethod: getMapObjectPixelFromMapObjectLonLat - * - * Parameters: - * moLonLat - {Object} MapObject LonLat format - * - * Returns: - * {Object} MapObject Pixel transtlated from MapObject LonLat - */ - getMapObjectPixelFromMapObjectLonLat: function(moLonLat) { - var lon = this.getLongitudeFromMapObjectLonLat(moLonLat); - var lat = this.getLatitudeFromMapObjectLonLat(moLonLat); - var res = this.map.getResolution(); - var extent = this.map.getExtent(); - px = new OpenLayers.Pixel( - (1/res * (lon - extent.left)), - (1/res * (extent.top - lat)) - ); - return this.getMapObjectPixelFromXY(px.x, px.y); - }, - - - /** - * APIMethod: setMapObjectCenter - * Set the mapObject to the specified center and zoom - * - * Parameters: - * center - {Object} MapObject LonLat format - * zoom - {int} MapObject zoom format - */ - setMapObjectCenter: function(center, zoom) { - this.mapObject.setOptions({ - center: center, - zoom: zoom - }); - }, - - - // Bounds - - /** - * APIMethod: getMapObjectZoomFromMapObjectBounds - * - * Parameters: - * moBounds - {Object} MapObject Bounds format - * - * Returns: - * {Object} MapObject Zoom for specified MapObject Bounds - */ - getMapObjectZoomFromMapObjectBounds: function(moBounds) { - return this.mapObject.getBoundsZoomLevel(moBounds); - }, - - /************************************ - * * - * MapObject Primitives * - * * - ************************************/ - - - // LonLat - - /** - * APIMethod: getMapObjectLonLatFromLonLat - * - * Parameters: - * lon - {Float} - * lat - {Float} - * - * Returns: - * {Object} MapObject LonLat built from lon and lat params - */ - getMapObjectLonLatFromLonLat: function(lon, lat) { - var gLatLng; - if(this.sphericalMercator) { - var lonlat = this.inverseMercator(lon, lat); - gLatLng = new google.maps.LatLng(lonlat.lat, lonlat.lon); - } else { - gLatLng = new google.maps.LatLng(lat, lon); - } - return gLatLng; - }, - - // Pixel - - /** - * APIMethod: getMapObjectPixelFromXY - * - * Parameters: - * x - {Integer} - * y - {Integer} - * - * Returns: - * {Object} MapObject Pixel from x and y parameters - */ - getMapObjectPixelFromXY: function(x, y) { - return new google.maps.Point(x, y); - }, - - /** - * APIMethod: destroy - * Clean up this layer. - */ - destroy: function() { - this._googleOnIdle && - google.maps.event.removeListener(this._googleOnIdle); - OpenLayers.Layer.Google.prototype.destroy.apply(this, arguments); - } - -}; diff --git a/tests/Layer/Google/v3.html b/tests/Layer/Google/v3.html index a9000558cb..99100e8b68 100644 --- a/tests/Layer/Google/v3.html +++ b/tests/Layer/Google/v3.html @@ -230,219 +230,4 @@
- - - - - - - - -
- \ No newline at end of file