Changeset 6112
- Timestamp:
- 02/08/08 11:38:19 (1 year ago)
- Files:
-
- sandbox/pagameba/transition-resize/examples/animated_panning.html (copied) (copied from trunk/openlayers/examples/animated_panning.html)
- sandbox/pagameba/transition-resize/lib/OpenLayers/Control/OverviewMap.js (modified) (1 diff)
- sandbox/pagameba/transition-resize/lib/OpenLayers/Map.js (modified) (6 diffs)
- sandbox/pagameba/transition-resize/tests/Control/test_OverviewMap.html (modified) (4 diffs)
- sandbox/pagameba/transition-resize/tests/Control/test_PanZoom.html (modified) (8 diffs)
- sandbox/pagameba/transition-resize/tests/Control/test_Permalink.html (modified) (6 diffs)
- sandbox/pagameba/transition-resize/tests/Layer/test_Grid.html (modified) (1 diff)
- sandbox/pagameba/transition-resize/tests/Layer/test_KaMap.html (modified) (1 diff)
- sandbox/pagameba/transition-resize/tests/test_Map.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/pagameba/transition-resize/lib/OpenLayers/Control/OverviewMap.js
r6107 r6112 512 512 updateMapToRect: function() { 513 513 var lonLatBounds = this.getMapBoundsFromRectBounds(this.rectPxBounds); 514 this.map. setCenter(lonLatBounds.getCenterLonLat(), this.map.zoom);514 this.map.panTo(lonLatBounds.getCenterLonLat()); 515 515 }, 516 516 sandbox/pagameba/transition-resize/lib/OpenLayers/Map.js
r6107 r6112 374 374 // Note that this is ok, as updateSize() does nothing if the 375 375 // map's size has not actually changed. 376 this.updateSizeDestroy = OpenLayers.Function.bind(this.updateSize, 377 this); 376 378 OpenLayers.Event.observe(window, 'resize', 377 OpenLayers.Function.bind(this.updateSize, this));379 this.updateSizeDestroy); 378 380 } 379 381 … … 435 437 */ 436 438 unloadDestroy: null, 439 440 /** 441 * Method: updateSizeDestroy 442 * When the map is destroyed, we need to stop listening to updateSize 443 * events: this method stores the function we need to unregister in 444 * non-IE browsers. 445 */ 446 updateSizeDestroy: null, 437 447 438 448 /** … … 449 459 OpenLayers.Event.stopObserving(window, 'unload', this.unloadDestroy); 450 460 this.unloadDestroy = null; 461 462 if (this.updateSizeDestroy) { 463 OpenLayers.Event.stopObserving(window, 'resize', 464 this.updateSizeDestroy); 465 } else { 466 this.events.unregister("resize", this, this.updateSize); 467 } 451 468 452 469 if (this.layers != null) { … … 1230 1247 * dx - {Integer} 1231 1248 * dy - {Integer} 1232 */ 1233 pan: function(dx, dy) { 1234 1249 * options - {Object} Only one at this time: "animate", which uses 1250 * panTo instead of setCenter. Default is true. 1251 */ 1252 pan: function(dx, dy, options) { 1253 1254 if (!options) { 1255 options = {} 1256 } 1235 1257 // getCenter 1236 1258 var centerPx = this.getViewPortPxFromLonLat(this.getCenter()); … … 1242 1264 if (!newCenterPx.equals(centerPx)) { 1243 1265 var newCenterLonLat = this.getLonLatFromViewPortPx(newCenterPx); 1244 this.setCenter(newCenterLonLat); 1266 if (options.animate) { 1267 this.panTo(newCenterLonLat); 1268 } else { 1269 this.setCenter(newCenterLonLat); 1270 } 1245 1271 } 1246 1272 1247 1273 }, 1274 1275 /** 1276 * APIMethod: panTo 1277 * Allows user to pan to a new lonlat 1278 * If the new lonlat is in the current extent the map will slide smoothly 1279 * 1280 * Parameters: 1281 * lonlat - {<OpenLayers.Lonlat>} 1282 */ 1283 panTo: function(lonlat) { 1284 if (this.getExtent().containsLonLat(lonlat)) { 1285 if (!this.panTween) { 1286 this.panTween = new OpenLayers.Tween(OpenLayers.Easing.Expo.easeOut); 1287 } 1288 var center = this.getCenter(); 1289 var from = { 1290 lon: center.lon, 1291 lat: center.lat 1292 }; 1293 var to = { 1294 lon: lonlat.lon, 1295 lat: lonlat.lat 1296 }; 1297 this.panTween.start(from, to, 50, { 1298 callbacks: { 1299 start: OpenLayers.Function.bind(function(lonlat) { 1300 this.events.triggerEvent("movestart"); 1301 }, this), 1302 eachStep: OpenLayers.Function.bind(function(lonlat) { 1303 var lonlat = new OpenLayers.LonLat(lonlat.lon, lonlat.lat); 1304 this.moveTo(lonlat, this.zoom, true); 1305 }, this), 1306 done: OpenLayers.Function.bind(function(lonlat) { 1307 this.events.triggerEvent("moveend"); 1308 }, this) 1309 } 1310 }); 1311 } else { 1312 this.setCenter(lonlat); 1313 } 1314 }, 1248 1315 1249 1316 /** … … 1286 1353 // noEvent is false by default 1287 1354 var noEvent = options.noEvent; 1355 1356 if (this.panTween && options.caller == "setCenter") { 1357 this.panTween.stop(); 1358 } 1288 1359 1289 1360 if (!this.center && !this.isValidLonLat(lonlat)) { sandbox/pagameba/transition-resize/tests/Control/test_OverviewMap.html
r6107 r6112 39 39 var centerLL = new OpenLayers.LonLat(-71,42); 40 40 map.setCenter(centerLL, 11); 41 41 t.delay_call(1, function() { 42 42 var overviewCenter = control.ovmap.getCenter(); 43 43 var overviewZoom = control.ovmap.getZoom(); … … 47 47 48 48 control.mapDivClick({'xy':new OpenLayers.Pixel(5,5)}); 49 49 }, 2, function() { 50 50 var cent = map.getCenter(); 51 51 t.eq(cent.lon, -71.3515625, "Clicking on the Overview Map has the correct effect on map lon"); … … 58 58 control.rectDrag(new OpenLayers.Pixel(15, 15)); 59 59 control.updateMapToRect(); 60 60 }, 2, function() { 61 61 var cent = map.getCenter(); 62 62 t.eq(cent.lon, -71.2734375, "Dragging on the Overview Map has the correct effect on map lon"); … … 69 69 t.eq(overviewCenter.lat, 0, "Overviewmap center lat correct -- second zoom"); 70 70 t.eq(overviewZoom, 0, "Overviewmap zoomcorrect -- second zoom"); 71 72 71 map.destroy(); 73 72 }); 74 73 } 75 74 sandbox/pagameba/transition-resize/tests/Control/test_PanZoom.html
r5822 r6112 62 62 63 63 simulateClick(wnd, wnd.control.buttons[0]); 64 t.ok( wnd.mapper.getCenter().lat > wnd.centerLL.lat, "Pan up works correctly" ); 65 t.ok(!flag.mousedown, "mousedown does not get to the map"); 66 t.ok(flag.mouseup, "mouseup does get to the map"); 67 t.ok(!flag.click, "click does not get to the map"); 68 t.ok(!flag.dblclick, "dblclick does not get to the map"); 69 resetFlags(); 64 t.delay_call(2, function() { 65 t.ok( wnd.mapper.getCenter().lat > wnd.centerLL.lat, "Pan up works correctly" ); 66 t.ok(!flag.mousedown, "mousedown does not get to the map"); 67 t.ok(flag.mouseup, "mouseup does get to the map"); 68 t.ok(!flag.click, "click does not get to the map"); 69 t.ok(!flag.dblclick, "dblclick does not get to the map"); 70 resetFlags(); 70 71 71 simulateClick(wnd, wnd.control.buttons[1]); 72 simulateClick(wnd, wnd.control.buttons[1]); 73 }, 2, function() { 72 74 t.ok( wnd.mapper.getCenter().lon < wnd.centerLL.lon, "Pan left works correctly" ); 73 75 t.ok(!flag.mousedown, "mousedown does not get to the map"); … … 78 80 79 81 simulateClick(wnd, wnd.control.buttons[2]); 82 }, 2, function() { 80 83 t.ok( wnd.mapper.getCenter().lon == wnd.centerLL.lon, "Pan right works correctly" ); 81 84 t.ok(!flag.mousedown, "mousedown does not get to the map"); … … 86 89 87 90 simulateClick(wnd, wnd.control.buttons[3]); 91 }, 2, function() { 88 92 t.ok( wnd.mapper.getCenter().lat == wnd.centerLL.lat, "Pan down works correctly" ); 89 93 t.ok(!flag.mousedown, "mousedown does not get to the map"); … … 94 98 95 99 simulateClick(wnd, wnd.control.buttons[4]); 100 }, 2, function() { 96 101 t.eq( wnd.mapper.getZoom(), 6, "zoomin works correctly" ); 97 102 t.ok(!flag.mousedown, "mousedown does not get to the map"); … … 102 107 103 108 simulateClick(wnd, wnd.control.buttons[6]); 109 }, 2, function() { 104 110 t.eq( wnd.mapper.getZoom(), 5, "zoomout works correctly" ); 105 111 t.ok(!flag.mousedown, "mousedown does not get to the map"); … … 110 116 111 117 simulateClick(wnd, wnd.control.buttons[5]); 118 }, 2, function() { 112 119 t.eq( wnd.mapper.getZoom(), 2, "zoomworld works correctly" ); 113 120 t.ok(!flag.mousedown, "mousedown does not get to the map"); … … 116 123 t.ok(!flag.dblclick, "dblclick does not get to the map"); 117 124 resetFlags(); 118 125 }); 119 126 }); 120 127 }); … … 147 154 148 155 var layer = new OpenLayers.Layer.WMS("Test Layer", 149 "http:// octo.metacarta.com/cgi-bin/mapserv?",150 { map: "/mapdata/vmap_wms.map",layers: "basic"});156 "http://labs.metacarta.com/wms-c/Basic.py?", 157 {layers: "basic"}); 151 158 mapper.addLayer(layer); 152 159 sandbox/pagameba/transition-resize/tests/Control/test_Permalink.html
r4345 r6112 39 39 if (!map.getCenter()) map.zoomToMaxExtent(); 40 40 map.addControl(control); 41 map.pan(5, 0 );41 map.pan(5, 0, {animate:false}); 42 42 t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"?zoom=2&lat=0&lon=1.75781&layers=BT"), 'pan sets permalink'); 43 43 … … 56 56 if (!map.getCenter()) map.zoomToMaxExtent(); 57 57 map.addControl(control); 58 map.pan(5, 0 );58 map.pan(5, 0, {animate:false}); 59 59 OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B'; 60 60 t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base"); … … 77 77 if (!map.getCenter()) map.zoomToMaxExtent(); 78 78 map.addControl(control); 79 map.pan(5, 0 );79 map.pan(5, 0, {animate:false}); 80 80 OpenLayers.Util.getElement('edit_permalink').href = './edit.html?foo=bar&zoom=2&lat=0&lon=1.75781&layers=B'; 81 81 t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and querystring"); … … 83 83 control = new OpenLayers.Control.Permalink('permalink', "./edit.html?foo=bar&" ); 84 84 map.addControl(control); 85 map.pan(0, 0 );85 map.pan(0, 0, {animate:false}); 86 86 t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and querystring ending with '&'"); 87 87 … … 89 89 OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B'; 90 90 map.addControl(control); 91 map.pan(5, 0 );92 map.pan(-5, 0 );91 map.pan(5, 0, {animate:false}); 92 map.pan(-5, 0, {animate:false}); 93 93 t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and querystring ending with '?'"); 94 94 … … 105 105 if (!map.getCenter()) map.zoomToMaxExtent(); 106 106 map.addControl(control); 107 map.pan(5, 0 );107 map.pan(5, 0, {animate:false}); 108 108 OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B'; 109 109 t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with existing zoom in base"); sandbox/pagameba/transition-resize/tests/Layer/test_Grid.html
r5070 r6112 543 543 var bounds = layer.getTileBounds(new OpenLayers.Pixel(200,200)); 544 544 t.eq(bounds.toBBOX(), "-180,-90,0,90", "get tile bounds returns correct bounds"); 545 map.pan(200,0 );545 map.pan(200,0, {animate:false}); 546 546 var bounds = layer.getTileBounds(new OpenLayers.Pixel(200,200)); 547 547 t.eq(bounds.toBBOX(), "0,-90,180,90", "get tile bounds returns correct bounds after pan"); sandbox/pagameba/transition-resize/tests/Layer/test_KaMap.html
r5822 r6112 246 246 var bounds = layer.getTileBounds(new OpenLayers.Pixel(200,200)); 247 247 t.eq(bounds.toBBOX(), "-180,0,0,180", "get tile bounds returns correct bounds"); 248 map.pan(200,0 );248 map.pan(200,0,{animate:false}); 249 249 var bounds = layer.getTileBounds(new OpenLayers.Pixel(200,200)); 250 250 t.eq(bounds.toBBOX(), "0,0,180,180", "get tile bounds returns correct bounds after pan"); sandbox/pagameba/transition-resize/tests/test_Map.html
r6107 r6112 682 682 map.setBaseLayer(tmsLayer); 683 683 map.zoomIn(); 684 map.pan(0, -200 );684 map.pan(0, -200, {animate:false}); 685 685 map.setBaseLayer(wmsLayer); 686 686 t.eq(map.layerContainerDiv.style.top, "0px", "layerContainer is recentered after setBaseLayer");
