diff --git a/doc/authors.txt b/doc/authors.txt index 5acd35381b..7c1727ed53 100644 --- a/doc/authors.txt +++ b/doc/authors.txt @@ -19,6 +19,7 @@ Philip Lindsay Martijn van Oosterhout David Overstrom Corey Puffault +Peter William Robins Gregers Rygg Tim Schaub Christopher Schmidt diff --git a/examples/google.html b/examples/google.html index d0a5dce7b6..946e1518f2 100644 --- a/examples/google.html +++ b/examples/google.html @@ -2,6 +2,7 @@ OpenLayers Google Layer Example + @@ -49,10 +50,14 @@
+

For best performance, you must be using a version of the Google Maps API which is v2.93 or higher. In order to use this version of the API, it is best to simply set your application to use the string "v=2" in - the request, rather than tying your application to an explicit version. + the request, rather than tying your application to an explicit version.

+

+ In order to position the Google attribution div in the default ocation, + you must include the extra theme/default/google.css stylesheet.

diff --git a/lib/OpenLayers/Layer/Google.js b/lib/OpenLayers/Layer/Google.js index 566d23cb2d..c6bdf4f81a 100644 --- a/lib/OpenLayers/Layer/Google.js +++ b/lib/OpenLayers/Layer/Google.js @@ -84,6 +84,18 @@ OpenLayers.Layer.Google = OpenLayers.Class( */ dragObject: null, + /** + * 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, + /** * Constructor: OpenLayers.Layer.Google * @@ -122,22 +134,32 @@ OpenLayers.Layer.Google = OpenLayers.Class( this.dragPanMapObject = null; } + // move the ToS and branding stuff up to the container div + this.termsOfUse = this.div.lastChild; + this.div.removeChild(this.termsOfUse); + if (this.isFixed) { + this.map.viewPortDiv.appendChild(this.termsOfUse); + } else { + this.map.layerContainerDiv.appendChild(this.termsOfUse); + } + this.termsOfUse.style.zIndex = "1100"; + this.termsOfUse.style.display = this.div.style.display; + this.termsOfUse.style.right = ""; + this.termsOfUse.style.bottom = ""; + this.termsOfUse.className = "olLayerGoogleCopyright"; - // move the ToS and branding stuff up to the pane - // thanks a *mil* Erik for thinking of this - var termsOfUse = this.div.lastChild; - this.div.removeChild(termsOfUse); - this.pane.appendChild(termsOfUse); - termsOfUse.className = "olLayerGoogleCopyright"; - termsOfUse.style.right = ""; - termsOfUse.style.bottom = ""; - - var poweredBy = this.div.lastChild; - this.div.removeChild(poweredBy); - this.pane.appendChild(poweredBy); - poweredBy.className = "olLayerGooglePoweredBy gmnoprint"; - poweredBy.style.left = ""; - poweredBy.style.bottom = ""; + this.poweredBy = this.div.lastChild; + this.div.removeChild(this.poweredBy); + if (this.isFixed) { + this.map.viewPortDiv.appendChild(this.poweredBy); + } else { + this.map.layerContainerDiv.appendChild(this.poweredBy); + } + this.poweredBy.style.zIndex = "1100"; + this.poweredBy.style.display = this.div.style.display; + this.poweredBy.style.right = ""; + this.poweredBy.style.bottom = ""; + this.poweredBy.className = "olLayerGooglePoweredBy gmnoprint"; } catch (e) { OpenLayers.Console.error(e); @@ -219,6 +241,27 @@ OpenLayers.Layer.Google = OpenLayers.Class( display: function(display) { OpenLayers.Layer.EventPane.prototype.display.apply(this, arguments); this.checkResize(); + this.termsOfUse.style.display = this.div.style.display; + this.poweredBy.style.display = this.div.style.display; + }, + + /** + * APIMethod: removeMap + * On being removed from the map, also remove termsOfUse and poweredBy divs + * + * Parameters: + * map - {} + */ + removeMap: function(map) { + if (this.termsOfUse && this.termsOfUse.parentNode) { + this.termsOfUse.parentNode.removeChild(this.termsOfUse); + this.termsOfUse = null; + } + if (this.poweredBy && this.poweredBy.parentNode) { + this.poweredBy.parentNode.removeChild(this.poweredBy); + this.poweredBy = null; + } + OpenLayers.Layer.EventPane.prototype.removeMap.apply(this, arguments); }, /** diff --git a/theme/default/google.css b/theme/default/google.css new file mode 100644 index 0000000000..7f3c369e8d --- /dev/null +++ b/theme/default/google.css @@ -0,0 +1,9 @@ +.olLayerGoogleCopyright { + right: 3px; + bottom: 2px; +} +.olLayerGooglePoweredBy { + left: 2px; + bottom: 2px; +} +