Committing change for #328 . This will allow us to clone layers after they have been
added to a map, using the resolutions/scales/etc. that were originally set, and also keeping ahold of all the new options set on the layer since we created it, like isBaseLayer, to correspond to behavior of Size.clone and the like. git-svn-id: http://svn.openlayers.org/trunk/openlayers@1662 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -33,18 +33,23 @@
|
||||
}
|
||||
|
||||
function test_02_Layer_clone (t) {
|
||||
t.plan( 6 );
|
||||
t.plan( 8 );
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var options = { chicken: 151, foo: "bar" };
|
||||
var mapone = new OpenLayers.Map('map');
|
||||
var options = { chicken: 151, foo: "bar", maxResolution: "auto" };
|
||||
var layer = new OpenLayers.Layer('Test Layer', options);
|
||||
map.addLayer(layer);
|
||||
mapone.addLayer(layer);
|
||||
|
||||
// randomly assigned property
|
||||
layer.chocolate = 5;
|
||||
|
||||
var clone = layer.clone();
|
||||
|
||||
t.ok( clone.map == null, "cloned layer has map property set to null")
|
||||
|
||||
var maptwo = new OpenLayers.Map('map2');
|
||||
maptwo.addLayer(clone);
|
||||
|
||||
t.ok( clone instanceof OpenLayers.Layer, "new OpenLayers.Layer returns object" );
|
||||
t.eq( clone.name, "Test Layer", "default clone.name is correct" );
|
||||
t.ok( ((clone.options["chicken"] == 151) && (clone.options["foo"] == "bar")), "clone.options correctly set" );
|
||||
@@ -53,8 +58,8 @@
|
||||
layer.addOptions({chicken:152});
|
||||
t.eq(clone.options["chicken"], 151, "made a clean copy of options");
|
||||
|
||||
|
||||
t.ok( clone.map == null, "cloned layer has map property set to null")
|
||||
t.ok( (layer.maxResolution != clone.maxResolution), "maxresolution of clone reset to new map div");
|
||||
t.ok( (layer.minResolution != clone.minResolution), "minresolution of clone reset to new map div");
|
||||
|
||||
}
|
||||
|
||||
@@ -174,6 +179,7 @@
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
<div id="map" style="width:500px;height:500px"></div>
|
||||
<div id="map2" style="width:100px;height:100px"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user