making the layerswitcher a little smarter. Instead of fancy 'noEvent' parameters, we just keep track of the state at each redraw. When asked to redraw, we then check first to see if anything has changed before going ahead with the redraw. Also in this patch, we add a 'visibilitychanged' event to the layer's events object -- upon request by users. (Closes #878)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@4229 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2007-09-12 04:00:31 +00:00
parent 7a37ed4423
commit 0e8e7ab620
5 changed files with 78 additions and 16 deletions

View File

@@ -65,7 +65,7 @@
function test_04_Control_LayerSwitcher_redraw (t) {
t.plan( 8 );
t.plan( 12 );
map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.WMS("WMS",
@@ -92,6 +92,16 @@
t.eq(markersInput.name, markers.name, "wms correctly named");
t.eq(markersInput.value, markers.name, "wms correctly valued");
t.eq(false, control.checkRedraw(), "check redraw is false");
control = new OpenLayers.Control.LayerSwitcher();
control.redraw = function() {
t.ok(true, "redraw called when setting vis");
}
map.addControl(control);
markers.setVisibility(false);
t.eq(control.checkRedraw(), true, "check redraw is true after changing layer and not letting redraw happen.");
}
function test_05_Control_LayerSwitcher_ascendingw (t) {

View File

@@ -118,7 +118,7 @@
function test_05_Layer_visibility(t) {
t.plan(5)
t.plan(7);
var layer = new OpenLayers.Layer('Test Layer');
@@ -140,6 +140,10 @@
layermoved = false;
layer.moveTo = function() { layermoved = true; }
layer.events.register('visibilitychanged', t, function() {
this.ok(true, "Visibility changed calls layer event.");
});
layer.setVisibility(false);
t.eq(layermoved, false, "Layer didn't move when calling setvis false");