[OpenLayers-Commits] r11482 - in trunk/openlayers:
lib/OpenLayers/Layer tests tests/Layer
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Fri Feb 25 07:02:33 EST 2011
Author: erilem
Date: 2011-02-25 04:02:29 -0800 (Fri, 25 Feb 2011)
New Revision: 11482
Modified:
trunk/openlayers/lib/OpenLayers/Layer/Grid.js
trunk/openlayers/tests/Layer/Grid.html
trunk/openlayers/tests/Map.html
Log:
the grid layer needs to clear its tile loading timeout when it's removed from the map, or moveGriddedTiles can be called with this.map set to null, r=crschmidt (closes #3110)
Modified: trunk/openlayers/lib/OpenLayers/Layer/Grid.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/Grid.js 2011-02-25 11:50:30 UTC (rev 11481)
+++ trunk/openlayers/lib/OpenLayers/Layer/Grid.js 2011-02-25 12:02:29 UTC (rev 11482)
@@ -132,6 +132,20 @@
},
/**
+ * Method: removeMap
+ * Called when the layer is removed from the map.
+ *
+ * Parameters:
+ * map - {<OpenLayers.Map>} The map.
+ */
+ removeMap: function(map) {
+ if(this.timerId != null) {
+ window.clearTimeout(this.timerId);
+ this.timerId = null;
+ }
+ },
+
+ /**
* APIMethod: destroy
* Deconstruct the layer and clear the grid.
*/
Modified: trunk/openlayers/tests/Layer/Grid.html
===================================================================
--- trunk/openlayers/tests/Layer/Grid.html 2011-02-25 11:50:30 UTC (rev 11481)
+++ trunk/openlayers/tests/Layer/Grid.html 2011-02-25 12:02:29 UTC (rev 11482)
@@ -593,7 +593,7 @@
function test_Layer_Grid_destroy (t) {
- t.plan( 7 );
+ t.plan( 8 );
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.Grid(name, url, params);
@@ -608,6 +608,7 @@
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0), 10);
+ map.setCenter(new OpenLayers.LonLat(1,1));
//grab a reference to one of the tiles
@@ -616,6 +617,7 @@
layer.destroy();
t.eq( tile.imgDiv, null, "Tile destroyed" );
+ t.eq( layer.timerId, null, "Tile loading timeout cleared");
t.ok( layer.grid == null, "tiles appropriately destroyed")
Modified: trunk/openlayers/tests/Map.html
===================================================================
--- trunk/openlayers/tests/Map.html 2011-02-25 11:50:30 UTC (rev 11481)
+++ trunk/openlayers/tests/Map.html 2011-02-25 12:02:29 UTC (rev 11482)
@@ -352,6 +352,8 @@
valid = OpenLayers.Map.prototype.isValidZoomLevel.apply(map, [19]);
t.eq(valid, false, "19 is not a valid zoomLevel when baseLayer has restrictedMinZoom of 1");
+
+ map.destroy();
}
function test_Map_isValidLonLat(t) {
@@ -977,6 +979,8 @@
map.addControls(controls2, pixels2);
t.eq(map.controls.length, 5, "three additional controls were added by map.addControls with a px-array");
t.eq(map.controls[3].position.toString(), pixels2[1].toString(), "control 'fourthctrl' has position set to given px");
+
+ map.destroy();
}
function test_Map_getControl(t) {
@@ -1598,6 +1602,8 @@
t.eq(map.layers.length, 2, "multiple layers added from options");
t.ok(map.baseLayer, "map has a base layer");
+
+ map.destroy();
}
More information about the Commits
mailing list