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
|
Martijn van Oosterhout
|
||||||
David Overstrom
|
David Overstrom
|
||||||
Corey Puffault
|
Corey Puffault
|
||||||
|
Peter William Robins
|
||||||
Gregers Rygg
|
Gregers Rygg
|
||||||
Tim Schaub
|
Tim Schaub
|
||||||
Christopher Schmidt
|
Christopher Schmidt
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<title>OpenLayers Google Layer Example</title>
|
<title>OpenLayers Google Layer Example</title>
|
||||||
<link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
|
<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" />
|
<link rel="stylesheet" href="style.css" type="text/css" />
|
||||||
<!-- this gmaps key generated for http://openlayers.org/dev/ -->
|
<!-- 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>
|
<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="map" class="smallmap"></div>
|
||||||
|
|
||||||
<div id="docs">
|
<div id="docs">
|
||||||
|
<p>
|
||||||
For best performance, you must be using a version of the Google Maps
|
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,
|
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
|
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>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -84,6 +84,18 @@ OpenLayers.Layer.Google = OpenLayers.Class(
|
|||||||
*/
|
*/
|
||||||
dragObject: null,
|
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
|
* Constructor: OpenLayers.Layer.Google
|
||||||
*
|
*
|
||||||
@@ -122,22 +134,32 @@ OpenLayers.Layer.Google = OpenLayers.Class(
|
|||||||
this.dragPanMapObject = null;
|
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
|
this.poweredBy = this.div.lastChild;
|
||||||
// thanks a *mil* Erik for thinking of this
|
this.div.removeChild(this.poweredBy);
|
||||||
var termsOfUse = this.div.lastChild;
|
if (this.isFixed) {
|
||||||
this.div.removeChild(termsOfUse);
|
this.map.viewPortDiv.appendChild(this.poweredBy);
|
||||||
this.pane.appendChild(termsOfUse);
|
} else {
|
||||||
termsOfUse.className = "olLayerGoogleCopyright";
|
this.map.layerContainerDiv.appendChild(this.poweredBy);
|
||||||
termsOfUse.style.right = "";
|
}
|
||||||
termsOfUse.style.bottom = "";
|
this.poweredBy.style.zIndex = "1100";
|
||||||
|
this.poweredBy.style.display = this.div.style.display;
|
||||||
var poweredBy = this.div.lastChild;
|
this.poweredBy.style.right = "";
|
||||||
this.div.removeChild(poweredBy);
|
this.poweredBy.style.bottom = "";
|
||||||
this.pane.appendChild(poweredBy);
|
this.poweredBy.className = "olLayerGooglePoweredBy gmnoprint";
|
||||||
poweredBy.className = "olLayerGooglePoweredBy gmnoprint";
|
|
||||||
poweredBy.style.left = "";
|
|
||||||
poweredBy.style.bottom = "";
|
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
OpenLayers.Console.error(e);
|
OpenLayers.Console.error(e);
|
||||||
@@ -219,6 +241,27 @@ OpenLayers.Layer.Google = OpenLayers.Class(
|
|||||||
display: function(display) {
|
display: function(display) {
|
||||||
OpenLayers.Layer.EventPane.prototype.display.apply(this, arguments);
|
OpenLayers.Layer.EventPane.prototype.display.apply(this, arguments);
|
||||||
this.checkResize();
|
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);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
.olLayerGoogleCopyright {
|
||||||
|
right: 3px;
|
||||||
|
bottom: 2px;
|
||||||
|
}
|
||||||
|
.olLayerGooglePoweredBy {
|
||||||
|
left: 2px;
|
||||||
|
bottom: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user