Adding clone method to the Google layer. r=ahocevar (closes #2473)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10081 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2010-02-20 20:14:53 +00:00
parent 2eb866658a
commit 09a858559b
2 changed files with 48 additions and 4 deletions

View File

@@ -117,6 +117,25 @@ OpenLayers.Layer.Google = OpenLayers.Class(
}
},
/**
* Method: clone
* Create a clone of this layer
*
* Returns:
* {<OpenLayers.Layer.Google>} An exact clone of this layer
*/
clone: function() {
/**
* This method isn't intended to be called by a subclass and it
* doesn't call the same method on the superclass. We don't call
* the super's clone because we don't want properties that are set
* on this layer after initialize (i.e. this.mapObject etc.).
*/
return new OpenLayers.Layer.Google(
this.name, this.getOptions()
);
},
/**
* Method: loadMapObject
* Load the GMap and register appropriate event listeners. If we can't
@@ -294,10 +313,12 @@ OpenLayers.Layer.Google = OpenLayers.Class(
* deletes the mapObject reference before removing this layer from
* the map.
*/
this.setGMapVisibility(false);
var cache = OpenLayers.Layer.Google.cache[this.map.id];
if (cache && cache.count <= 1) {
this.removeGMapElements(false);
if (this.map) {
this.setGMapVisibility(false);
var cache = OpenLayers.Layer.Google.cache[this.map.id];
if (cache && cache.count <= 1) {
this.removeGMapElements(false);
}
}
OpenLayers.Layer.EventPane.prototype.destroy.apply(this, arguments);
},