Fix for "OL is breaking Google API Terms", patch by pwr, r=me, (Closes #1858)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9272 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -19,6 +19,7 @@ Philip Lindsay
|
||||
Martijn van Oosterhout
|
||||
David Overstrom
|
||||
Corey Puffault
|
||||
Peter William Robins
|
||||
Gregers Rygg
|
||||
Tim Schaub
|
||||
Christopher Schmidt
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<head>
|
||||
<title>OpenLayers Google Layer Example</title>
|
||||
<link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../theme/default/google.css" type="text/css" />
|
||||
<link rel="stylesheet" href="style.css" type="text/css" />
|
||||
<!-- this gmaps key generated for http://openlayers.org/dev/ -->
|
||||
<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
|
||||
@@ -49,10 +50,14 @@
|
||||
<div id="map" class="smallmap"></div>
|
||||
|
||||
<div id="docs">
|
||||
<p>
|
||||
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.</p>
|
||||
<p>
|
||||
In order to position the Google attribution div in the default ocation,
|
||||
you must include the extra theme/default/google.css stylesheet.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -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 - {<OpenLayers.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);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
9
theme/default/google.css
Normal file
9
theme/default/google.css
Normal file
@@ -0,0 +1,9 @@
|
||||
.olLayerGoogleCopyright {
|
||||
right: 3px;
|
||||
bottom: 2px;
|
||||
}
|
||||
.olLayerGooglePoweredBy {
|
||||
left: 2px;
|
||||
bottom: 2px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user