Implemented activate, deactivate and destroy methods; use autoActivate option with a default of true. p=jorix,r=me (closes #2567)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10510 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -21,6 +21,42 @@
|
||||
"graticule has features");
|
||||
control.destroy();
|
||||
}
|
||||
|
||||
function test_activate(t) {
|
||||
t.plan(7);
|
||||
var map = new OpenLayers.Map("map",{projection:"EPSG:4326"});
|
||||
var layer = new OpenLayers.Layer.WMS();
|
||||
map.addLayers([layer]);
|
||||
|
||||
var control = new OpenLayers.Control.Graticule({});
|
||||
map.addControl(control);
|
||||
map.zoomToMaxExtent();
|
||||
|
||||
t.ok(control.gratLayer.visibility, "Graticule layer is visible by default");
|
||||
control.deactivate();
|
||||
t.ok(control.gratLayer.map == null,
|
||||
"Graticule layer is not in map when control is deactivated");
|
||||
control.destroy();
|
||||
|
||||
var control2 = new OpenLayers.Control.Graticule({autoActivate:false});
|
||||
map.addControl(control2);
|
||||
t.ok(control2.gratLayer.map == null,
|
||||
"Graticule layer is not in map when autoActivate:false");
|
||||
t.ok(control2.gratLayer.features.length == 0,
|
||||
"Graticule layer is empty when autoActivate:false");
|
||||
control2.activate();
|
||||
t.ok(control2.gratLayer.map != null,
|
||||
"Graticule layer is on map when control is activated");
|
||||
t.ok(control2.gratLayer.features.length > 0,
|
||||
"Graticule features refreshed after control is activated");
|
||||
control2.gratLayer.setVisibility(false);
|
||||
|
||||
control2.destroy();
|
||||
t.ok(control2.gratLayer == null,
|
||||
"Graticule layer is destroyed when control is destroyed");
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
Reference in New Issue
Block a user