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:
crschmidt
2009-04-12 16:05:19 +00:00
parent 29a23731ab
commit da3a4b272a
4 changed files with 74 additions and 16 deletions
+58 -15
View File
@@ -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);
},
/**