diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 2615bc7e58..b471c42ef9 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -225,6 +225,7 @@ OpenLayers.Map.prototype = { } this.controls = null; } + this.div.innerHTML = ""; }, /** diff --git a/tests/Control/test_OverviewMap.html b/tests/Control/test_OverviewMap.html index 78467595d8..2a56df03f4 100644 --- a/tests/Control/test_OverviewMap.html +++ b/tests/Control/test_OverviewMap.html @@ -21,6 +21,7 @@ t.eq( parseInt(control.div.style.zIndex), map.Z_INDEX_BASE['Control'] + 4, "Control div zIndexed properly" ); t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 4, "Viewport div contains control div" ); + map.destroy(); } function test_03_Control_PanZoom_control_events (t) { t.plan( 10 ); @@ -64,6 +65,7 @@ t.eq(overviewCenter.lat, 0, "Overviewmap center lat correct -- second zoom"); t.eq(overviewZoom, 0, "Overviewmap zoomcorrect -- second zoom"); + map.destroy(); } // --> diff --git a/tests/Layer/test_WMS.html b/tests/Layer/test_WMS.html index c37066e64f..2d2163e017 100644 --- a/tests/Layer/test_WMS.html +++ b/tests/Layer/test_WMS.html @@ -62,6 +62,7 @@ url + "?" + OpenLayers.Util.getParameterString(tParams), "div first child is correct image object" ); t.eq( tile.position.toString(), "x=5,y=6", "Position of tile is set correctly." ); + map.destroy(); } function test_03_Layer_WMS_inittiles (t) { @@ -72,7 +73,7 @@ map.setCenter(new OpenLayers.LonLat(0,0),5); t.eq( layer.grid.length, 7, "Grid rows is correct." ); t.eq( layer.grid[0].length, 6, "Grid cols is correct." ); - + map.destroy(); } @@ -101,6 +102,7 @@ t.eq( clone.alpha, layer.alpha, "alpha copied correctly"); layer.grid = null; + map.destroy(); } function test_05_Layer_WMS_isBaseLayer(t) { @@ -142,6 +144,7 @@ newParams.CHICKPEAS = 151; t.eq( layer.params.CHICKPEAS, "image/png", "mergeNewParams() makes clean copy of hashtable"); + map.destroy(); } function test_07_Layer_WMS_getFullRequestString (t) { @@ -171,6 +174,7 @@ t.eq(str, tUrl + "?" + OpenLayers.Util.getParameterString(tParams), "getFullRequestString() by default does *not* add SRS value if projection is 'none'"); + map.destroy(); } @@ -196,22 +200,25 @@ tile.draw(); t.eq(parseFloat(tile.imgDiv.style.opacity), 0.6, "Tile opacity is set correctly"); + map.destroy(); } function test_20_Layer_WMS_Reproject (t) { t.plan(5); + var map = new OpenLayers.Map('map'); var layer = new OpenLayers.Layer.Google("Google"); map.addLayer(layer); - layer = new OpenLayers.Layer.WMS(name, url, params, {isBaseLayer: false}); - layer.isBaseLayer=false; - map.addLayer(layer); + wmslayer = new OpenLayers.Layer.WMS(name, url, params, {isBaseLayer: false}); + wmslayer.isBaseLayer=false; + map.addLayer(wmslayer); map.setCenter(new OpenLayers.LonLat(0,0), 5); var tile = layer.grid[0][0]; t.eq( tile.bounds.left, -22.5, "left side matches" ); t.eq( tile.bounds.right, -11.25, "top side matches" ); t.eq( tile.bounds.bottom.toFixed(6), '11.178402', "bottom side matches" ); t.eq( tile.bounds.top.toFixed(6), '21.943046', "top side matches" ); + map.destroy(); var map = new OpenLayers.Map('map'); layer = new OpenLayers.Layer.WMS(name, url, params); @@ -219,6 +226,8 @@ map.setCenter(new OpenLayers.LonLat(0,0), 5); var tile = layer.grid[0][0]; t.ok( tile.bounds.equals(new OpenLayers.Bounds(-33.75, 33.75, -22.5, 45)), "okay"); + + map.destroy(); } function test_99_Layer_WMS_destroy (t) { diff --git a/tests/test_Map.html b/tests/test_Map.html index d4ea0ad89a..5d42f0573e 100644 --- a/tests/test_Map.html +++ b/tests/test_Map.html @@ -318,11 +318,12 @@ function test_99_Map_destroy (t) { - t.plan( 2 ); + t.plan( 3 ); map = new OpenLayers.Map('map'); map.destroy(); t.eq( map.layers, null, "map.layers is null after destroy" ); t.eq( map.controls, null, "map.controls is null after destroy" ); + t.eq( map.div.innerHTML, "", "map's div cleared out"); } // --> diff --git a/tests/test_Marker.html b/tests/test_Marker.html index b6343a41d8..04f9c1b1af 100644 --- a/tests/test_Marker.html +++ b/tests/test_Marker.html @@ -42,7 +42,7 @@ mlayer.addMarker(marker2); t.ok( !marker2.onScreen(), "marker knows it's offscreen" ); - + map.destroy(); } function test_03_Marker_setOpacity(t) { @@ -70,6 +70,7 @@ marker.setOpacity(0.5); t.eq(parseFloat(marker.icon.imageDiv.style.opacity), 0.5, "marker.setOpacity() works"); + map.destroy(); } function test_04_Marker_moveTo(t) { t.plan( 6 ); @@ -101,6 +102,7 @@ marker.moveTo(new OpenLayers.Pixel(0,0)); t.eq(marker.lonlat.lon, map.getExtent().left, "on left edge of map"); t.eq(marker.lonlat.lat, map.getExtent().top, "on top edge of map"); + map.destroy(); }