[OpenLayers-Commits] r3041 - in trunk/openlayers: lib/OpenLayers tests
commits at openlayers.org
commits at openlayers.org
Tue Apr 10 06:30:53 EDT 2007
Author: crschmidt
Date: 2007-04-10 06:30:49 -0400 (Tue, 10 Apr 2007)
New Revision: 3041
Modified:
trunk/openlayers/lib/OpenLayers/Layer.js
trunk/openlayers/tests/test_Layer.html
Log:
Commit Fix for #654: Layer should not redraw on setVisibility(false). For
some layers, this is a significant performance enhancement. Includes regression
tests.
Modified: trunk/openlayers/lib/OpenLayers/Layer.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer.js 2007-04-10 10:19:13 UTC (rev 3040)
+++ trunk/openlayers/lib/OpenLayers/Layer.js 2007-04-10 10:30:49 UTC (rev 3041)
@@ -347,7 +347,7 @@
if (visibility != this.visibility) {
this.visibility = visibility;
this.display(visibility);
- if (this.map != null) {
+ if (visibility && this.map != null) {
var extent = this.map.getExtent();
if (extent != null) {
this.moveTo(extent, true);
Modified: trunk/openlayers/tests/test_Layer.html
===================================================================
--- trunk/openlayers/tests/test_Layer.html 2007-04-10 10:19:13 UTC (rev 3040)
+++ trunk/openlayers/tests/test_Layer.html 2007-04-10 10:30:49 UTC (rev 3041)
@@ -118,7 +118,7 @@
function test_05_Layer_visibility(t) {
- t.plan(3)
+ t.plan(5)
var layer = new OpenLayers.Layer('Test Layer');
@@ -129,6 +129,22 @@
layer.setVisibility(true);
t.eq(layer.getVisibility(), true, "setVisibility true works");
+
+ // Need a map in order to have moveTo called.
+ // Tests added for #654.
+ var layer = new OpenLayers.Layer.WMS('Test Layer','http://example.com');
+ var m = new OpenLayers.Map('map');
+ m.addLayer(layer);
+ m.zoomToMaxExtent();
+
+ layermoved = false;
+ layer.moveTo = function() { layermoved = true; }
+
+ layer.setVisibility(false);
+ t.eq(layermoved, false, "Layer didn't move when calling setvis false");
+
+ layer.setVisibility(true);
+ t.eq(layermoved, true, "Layer moved when calling setvis true.");
}
More information about the Commits
mailing list