From 663392b10e39fdfa254c3fd356791abfdbbbc24c Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Thu, 1 Sep 2011 19:07:37 +0000 Subject: [PATCH] Despite our best efforts to comply, we have been told that this layer violates the Google Maps Terms of Service. Without rendering their full map interface, they have no way of controlling the user experience, dropping in ads, and the like. (closes #3481) git-svn-id: http://svn.openlayers.org/trunk/openlayers@12317 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- apidoc_config/Menu.txt | 2 - doc_config/Menu.txt | 2 - examples/google-ng.html | 45 ----- examples/google-ng.js | 28 --- lib/OpenLayers.js | 2 - lib/OpenLayers/Layer/GoogleNG.js | 336 ------------------------------- lib/OpenLayers/Tile/Google.js | 154 -------------- tests/Layer/GoogleNG.html | 104 ---------- tests/Tile/Google.html | 74 ------- tests/list-tests.html | 2 - 10 files changed, 749 deletions(-) delete mode 100644 examples/google-ng.html delete mode 100644 examples/google-ng.js delete mode 100644 lib/OpenLayers/Layer/GoogleNG.js delete mode 100644 lib/OpenLayers/Tile/Google.js delete mode 100644 tests/Layer/GoogleNG.html delete mode 100644 tests/Tile/Google.html diff --git a/apidoc_config/Menu.txt b/apidoc_config/Menu.txt index 9d17464b31..9d23a1a7aa 100644 --- a/apidoc_config/Menu.txt +++ b/apidoc_config/Menu.txt @@ -352,7 +352,6 @@ Group: OpenLayers { File: GML (no auto-title, OpenLayers/Layer/GML.js) File: Google (no auto-title, OpenLayers/Layer/Google.js) File: Google.v3 (no auto-title, OpenLayers/Layer/Google/v3.js) - File: GoogleNG (no auto-title, OpenLayers/Layer/GoogleNG.js) File: Grid (no auto-title, OpenLayers/Layer/Grid.js) File: HTTPRequest (no auto-title, OpenLayers/Layer/HTTPRequest.js) File: Image (no auto-title, OpenLayers/Layer/Image.js) @@ -475,7 +474,6 @@ Group: OpenLayers { Group: Tile { File: Tile (no auto-title, OpenLayers/Tile.js) - File: Google (no auto-title, OpenLayers/Tile/Google.js) File: Image (no auto-title, OpenLayers/Tile/Image.js) File: Image.IFrame (no auto-title, OpenLayers/Tile/Image/IFrame.js) File: WFS (no auto-title, OpenLayers/Tile/WFS.js) diff --git a/doc_config/Menu.txt b/doc_config/Menu.txt index 9d17464b31..9d23a1a7aa 100644 --- a/doc_config/Menu.txt +++ b/doc_config/Menu.txt @@ -352,7 +352,6 @@ Group: OpenLayers { File: GML (no auto-title, OpenLayers/Layer/GML.js) File: Google (no auto-title, OpenLayers/Layer/Google.js) File: Google.v3 (no auto-title, OpenLayers/Layer/Google/v3.js) - File: GoogleNG (no auto-title, OpenLayers/Layer/GoogleNG.js) File: Grid (no auto-title, OpenLayers/Layer/Grid.js) File: HTTPRequest (no auto-title, OpenLayers/Layer/HTTPRequest.js) File: Image (no auto-title, OpenLayers/Layer/Image.js) @@ -475,7 +474,6 @@ Group: OpenLayers { Group: Tile { File: Tile (no auto-title, OpenLayers/Tile.js) - File: Google (no auto-title, OpenLayers/Tile/Google.js) File: Image (no auto-title, OpenLayers/Tile/Image.js) File: Image.IFrame (no auto-title, OpenLayers/Tile/Image/IFrame.js) File: WFS (no auto-title, OpenLayers/Tile/WFS.js) diff --git a/examples/google-ng.html b/examples/google-ng.html deleted file mode 100644 index 4322763b8e..0000000000 --- a/examples/google-ng.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - OpenLayers Google NG Layer Example - - - - - - - - - -

Google NG Layer Example

-
- Google, api key, apikey -
-

- Demonstrate use of tiles from the Google Maps v3 API. -

-
-
-

- If you use OpenLayers.Layer.GoogleNG, the getTile method of the - GMaps v3 API's MapType is used to load tiles. This allows for - better integration than interacting with a whole map generated - by a google.maps.Map instance, as done with - OpenLayers.Layer.Google. See the - google-ng.js source - to see how this is done. -

-
- - diff --git a/examples/google-ng.js b/examples/google-ng.js deleted file mode 100644 index fa2ba35b25..0000000000 --- a/examples/google-ng.js +++ /dev/null @@ -1,28 +0,0 @@ -var map; - -function init() { - map = new OpenLayers.Map('map'); - map.addControl(new OpenLayers.Control.LayerSwitcher()); - - var gphy = new OpenLayers.Layer.GoogleNG( - {type: google.maps.MapTypeId.TERRAIN} - ); - var gmap = new OpenLayers.Layer.GoogleNG( - // ROADMAP, the default - ); - var ghyb = new OpenLayers.Layer.GoogleNG( - {type: google.maps.MapTypeId.HYBRID} - ); - var gsat = new OpenLayers.Layer.GoogleNG( - {type: google.maps.MapTypeId.SATELLITE} - ); - - map.addLayers([gphy, gmap, ghyb, gsat]); - - // GoogleNG uses EPSG:900913 as projection, so we have to - // transform our coordinates - map.setCenter(new OpenLayers.LonLat(10.2, 48.9).transform( - new OpenLayers.Projection("EPSG:4326"), - map.getProjectionObject() - ), 5); -} diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index 0b4e37db20..b378b7d24b 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -122,7 +122,6 @@ "OpenLayers/Popup.js", "OpenLayers/Tile.js", "OpenLayers/Tile/BackBufferable.js", - "OpenLayers/Tile/Google.js", "OpenLayers/Tile/Image.js", "OpenLayers/Tile/Image/IFrame.js", "OpenLayers/Tile/WFS.js", @@ -155,7 +154,6 @@ "OpenLayers/Layer/Boxes.js", "OpenLayers/Layer/XYZ.js", "OpenLayers/Layer/Bing.js", - "OpenLayers/Layer/GoogleNG.js", "OpenLayers/Layer/TMS.js", "OpenLayers/Layer/TileCache.js", "OpenLayers/Layer/Zoomify.js", diff --git a/lib/OpenLayers/Layer/GoogleNG.js b/lib/OpenLayers/Layer/GoogleNG.js deleted file mode 100644 index f380b72331..0000000000 --- a/lib/OpenLayers/Layer/GoogleNG.js +++ /dev/null @@ -1,336 +0,0 @@ -/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for - * full list of contributors). 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/XYZ.js - * @requires OpenLayers/Tile/Google.js - * @requires OpenLayers/Layer/SphericalMercator.js - */ - -/** - * Class: OpenLayers.Layer.GoogleNG - * Google layer using tiles. - * - * Inherits from: - * - - */ -OpenLayers.Layer.GoogleNG = OpenLayers.Class(OpenLayers.Layer.XYZ, { - - /** - * Property: SUPPORTED_TRANSITIONS - * {Array} An immutable (that means don't change it!) list of supported - * transitionEffect values. This layer type supports none. - */ - SUPPORTED_TRANSITIONS: [], - - /** - * Property: serverResolutions - * {Array} the resolutions provided by the Google API. - */ - serverResolutions: [ - 156543.03390625, 78271.516953125, 39135.7584765625, - 19567.87923828125, 9783.939619140625, 4891.9698095703125, - 2445.9849047851562, 1222.9924523925781, 611.4962261962891, - 305.74811309814453, 152.87405654907226, 76.43702827453613, - 38.218514137268066, 19.109257068634033, 9.554628534317017, - 4.777314267158508, 2.388657133579254, 1.194328566789627, - 0.5971642833948135, 0.29858214169740677, 0.14929107084870338, - 0.07464553542435169, 0.037322767712175846 - ], - - /** - * Property: attributionTemplate - * {String} - */ - attributionTemplate: '' + - '
' + - '
${mapData}' + - 'Terms of Use
', - - /** - * Property: mapTypes - * {Object} mapping of {google.maps.MapTypeId} to the t param of - * http://maps.google.com/maps? permalinks - */ - mapTypes: { - "roadmap": "m", - "satellite": "k", - "hybrid": "h", - "terrain": "p" - }, - - /** - * APIProperty: type - * {google.maps.MapTypeId} See - * http://code.google.com/apis/maps/documentation/javascript/reference.html#MapTypeId - */ - type: null, - - /** - * Constructor: OpenLayers.Layer.GoogleNG - * Create a new GoogleNG layer. Requires the GMaps v3 JavaScript API script - * (http://maps.google.com/maps/api/js?v=3.5&sensor=false) loaded in - * the html document. Note: Terms of Service compliant use requires the map - * to be configured with an control and - * the attribution placed on the map. - * - * Example: - * (code) - * var terrain = new OpenLayers.Layer.GoogleNG({ - * name: "Google Terrain", - * type: google.maps.MapTypeId.TERRAIN - * }); - * (end) - * - * Parameters: - * options - {Object} Configuration properties for the layer. - * - * Required configuration properties: - * type - {google.maps.MapTypeId} The layer identifier. See - * http://code.google.com/apis/maps/documentation/javascript/reference.html#MapTypeId - * for valid types. - * - * Any other documented layer properties can be provided in the config object. - */ - initialize: function(options) { - options = OpenLayers.Util.applyDefaults({ - sphericalMercator: true - }, options); - - if (!options.type) { - options.type = google.maps.MapTypeId.ROADMAP; - } - var newArgs = [options.name, null, options]; - OpenLayers.Layer.XYZ.prototype.initialize.apply(this, newArgs); - - if (!OpenLayers.Layer.GoogleNG.mapObject) { - OpenLayers.Layer.GoogleNG.mapObject = - new google.maps.Map(document.createElement("div")); - } - if (OpenLayers.Layer.GoogleNG.mapObject.mapTypes[this.type]) { - this.initLayer(); - } else { - google.maps.event.addListenerOnce( - OpenLayers.Layer.GoogleNG.mapObject, - "idle", - OpenLayers.Function.bind(this.initLayer, this) - ); - } - }, - - /** - * Method: initLayer - * - * Sets layer properties according to the metadata provided by the API - */ - initLayer: function() { - var mapType = OpenLayers.Layer.GoogleNG.mapObject.mapTypes[this.type]; - if (!this.name) { - this.setName("Google " + mapType.name); - } - - var minZoom = mapType.minZoom || 0; - this.addOptions({ - maxResolution: Math.min( - this.serverResolutions[minZoom], this.maxResolution - ), - zoomOffset: minZoom, - numZoomLevels: Math.min( - mapType.maxZoom + 1 - minZoom, this.numZoomLevels - ) - }, true); - }, - - /** - * Method: addTile - * Create a tile, initialize it, and add it to the layer div. - * - * Parameters - * bounds - {} - * position - {} - * - * Returns: - * {} The added OpenLayers.Tile.Google - */ - addTile:function(bounds, position) { - return new OpenLayers.Tile.Google( - this, position, bounds, this.tileOptions - ); - }, - - /** - * Method: updateAttribution - * Updates the attribution using the - * - * Parameters: - * copyrights - {Object} Object with "m", "k", "h" and "p" properties (see - * ), each holding an array of copyrights. - */ - updateAttribution: function(copyrights) { - var myCopyrights; - if (this.type == google.maps.MapTypeId.HYBRID) { - // the Copyright Service returns "k" and "m" copyrights for the - // HYBRID layer type. - var candidates = [].concat( - copyrights["h"], copyrights["k"], copyrights["m"] - ); - myCopyrights = []; - for (var i=candidates.length-1; i>=0; --i) { - if (OpenLayers.Util.indexOf(candidates, myCopyrights) == -1) { - myCopyrights.push(candidates[i]); - } - } - } else { - myCopyrights = copyrights[this.mapTypes[this.type]]; - } - var mapData = myCopyrights.length == 0 ? "" : - "Map Data ©" + new Date().getFullYear() + " " + - myCopyrights.join(", ") + " - "; - var center = this.map.getCenter(); - center && center.transform( - this.map.getProjectionObject(), - new OpenLayers.Projection("EPSG:4326") - ); - var size = this.map.getSize(); - this.attribution = OpenLayers.String.format(this.attributionTemplate, { - t: this.mapTypes[this.type], - zoom: this.map.getZoom(), - center: center.lat + "," + center.lon, - mapType: this.type, - mapData: mapData - }); - this.map && this.map.events.triggerEvent("changelayer", { - layer: this, - property: "attribution" - }); - }, - - /** - * Method: setMap - */ - setMap: function() { - OpenLayers.Layer.XYZ.prototype.setMap.apply(this, arguments); - this.events.register("moveend", this, - OpenLayers.Layer.GoogleNG.loadCopyrights - ); - }, - - /** - * Method: removeMap - */ - removeMap: function() { - OpenLayers.Layer.XYZ.prototype.removeMap.apply(this, arguments); - this.events.unregister("moveend", this, - OpenLayers.Layer.GoogleNG.loadCopyrights - ); - }, - - /** - * APIMethod: clone - * - * Parameters: - * obj - {Object} - * - * Returns: - * {} An exact clone of this - * - */ - clone: function(obj) { - if (obj == null) { - obj = new OpenLayers.Layer.GoogleNG(this.options); - } - //get all additions from superclasses - obj = OpenLayers.Layer.XYZ.prototype.clone.apply(this, [obj]); - // copy/set any non-init, non-simple values here - return obj; - }, - - CLASS_NAME: "OpenLayers.Layer.GoogleNG" -}); - -/** - * Property: mapObject - * {google.maps.Map} Shared GMaps instance - will be set upon instantiation of - * the 1st GoogleNG layer - */ -OpenLayers.Layer.GoogleNG.mapObject = null; - -/** - * Function: loadCopyrights - * Using the Google Maps Copyright Service mode (see - * http://mapki.com/wiki/Google_Map_Parameters#Misc) to get the attribution for - * the current map extent. Will be called by each GoogleNG layer instance on - * moveend. - */ -OpenLayers.Layer.GoogleNG.loadCopyrights = function() { - var me = OpenLayers.Layer.GoogleNG.loadCopyrights; - if (me.numLoadingScripts == undefined) { - me.loadingScripts = []; - me.numLoadingScripts = 0; - me.copyrights = {"m": [], "k": [], "h": [], "p": []}; - - // store window scope functions before overwriting them - me.origGAddCopyright = window.GAddCopyright; - me.origGVerify = window.GVerify; - me.origGAppFeatures = window.GAppFeatures; - - // defining window scope functions called by the script that the - // Copyright Service returns - window.GAddCopyright = function() { - var copyright = arguments[7]; - var category = me.copyrights[arguments[0]]; - if (OpenLayers.Util.indexOf(category, copyright) == -1) { - copyright && category.push(copyright); - } - }; - window.GVerify = OpenLayers.Function.True; - window.GAppFeatures = OpenLayers.Function.bind(function() { - me.numLoadingScripts--; - if (me.numLoadingScripts == 0) { - var script; - for (var i=me.loadingScripts.length-1; i>=0; --i) { - script = me.loadingScripts[i][0]; - me.loadingScripts[i][1].updateAttribution(me.copyrights); - script.parentNode.removeChild(script); - } - - // restore original functions - window.GAddCopyright = me.origGAddCopyright; - delete me.origGAddCopyright; - window.GVerify = me.origGVerify; - delete me.origGVerify; - window.GAppFeatures = me.origGAppFeatures; - delete me.origGAppFeatures; - - delete me.loadingScripts; - delete me.numLoadingScripts; - delete me.copyrights; - } - }, this); - } - var mapProj = this.map.getProjectionObject(); - var llProj = new OpenLayers.Projection("EPSG:4326"); - var center = this.map.getCenter().transform(mapProj, llProj); - var extent = this.map.getExtent().transform(mapProj, llProj); - var params = { - spn: extent.getHeight() + "," + extent.getWidth(), - z: this.map.getZoom(), - t: this.mapTypes[this.type], - vp: center.lat + "," + center.lon - }; - var url = "http://maps.google.com/maps?" + - OpenLayers.Util.getParameterString(params); - var script = document.createElement("script"); - script.type = "text/javascript"; - script.src = url; - me.numLoadingScripts++; - me.loadingScripts.push([script, this]); - document.getElementsByTagName("head")[0].appendChild(script); -}; - diff --git a/lib/OpenLayers/Tile/Google.js b/lib/OpenLayers/Tile/Google.js deleted file mode 100644 index b96f2d0f04..0000000000 --- a/lib/OpenLayers/Tile/Google.js +++ /dev/null @@ -1,154 +0,0 @@ -/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for - * full list of contributors). Published under the Clear BSD license. - * See http://svn.openlayers.org/trunk/openlayers/license.txt for the - * full text of the license. */ - - -/** - * @requires OpenLayers/BaseTypes/Class.js - * @requires OpenLayers/Util.js - * @requires OpenLayers/Tile.js - */ - -/* - * Class: OpenLayers.Tile.Google - * Instances of OpenLayers.Tile.Google are used to manage the tiles created - * by google.maps.MapType (see - * http://code.google.com/apis/maps/documentation/javascript/reference.html#MapType). - * - * Inherits from: - * - - */ -OpenLayers.Tile.Google = OpenLayers.Class(OpenLayers.Tile, { - - /** - * Property: node - * {DOMElement} The tile node from the MapType's getTile method - */ - node: null, - - /** - * Constructor: OpenLayers.Tile.Google - * Constructor for a new instance. - * - * Parameters: - * layer - {} layer that the tile will go in. - * position - {} - * bounds - {} - * options - {Object} - */ - initialize: function(layer, position, bounds, options) { - OpenLayers.Tile.prototype.initialize.apply(this, [ - layer, position, bounds, null, null, options - ]); - }, - - /** - * APIMethod: destroy - * Nullify references to prevent circular references and memory leaks. - */ - destroy:function() { - this.node && this.clear(); - this.node = null; - OpenLayers.Tile.prototype.destroy.apply(this, arguments); - }, - - /** - * Method: clone - * - * Parameters: - * obj - {} The tile to be cloned - * - * Returns: - * {} An exact clone of this - */ - clone: function (obj) { - if (obj == null) { - obj = new OpenLayers.Tile.Google(this.layer, - this.position, - this.bounds); - } - - // catch any randomly tagged-on properties - OpenLayers.Util.applyDefaults(obj, this); - - obj.node = null; - - return obj; - }, - - /** - * Method: draw - * Check that a tile should be drawn, and draw it. - * - * Returns: - * {Boolean} Always returns true. - */ - draw: function() { - var layerType = OpenLayers.Layer.GoogleNG.mapObject.mapTypes[ - this.layer.type - ]; - if (layerType && OpenLayers.Tile.prototype.draw.apply(this, arguments)) { - var xyz = this.layer.getXYZ(this.bounds); - var point = new google.maps.Point(xyz.x, xyz.y); - - // The hybrid tile consists of two images. For some reason, we have - // to make sure that the satellite image loads first, otherwise we - // occasionally get blank tiles for one of the two images. This is - // done by requesting the tile for just the satellite mapType - // first, before requesting the hybrid one. - //TODO revisit this - it may be a temporary issue with GMaps - var tempTile; - if (this.layer.type === google.maps.MapTypeId.HYBRID) { - tempTile = layerType.getTile(point, xyz.z, document); - } - - this.node = layerType.getTile(point, xyz.z, document); - - this.isLoading = true; - this.events.triggerEvent("loadstart"); - - this.layer.div.appendChild(this.node); - - // We only modify what we need to - we expect the size to be set - // by getTile, and we have a test that will fail if this changes. - OpenLayers.Util.modifyDOMElement( - this.node, null, this.position, null, "absolute" - ); - - // The images inside the node returned from getTile seem to be - // preloaded already, so registering onload events on these images - // won't work. Instead, we trigger the loadend event immediately - // in the next cycle. - window.setTimeout(OpenLayers.Function.bind(function() { - this.isLoading = false; - // check for this.events - we may be destroyed already - this.events && this.events.triggerEvent("loadend"); - - // see hybrid tile issue above - //TODO revisit this - it may be a temporary issue with GMaps - if (tempTile) { - layerType.releaseTile(tempTile); - } - }, this), 0); - } - return true; - }, - - /** - * Method: clear - * Clear the tile of any bounds/position-related data so that it can - * be reused in a new location. To be implemented by subclasses. - */ - clear: function() { - if (this.node) { - this.node.parentNode && - this.node.parentNode.removeChild(this.node); - OpenLayers.Layer.GoogleNG.mapObject.mapTypes[ - this.layer.type - ].releaseTile(this.node); - } - }, - - CLASS_NAME: "OpenLayers.Tile.Google" -}); diff --git a/tests/Layer/GoogleNG.html b/tests/Layer/GoogleNG.html deleted file mode 100644 index 6a864d4f90..0000000000 --- a/tests/Layer/GoogleNG.html +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - -
-
- - diff --git a/tests/Tile/Google.html b/tests/Tile/Google.html deleted file mode 100644 index e1710847ba..0000000000 --- a/tests/Tile/Google.html +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - -
- - \ No newline at end of file diff --git a/tests/list-tests.html b/tests/list-tests.html index fdadcfb8db..b5d052093f 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -153,7 +153,6 @@
  • Layer/GML.html
  • Layer/Google.html
  • Layer/Google/v3.html
  • -
  • Layer/GoogleNG.html
  • Layer/Grid.html
  • Layer/HTTPRequest.html
  • Layer/Image.html
  • @@ -224,7 +223,6 @@
  • Symbolizer/Raster.html
  • Symbolizer/Text.html
  • Tile.html
  • -
  • Tile/Google.html
  • Tile/Image.html
  • Tile/BackBufferable.html
  • Tile/Image/IFrame.html