Changeset 2846
- Timestamp:
- 03/22/07 10:11:40 (2 years ago)
- Files:
-
- sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/OverviewMap.js (modified) (1 diff)
- sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/PanZoomBar.js (modified) (2 diffs)
- sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer.js (modified) (3 diffs)
- sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer/Image.js (modified) (1 diff)
- sandbox/emanuel/animatedZooming/lib/OpenLayers/Map.js (modified) (3 diffs)
- sandbox/emanuel/animatedZooming/lib/OpenLayers/Util.js (modified) (2 diffs)
- sandbox/emanuel/animatedZooming/tests/Control/test_KeyboardDefaults.html (added)
- sandbox/emanuel/animatedZooming/tests/Control/test_MouseDefaults.html (added)
- sandbox/emanuel/animatedZooming/tests/Control/test_OverviewMap.html (modified) (5 diffs)
- sandbox/emanuel/animatedZooming/tests/Control/test_PanZoom.html (modified) (1 diff)
- sandbox/emanuel/animatedZooming/tests/Control/test_PanZoomBar.html (modified) (3 diffs)
- sandbox/emanuel/animatedZooming/tests/Control/test_Scale.html (modified) (2 diffs)
- sandbox/emanuel/animatedZooming/tests/Layer/test_Grid.html (modified) (9 diffs)
- sandbox/emanuel/animatedZooming/tests/Layer/test_Image.html (modified) (4 diffs)
- sandbox/emanuel/animatedZooming/tests/Layer/test_WMS.html (modified) (7 diffs)
- sandbox/emanuel/animatedZooming/tests/Layer/test_WMS_Untiled.html (added)
- sandbox/emanuel/animatedZooming/tests/list-tests.html (modified) (3 diffs)
- sandbox/emanuel/animatedZooming/tests/test_Layer.html (modified) (1 diff)
- sandbox/emanuel/animatedZooming/tests/test_Map.html (modified) (3 diffs)
- sandbox/emanuel/animatedZooming/tests/test_Util.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/OverviewMap.js
r2827 r2846 353 353 this.createMap(); 354 354 } 355 355 356 if(!this.isSuitableOverview()) { 356 357 this.updateOverview(); 357 358 } 359 360 // update extent rectangle 358 361 this.updateRectToMap(); 359 this.updateOverview(); 362 363 this.updateOverview(); 360 364 }, 361 365 /** sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/PanZoomBar.js
r2635 r2846 150 150 */ 151 151 divClick: function (evt) { 152 if (!OpenLayers.Event.isLeftClick(evt)) return;152 //if (!OpenLayers.Event.isLeftClick(evt)) return; 153 153 var y = evt.xy.y; 154 154 var top = OpenLayers.Util.pagePosition(evt.object)[1]; 155 155 var levels = Math.floor((y - top)/this.zoomStopHeight); 156 156 157 157 if (!this.map.zoomanimationActive) 158 158 this.map.zoomTo((this.map.getNumZoomLevels() -1) - levels); … … 217 217 this.map.events.unregister("mouseup", this, this.passEventToSlider); 218 218 this.map.events.unregister("mousemove", this, this.passEventToSlider); 219 var deltaY = this.map.zoomStart.y - evt.xy.y 220 219 var deltaY = this.map.zoomStart.y - evt.xy.y; 220 221 221 // zoom map to new zoomlevel 222 222 var finalZoomlevel = this.map.zoom + Math.round(deltaY/this.zoomStopHeight); sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer.js
r2827 r2846 850 850 /** 851 851 * The actual clone function: 852 * Freeze current map while tiles of viewport are loading.852 * Hold scaled map while tiles are loading successive. 853 853 * 854 854 * special function; shares with some baselayers; calls from subclasses … … 876 876 this.map.baseLayerDivClone.style.zIndex--; 877 877 878 // 4. set original div invisible during the tiles are loading 879 //this.map.layerContainerDiv.style.display= "none"; 880 881 // 5. set zoomOut tile (of original div) invisible 878 // 4. set zoomOut tile (of original div) invisible 882 879 if (this.map.baseLayer.zoomOutTile) 883 880 this.map.baseLayer.zoomOutTile.imgDiv.style.display = "none"; … … 911 908 } 912 909 } 913 914 910 // set flag that zoom animation finished 915 911 this.map.zoomanimationActive = false; sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer/Image.js
r2635 r2846 135 135 this.tile.position = ulPx.clone(); 136 136 } 137 138 // fire loadstart event139 this.events.triggerEvent("loadstart");140 this.doneLoading = false;141 142 137 this.tile.draw(); 143 144 var onload = function() {145 this.doneLoading = true;146 this.events.triggerEvent("loadend");147 }148 149 OpenLayers.Event.observe(this.tile.imgDiv, 'load',150 onload.bindAsEventListener(this));151 138 } 152 139 }, sandbox/emanuel/animatedZooming/lib/OpenLayers/Map.js
r2827 r2846 939 939 }; 940 940 var move = function() { 941 var dx = OpenLayers.Util.easeInOut (this.slideX,941 var dx = OpenLayers.Util.easeInOutPan(this.slideX, 942 942 this.totalSteps, 943 943 this.step, 944 944 this.power); 945 var dy = OpenLayers.Util.easeInOut (this.slideY,945 var dy = OpenLayers.Util.easeInOutPan(this.slideY, 946 946 this.totalSteps, 947 947 this.step, … … 1402 1402 1403 1403 // set zoomanimation flag to false _manually_ 1404 // (only for image baselayer, because there is no onimageload event);1404 // (only for baselayers without onimageload events, f.e. imagelayer); 1405 1405 // for all other layers it calls automatically from 1406 1406 // loadendevent in layers.js 1407 if ( !this.baseLayer.CLASS_NAME.match("OpenLayers.Layer.WMS")){1407 if (this.baseLayer.CLASS_NAME.match("OpenLayers.Layer.Image")){ 1408 1408 this.zoomanimationActive = false; 1409 1409 } … … 1428 1428 this.zoomlevel_scale = 0; 1429 1429 } 1430 if (this.zoomlevel_scale > (this.getNumZoomLevels()- 1)) {1430 if (this.zoomlevel_scale > (this.getNumZoomLevels()- 1)) { 1431 1431 this.zoomlevel_scale = this.getNumZoomLevels() - 1; 1432 1432 } sandbox/emanuel/animatedZooming/lib/OpenLayers/Util.js
r2827 r2846 973 973 * @param {float} power 974 974 * 975 * @returns The delta to the next position in the animation movement975 * @returns The delta to the next position in the pan animation movement 976 976 * @type int 977 977 */ 978 OpenLayers.Util.easeInOut = function(delta, totalSteps, step, power) {978 OpenLayers.Util.easeInOutPan = function(delta, totalSteps, step, power) { 979 979 var prevStepVal = Math.pow(((1/totalSteps)*(step-1)),power) * delta; 980 980 var stepVal = Math.pow(((1/totalSteps)*step),power) * delta; … … 991 991 * @param {float} power 992 992 * 993 * @returns The delta to the next position in theanimation movement993 * @returns The next zoomlevel in the zoom animation movement 994 994 * @type float 995 995 */ 996 996 OpenLayers.Util.easeInOutZoom = function(delta, totalSteps, step, power) { 997 var prevStepVal = Math.pow(((1/totalSteps)*(step-1)),power) * delta;998 997 var stepVal = Math.pow(((1/totalSteps)*step),power) * delta; 999 998 return stepVal; sandbox/emanuel/animatedZooming/tests/Control/test_OverviewMap.html
r2827 r2846 4 4 <script type="text/javascript"><!-- 5 5 var map; 6 function test_01_Control_ PanZoom_constructor (t) {6 function test_01_Control_OverviewMap_constructor (t) { 7 7 t.plan( 1 ); 8 8 … … 10 10 t.ok( control instanceof OpenLayers.Control.OverviewMap, "new OpenLayers.Control.OverviewMap returns object" ); 11 11 } 12 function test_02_Control_ PanZoom_addControl (t) {12 function test_02_Control_OverviewMap_addControl (t) { 13 13 t.plan( 6 ); 14 14 map = new OpenLayers.Map('map'); … … 23 23 24 24 } 25 function test_03_Control_ PanZoom_control_events (t) {25 function test_03_Control_OverviewMap_control_events (t) { 26 26 t.plan( 10 ); 27 27 var evt = {which: 1}; // control expects left-click … … 45 45 46 46 control.mapDivDblClick({'xy':new OpenLayers.Pixel(5,5)}); 47 t.delay_call( 1, function() { 48 var cent = map.getCenter(); 49 t.eq(cent.lon, -71.3515625, "Clicking on the Overview Map has the correct effect on map lon"); 50 t.eq(cent.lat, 42.17578125, "Clicking on the Overview Map has the correct effect on map lat"); 47 t.delay_call( 48 1, function() { 49 var cent = map.getCenter(); 50 t.eq(cent.lon, -71.3515625, "Clicking on the Overview Map has the correct effect on map lon"); 51 t.eq(cent.lat, 42.17578125, "Clicking on the Overview Map has the correct effect on map lat"); 51 52 52 control.rectMouseDown({'xy':new OpenLayers.Pixel(5,5), 'which':1}); 53 control.rectMouseMove({'xy':new OpenLayers.Pixel(15,15), 'which':1}); 54 control.rectMouseUp({'xy':new OpenLayers.Pixel(15,15), 'which':1}); 55 56 t.delay_call( 1, function() { 53 control.rectMouseDown({'xy':new OpenLayers.Pixel(5,5), 'which':1}); 54 control.rectMouseMove({'xy':new OpenLayers.Pixel(15,15), 'which':1}); 55 control.rectMouseUp({'xy':new OpenLayers.Pixel(15,15), 'which':1}); 56 }, 57 58 1, function() { 57 59 var cent = map.getCenter(); 58 60 t.eq(cent.lon, -71.27328491210938, "Dragging on the Overview Map has the correct effect on map lon"); … … 65 67 t.eq(overviewCenter.lat, 0, "Overviewmap center lat correct -- second zoom"); 66 68 t.eq(overviewZoom, 0, "Overviewmap zoomcorrect -- second zoom"); 67 }); 68 }); 69 } 70 ); 71 } 69 72 73 function test_04_Control_OverviewMap_updateRectToMap (t) { 74 t.plan( 4 ); 75 76 map = new OpenLayers.Map('map'); 77 var layer = new OpenLayers.Layer.WMS("Test Layer", 78 "http://octo.metacarta.com/cgi-bin/mapserv?", 79 {map: "/mapdata/vmap_wms.map", layers: "basic"}); 80 map.addLayer(layer); 81 82 control = new OpenLayers.Control.OverviewMap(); 83 map.addControl(control, new OpenLayers.Pixel(20,20)); 84 map.setCenter(new OpenLayers.LonLat(0,0), 5); 85 control.updateRectToMap(); 86 t.eq(control.extentRectangle.style.left, "45px", "rectangle left position has been set correctly"); 87 t.eq(control.extentRectangle.style.top, "23px", "rectangle top position has been set correctly"); 88 t.eq(control.extentRectangle.style.width, "90px", "rectangle width position has been set correctly"); 89 t.eq(control.extentRectangle.style.height, "45px", "rectangle height position has been set correctly"); 90 } 91 92 function test_05_Control_OverviewMap_updateMapToRect (t) { 93 t.plan( 4 ); 94 95 map = new OpenLayers.Map('map'); 96 var layer = new OpenLayers.Layer.WMS("Test Layer", 97 "http://octo.metacarta.com/cgi-bin/mapserv?", 98 {map: "/mapdata/vmap_wms.map", layers: "basic"}); 99 map.addLayer(layer); 100 101 control = new OpenLayers.Control.OverviewMap(); 102 map.addControl(control, new OpenLayers.Pixel(20,20)); 103 map.setCenter(new OpenLayers.LonLat(0,0), 5); 104 control.updateRectToMap(); 105 t.eq(control.extentRectangle.style.left, "45px", "rectangle left position has been set correctly"); 106 t.eq(control.extentRectangle.style.top, "23px", "rectangle top position has been set correctly"); 107 t.eq(control.extentRectangle.style.width, "90px", "rectangle width position has been set correctly"); 108 t.eq(control.extentRectangle.style.height, "45px", "rectangle height position has been set correctly"); 70 109 } 71 110 // --> sandbox/emanuel/animatedZooming/tests/Control/test_PanZoom.html
r2827 r2846 43 43 44 44 control.buttons[0].onmousedown(evt); 45 t.delay_call( 1, function() { 46 t.ok( map.getCenter().lat > centerLL.lat, "Pan up works correctly" ); 47 48 control.buttons[1].onmousedown(evt); 49 t.delay_call( 1, function() { 50 t.ok( map.getCenter().lon < centerLL.lon, "Pan left works correctly" ); 51 52 control.buttons[2].onmousedown(evt); 53 t.delay_call( 1, function() { 54 t.ok( map.getCenter().lon == centerLL.lon, "Pan right works correctly" ); 55 56 control.buttons[3].onmousedown(evt); 57 t.delay_call( 1, function() { 45 t.delay_call( 46 1, function() { 47 t.ok( map.getCenter().lat > centerLL.lat, "Pan up works correctly" ); 48 control.buttons[1].onmousedown(evt); 49 }, 50 51 1, function() { 52 t.ok( map.getCenter().lon < centerLL.lon, "Pan left works correctly" ); 53 control.buttons[2].onmousedown(evt); 54 }, 55 56 1, function() { 57 t.ok( map.getCenter().lon == centerLL.lon, "Pan right works correctly" ); 58 control.buttons[3].onmousedown(evt); 59 }, 60 61 1, function() { 58 62 t.ok( map.getCenter().lat == centerLL.lat, "Pan down works correctly" ); 59 60 63 control.buttons[4].onmousedown(evt); 61 t.delay_call( 1, function() { 62 t.eq( map.getZoom(), 6, "zoomin works correctly" ); 63 64 // set zoomanimation flag manually, 65 // reason: loadend event in layers.js will not achieved in unittests 66 map.zoomanimationActive = false; 67 control.buttons[6].onmousedown(evt); 68 t.delay_call( 1, function() { 69 t.eq( map.getZoom(), 5, "zoomout works correctly" ); 70 71 control.buttons[5].onmousedown(evt); 72 t.delay_call( 1, function() { 73 t.eq( map.getZoom(), 2, "zoomworld works correctly" ); 74 }); 75 }); 76 }); 77 }); 78 }); 79 }); 80 }); 64 }, 65 66 1, function() { 67 t.eq( map.getZoom(), 6, "zoomin works correctly" ); 68 // set zoomanimation flag manually, 69 // reason: loadend event in layers.js will not achieved in unittests 70 map.zoomanimationActive = false; 71 control.buttons[6].onmousedown(evt); 72 }, 73 74 1, function() { 75 t.eq( map.getZoom(), 5, "zoomout works correctly" ); 76 control.buttons[5].onmousedown(evt); 77 }, 78 79 1, function() { 80 t.eq( map.getZoom(), 2, "zoomworld works correctly" ); 81 } 82 ); 81 83 82 84 } sandbox/emanuel/animatedZooming/tests/Control/test_PanZoomBar.html
r2827 r2846 4 4 <script type="text/javascript"><!-- 5 5 var map; 6 var layer; 7 var name = 'Test Layer'; 8 var url = "http://octo.metacarta.com/cgi-bin/mapserv"; 9 var params = { map: '/mapdata/vmap_wms.map', 10 layers: 'basic', 11 format: 'image/png'}; 12 6 13 function test_01_Control_PanZoomBar_constructor (t) { 7 14 t.plan( 1 ); … … 12 19 function test_02_Control_PanZoomBar_addControl (t) { 13 20 t.plan( 8 ); 21 14 22 map = new OpenLayers.Map('map', {controls:[]}); 15 var layer = new OpenLayers.Layer.WMS("Test Layer", 16 "http://octo.metacarta.com/cgi-bin/mapserv?", 17 {map: "/mapdata/vmap_wms.map", layers: "basic"}); 23 layer = new OpenLayers.Layer.WMS(name, url, params); 18 24 map.addLayer(layer); 19 25 control = new OpenLayers.Control.PanZoomBar(); … … 31 37 t.eq( control2.div.style.top, "100px", "2nd control div is located correctly"); 32 38 } 39 40 function test_03_Control_PanZoomBar_control_events (t) { 41 t.plan( 3 ); 42 43 var evt = {which: 1}; // control expects left-click 44 map = new OpenLayers.Map('map'); 45 layer = new OpenLayers.Layer.WMS(name, url, params); 46 map.addLayer(layer); 47 control = new OpenLayers.Control.PanZoomBar(); 48 map.addControl(control); 49 var centerLL = new OpenLayers.LonLat(0,0); 50 map.setCenter(centerLL, 0); 51 52 evt.xy = new OpenLayers.Pixel(10,115); 53 evt.object = control; 54 control.divClick(evt); 55 t.delay_call( 56 1, function() { 57 t.eq(map.zoom, 5, 58 "Clicking on the zoombar has the correct effect on zoomlevel"); 59 60 control.zoomBarDown(evt); 61 evt.xy.y -= 30; 62 control.zoomBarDrag(evt); 63 64 control.zoomBarUp(evt); 65 }, 66 1, function() { 67 t.eq(map.zoom, 8, 68 "Dragging the zoomslider works correctly"); 69 t.eq(control.slider.style.top, "159px", 70 "Zoomslider top position has been set correctly"); 71 } 72 73 ); 74 75 76 77 } 78 33 79 // --> 34 80 </script> sandbox/emanuel/animatedZooming/tests/Control/test_Scale.html
r2827 r2846 19 19 map.addLayer(layer); 20 20 map.zoomTo(0); 21 t.delay_call( 1, function() { 22 map.addControl(control); 23 t.eq(OpenLayers.Util.getElement('scale').innerHTML, "Scale = 1 : 443M", "Scale set by default." ); 24 // set zoomanimation flag manually, 25 // reason: loadend event in layers.js will not achieved in unittests 26 map.zoomanimationActive = false; 27 map.zoomIn(); 28 t.delay_call( 1, function() { 21 t.delay_call( 22 1, function() { 23 map.addControl(control); 24 t.eq(OpenLayers.Util.getElement('scale').innerHTML, "Scale = 1 : 443M", "Scale set by default." ); 25 // set zoomanimation flag manually, 26 // reason: loadend event in layers.js will not achieved in unittests 27 map.zoomanimationActive = false; 28 map.zoomIn(); 29 }, 30 1, function() { 29 31 t.eq(OpenLayers.Util.getElement('scale').innerHTML, "Scale = 1 : 221M", "Zooming in changes scale" ); 30 32 … … 34 36 map.baseLayer.resolutions = [OpenLayers.Util.getResolutionFromScale(110)]; 35 37 map.zoomTo(0,false); 36 t.delay_call( 1, function() {37 t.eq(OpenLayers.Util.getElement('scale').innerHTML, "Scale = 1 : 110", "Scale of 100 isn't rounded" );38 });39 } );40 });38 }, 39 1, function() { 40 t.eq(OpenLayers.Util.getElement('scale').innerHTML, "Scale = 1 : 110", "Scale of 100 isn't rounded" ); 41 } 42 ); 41 43 } 42 44 function test_03_Control_Scale_internalScale (t) { sandbox/emanuel/animatedZooming/tests/Layer/test_Grid.html
r2827 r2846 4 4 <script type="text/javascript"><!-- 5 5 var isMozilla = (navigator.userAgent.indexOf("compatible") == -1); 6 var map; 6 7 var layer; 7 8 8 9 var name = 'Test Layer'; 9 10 var url = "http://octo.metacarta.com/cgi-bin/mapserv"; 10 11 var params = { map: '/mapdata/vmap_wms.map', 11 12 layers: 'basic', 12 format: 'image/png'};13 format: 'image/png'}; 13 14 14 15 /** 15 16 * NOTE TO READER: 16 * 17 * 17 18 * Some of the tests on the Grid class actually use the WMS class. 18 19 * This is because WMS is a subclass of Grid and it implements the … … 33 34 function test_02_Layer_Grid_inittiles (t) { 34 35 t.plan( 2 ); 35 varmap = new OpenLayers.Map('map');36 map = new OpenLayers.Map('map'); 36 37 layer = new OpenLayers.Layer.WMS(name, url, params); 37 38 map.addLayer(layer); … … 44 45 function test_03_Layer_Grid_clearTiles (t) { 45 46 t.plan(1); 46 varmap = new OpenLayers.Map('map');47 map = new OpenLayers.Map('map'); 47 48 layer = new OpenLayers.Layer.WMS(name, url, params); 48 49 map.addLayer(layer); … … 82 83 t.plan( 1 ); 83 84 84 varmap = new OpenLayers.Map('map');85 map = new OpenLayers.Map('map'); 85 86 layer = new OpenLayers.Layer.WMS(name, url, params); 86 87 map.addLayer(layer); … … 95 96 var bounds, zoom; 96 97 97 varmap = new OpenLayers.Map('map');98 map = new OpenLayers.Map('map'); 98 99 layer = new OpenLayers.Layer.WMS(name, url, params); 99 100 map.addLayer(layer); … … 133 134 134 135 var options = {tileSize: new OpenLayers.Size(500,50)}; 135 varmap = new OpenLayers.Map('map', options);136 map = new OpenLayers.Map('map', options); 136 137 layer = new OpenLayers.Layer.Grid(name, url, params); 137 138 map.addLayer(layer); … … 157 158 158 159 function test_11_Layer_Grid_setMap(t) { 159 160 160 t.plan(2); 161 161 162 162 var options = {tileSize: new OpenLayers.Size(500,50)}; 163 varmap = new OpenLayers.Map('map', options);163 map = new OpenLayers.Map('map', options); 164 164 layer = new OpenLayers.Layer.Grid(name, url, params); 165 165 … … 172 172 173 173 174 175 /*** animated zooming test functions ***/ 176 177 function test_12_Layer_Grid_setZoomOutTile (t) { 178 t.plan(5); 179 180 map = new OpenLayers.Map('map'); 181 layer = new OpenLayers.Layer.WMS(name, url, params); 182 map.addLayer(layer); 183 map.tileSize = new OpenLayers.Size(256,256); 184 map.zoomOutTileFactor = 4; 185 var tile = map.baseLayer.zoomOutTile; 186 187 t.ok( tile instanceof OpenLayers.Tile.Image, 188 "zoomOutTile is a Tile.Image object"); 189 190 var firstChild = map.baseLayer.div.firstChild; 191 t.eq( tile.imgDiv.id, firstChild.id, 192 "zoomOutTile is first child of baseLayerDiv"); 193 194 size = map.baseLayer.zoomOutTile.size; 195 t.eq( size.w, 1024, "zoomOutTile width is 1024px"); 196 t.eq( size.h, 1024, "zoomOutTile height is 1024px"); 197 198 t.ok( tile.imgDiv.style.display == "none", 199 "zoomOutTile is invisible"); 200 } 201 202 203 function test_13_Layer_Grid_getTileSize (t) { 204 t.plan(2); 205 206 map = new OpenLayers.Map('map'); 207 layer = new OpenLayers.Layer.WMS(name, url, params); 208 map.addLayer(layer); 209 map.tileSize = new OpenLayers.Size(256,256); 210 211 size = map.baseLayer.getTileSize(); 212 t.eq(size.w, 256, "tile width is correct"); 213 t.eq(size.h, 256, "tile height is correct"); 214 } 215 216 function test_14_Layer_Grid_getCenterTile (t) { 217 t.plan(1); 218 219 map = new OpenLayers.Map('map'); 220 layer = new OpenLayers.Layer.WMS(name, url, params); 221 map.addLayer(layer); 222 map.setCenter(new OpenLayers.LonLat(0,0)); 223 224 tile = map.baseLayer.getCenterTile(); 225 t.ok(tile.bounds.contains(0,0,true), 226 "center tile has been set correctly" ); 227 } 228 229 function test_15_Layer_Grid_setTilesOutsideInvisible (t) { 230 t.plan(1); 231 232 map = new OpenLayers.Map('map'); 233 layer = new OpenLayers.Layer.WMS(name, url, params); 234 map.addLayer(layer); 235 map.setCenter(new OpenLayers.LonLat(0,0)); 236 map.zoomTo(5,false); 237 map.baseLayer.setTilesOutsideInvisible(); 238 239 var tileOutside = map.baseLayer.grid[0][0]; 240 t.ok( tileOutside.imgDiv.style.display == "none", 241 "tiles outside the viewport have been set invisible"); 242 243 } 244 245 function test_16_Layer_Grid_scaleTilesOfGrid (t) { 246 t.plan(4); 247 248 map = new OpenLayers.Map('map'); 249 layer = new OpenLayers.Layer.WMS(name, url, params); 250 map.addLayer(layer); 251 map.setCenter(new OpenLayers.LonLat(0,0)); 252 map.zoomTo(5,false); 253 254 var tile = map.baseLayer.grid[3][2]; 255 var centerTile = map.baseLayer.getCenterTile(); 256 var newTileSize = new OpenLayers.Size(128,128); 257 map.baseLayer.scaleTileTo(centerTile,newTileSize); 258 map.baseLayer.scaleTilesOfGrid(centerTile,newTileSize); 259 260 t.eq( tile.imgDiv.style.width, "128px", 261 "width of tiles has been set correctly"); 262 t.eq( tile.imgDiv.style.height, "128px", 263 "height of tiles has been set correctly"); 264 t.eq( tile.imgDiv.style.top, "147px", 265 "top position of tiles has been set correctly"); 266 t.eq( tile.imgDiv.style.left, "122px", 267 "left position of tiles has been set correctly"); 268 } 269 270 function test_17_Layer_Grid_scaleZoomOutTile (t) { 271 t.plan(5); 272 273 map = new OpenLayers.Map('map'); 274 layer = new OpenLayers.Layer.WMS(name, url, params); 275 map.addLayer(layer); 276 map.setCenter(new OpenLayers.LonLat(0,0)); 277 map.tileSize = new OpenLayers.Size(256,256); 278 map.zoomToMaxExtent(); 279 var tile = map.baseLayer.zoomOutTile; 280 map.baseLayer.scaleZoomOutTile(1,map.maxResolution/2); 281 282 t.eq( tile.imgDiv.style.width, "512px", 283 "width of zoomOutTile has been set correctly"); 284 t.eq( tile.imgDiv.style.height, "512px", 285 "height of zoomOutTile has been set correctly"); 286 t.eq( tile.imgDiv.style.top, "-109px", 287 "top position of zoomOutTile has been set correctly"); 288 t.eq( tile.imgDiv.style.left, "-6px", 289 "left position of zoomOutTile has been set correctly"); 290 t.ok( tile.imgDiv.style.display != "none", 291 "zoomOutTile has been set visible"); 292 } 293 294 function test_18_Layer_Grid_cloneBaseLayerDiv (t) { 295 t.plan(4); 296 297 map = new OpenLayers.Map('map'); 298 layer = new OpenLayers.Layer.WMS(name, url, params); 299 map.addLayer(layer); 300 301 map.baseLayer.cloneBaseLayerDiv(); 302 var cloneDiv = map.baseLayerDivClone; 303 var originDiv = map.baseLayer.div; 304 t.ok( cloneDiv instanceof HTMLDivElement, 305 "cloned baseLayerDiv is a valid HTMLDivElement"); 306 t.eq( cloneDiv.childNodes.length, originDiv.childNodes.length, 307 "cloned baseLayerDiv has the same number of childs"); 308 t.eq( parseInt(cloneDiv.style.zIndex)+1, parseInt(originDiv.style.zIndex), 309 "zIndex has been set correctly"); 310 t.ok( map.baseLayer.zoomOutTile.imgDiv.style.display == "none", 311 "zoomOutTile of original div has been set invisible"); 312 } 313 314 315 174 316 function test_99_Layer_Grid_destroy (t) { 175 317 176 318 t.plan( 3 ); 177 319 178 varmap = new OpenLayers.Map('map');320 map = new OpenLayers.Map('map'); 179 321 layer = new OpenLayers.Layer.Grid(name, url, params); 180 322 map.addLayer(layer); … … 184 326 185 327 186 //test with tile creation328 //test with tile creation 187 329 layer = new OpenLayers.Layer.WMS(name, url, params); 188 330 map.addLayer(layer); sandbox/emanuel/animatedZooming/tests/Layer/test_Image.html
r2827 r2846 39 39 } 40 40 41 function test_ 50_Layer_Image_tileTests (t) {41 function test_02_Layer_Image_tileTests (t) { 42 42 t.plan(4); 43 43 var map = new OpenLayers.Map('map'); … … 66 66 67 67 68 /*** animated zooming test functions ***/ 69 function test_03_Layer_Image_getTileSize (t) { 70 t.plan(2); 71 72 map = new OpenLayers.Map('map'); 73 layer = new OpenLayers.Layer.Image('Test Layer', 74 'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif', 75 new OpenLayers.Bounds(-180, -88.759, 180, 88.759), 76 new OpenLayers.Size(580, 288)); 77 map.addLayer(layer); 78 map.setCenter(new OpenLayers.LonLat(0,0)); 79 80 var size = map.baseLayer.getTileSize(); 81 t.eq(size.w, 580, "tile width is correct"); 82 t.eq(size.h, 288, "tile height is correct"); 83 } 84 function test_04_Layer_Image_getCenterTile (t) { 85 t.plan(1); 86 87 map = new OpenLayers.Map('map'); 88 layer = new OpenLayers.Layer.Image('Test Layer', 89 'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif', 90 new OpenLayers.Bounds(-180, -88.759, 180, 88.759), 91 new OpenLayers.Size(580, 288)); 92 map.addLayer(layer); 93 map.setCenter(new OpenLayers.LonLat(0,0)); 94 95 tile = map.baseLayer.getCenterTile(); 96 t.ok(map.baseLayer.tile == tile, 97 "center tile has been set correctly" ); 98 } 99 function test_05_Layer_Image_cloneBaseLayerDiv (t) { 100 t.plan(3); 101 102 map = new OpenLayers.Map('map'); 103 layer = new OpenLayers.Layer.Image('Test Layer', 104 'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif', 105 new OpenLayers.Bounds(-180, -88.759, 180, 88.759), 106 new OpenLayers.Size(580, 288)); 107 map.addLayer(layer); 108 109 map.baseLayer.cloneBaseLayerDiv(); 110 var cloneDiv = map.baseLayerDivClone; 111 var originDiv = map.baseLayer.div; 112 t.ok( cloneDiv instanceof HTMLDivElement, 113 "cloned baseLayerDiv is a valid HTMLDivElement"); 114 t.eq( cloneDiv.childNodes.length, originDiv.childNodes.length, 115 "cloned baseLayerDiv has the same number of childs"); 116 t.eq( parseInt(cloneDiv.style.zIndex)+1, parseInt(originDiv.style.zIndex), 117 "zIndex has been set correctly"); 118 } 119 68 120 function test_99_Layer_Image_destroy (t) { 69 121 t.plan( 4 ); … … 72 124 73 125 layer = new OpenLayers.Layer.Image('Test Layer', 74 'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif',75 new OpenLayers.Bounds(-180, -88.759, 180, 88.759),76 new OpenLayers.Size(580, 288));126 'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif', 127 new OpenLayers.Bounds(-180, -88.759, 180, 88.759), 128 new OpenLayers.Size(580, 288)); 77 129 78 130 map.addLayer(layer); … … 92 144 <body> 93 145 <div id="map" style="width:500px;height:500px"></div> 94 <div id="map2" style="width:100px;height:100px"></div>95 146 </body> 96 147 </html> sandbox/emanuel/animatedZooming/tests/Layer/test_WMS.html
r2827 r2846 27 27 } 28 28 29 function test_02_Layer_WMS_addtile (t) { 29 function test_03_Layer_WMS_getURL (t) { 30 t.plan( 3 ); 31 32 var url = "http://octo.metacarta.com/cgi-bin/mapserv"; 33 layer = new OpenLayers.Layer.WMS(name, url, params); 34 var map = new OpenLayers.Map('map'); 35 map.addLayer(layer); 36 37 var bounds = new OpenLayers.Bounds(1,2,3,4); 38 var url = map.baseLayer.getURL(bounds); 39 t.eq( url, "http://octo.metacarta.com/cgi-bin/mapserv?MAP=%2Fmapdata%2Fvmap_wms.map&LAYERS=basic&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=1%2C2%2C3%2C4&WIDTH=256&HEIGHT=256", 40 "url has been set correctly"); 41 42 var tileSize = new OpenLayers.Size(512,512); 43 url = map.baseLayer.getURL(bounds,tileSize); 44 t.ok( url.match("WIDTH=512"), 45 "url with custom width has been set correctly"); 46 t.ok( url.match("HEIGHT=512"), 47 "url with custom height has been set correctly"); 48 49 } 50 51 function test_03_Layer_WMS_addtile (t) { 30 52 t.plan( 6 ); 31 53 … … 66 88 } 67 89 68 function test_0 3_Layer_WMS_inittiles (t) {90 function test_04_Layer_WMS_inittiles (t) { 69 91 t.plan( 2 ); 70 92 var map = new OpenLayers.Map('map'); … … 78 100 79 101 80 function test_0 4_Layer_WMS_clone (t) {102 function test_05_Layer_WMS_clone (t) { 81 103 t.plan(4); 82 104 … … 105 127 } 106 128 107 function test_0 5_Layer_WMS_isBaseLayer(t) {129 function test_06_Layer_WMS_isBaseLayer(t) { 108 130 t.plan(3); 109 131 … … 121 143 } 122 144 123 function test_0 6_Layer_WMS_mergeNewParams (t) {145 function test_07_Layer_WMS_mergeNewParams (t) { 124 146 t.plan( 5 ); 125 147 … … 146 168 } 147 169 148 function test_0 7_Layer_WMS_getFullRequestString (t) {170 function test_08_Layer_WMS_getFullRequestString (t) { 149 171 150 172 … … 176 198 } 177 199 178 function test_0 8_Layer_WMS_setOpacity (t) {200 function test_09_Layer_WMS_setOpacity (t) { 179 201 t.plan( 5 ); 180 202 sandbox/emanuel/animatedZooming/tests/list-tests.html
r2827 r2846 1 1 <ul id="testlist"> 2 <li>BaseTypes/test_Bounds.html</li> 2 3 <li>BaseTypes/test_Class.html</li> 4 <li>BaseTypes/test_LonLat.html</li> 3 5 <li>BaseTypes/test_Pixel.html</li> 4 6 <li>BaseTypes/test_Size.html</li> 5 <li>BaseTypes/test_LonLat.html</li>6 <li>BaseTypes/test_Bounds.html</li>7 7 <li>test_Geometry.html</li> 8 <li>Geometry/test_ Point.html</li>9 <li>Geometry/test_ Curve.html</li>10 <li>Geometry/test_LineString.html</li> 8 <li>Geometry/test_Collection.html</li> 9 <li>Geometry/test_LinearRing.html</li> 10 <li>Geometry/test_LineString.html</li> 11 11 <li>Geometry/test_MultiLineString.html</li> 12 <li>Geometry/test_LinearRing.html</li>13 <li>Geometry/test_Collection.html</li>
