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:
@@ -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
|
* Method: loadMapObject
|
||||||
* Load the GMap and register appropriate event listeners. If we can't
|
* 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
|
* deletes the mapObject reference before removing this layer from
|
||||||
* the map.
|
* the map.
|
||||||
*/
|
*/
|
||||||
this.setGMapVisibility(false);
|
if (this.map) {
|
||||||
var cache = OpenLayers.Layer.Google.cache[this.map.id];
|
this.setGMapVisibility(false);
|
||||||
if (cache && cache.count <= 1) {
|
var cache = OpenLayers.Layer.Google.cache[this.map.id];
|
||||||
this.removeGMapElements(false);
|
if (cache && cache.count <= 1) {
|
||||||
|
this.removeGMapElements(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
OpenLayers.Layer.EventPane.prototype.destroy.apply(this, arguments);
|
OpenLayers.Layer.EventPane.prototype.destroy.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -40,6 +40,29 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_clone(t) {
|
||||||
|
if (validkey) {
|
||||||
|
t.plan(2);
|
||||||
|
var layer, clone;
|
||||||
|
|
||||||
|
// test default layer
|
||||||
|
layer = new OpenLayers.Layer.Google();
|
||||||
|
clone = layer.clone();
|
||||||
|
t.ok(clone instanceof OpenLayers.Layer.Google, "[default] good instance");
|
||||||
|
|
||||||
|
layer.destroy();
|
||||||
|
clone.destroy();
|
||||||
|
|
||||||
|
// test with alt type
|
||||||
|
layer = new OpenLayers.Layer.Google(null, {type: G_SATELLITE_MAP});
|
||||||
|
clone = layer.clone();
|
||||||
|
t.ok(clone.type === G_SATELLITE_MAP, "[sat] correct type");
|
||||||
|
|
||||||
|
layer.destroy();
|
||||||
|
clone.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function test_Layer_Google_isBaseLayer (t) {
|
function test_Layer_Google_isBaseLayer (t) {
|
||||||
if(validkey) {
|
if(validkey) {
|
||||||
t.plan(1);
|
t.plan(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user