Changeset 66
- Timestamp:
- 05/16/06 19:46:41 (3 years ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Map.js (modified) (7 diffs)
- trunk/openlayers/tests/test_Map.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Map.js
r65 r66 242 242 } 243 243 this.center = latlon.copyOf(); 244 var zoomChanged = false;245 if (zoom != null ) {246 if (this.zoom && zoom != this.zoom)247 zoomChanged = true;244 var zoomChanged = null; 245 if (zoom != null && zoom != this.zoom 246 && zoom >= 0 && zoom <= this.getZoomLevels()) { 247 zoomChanged = (this.zoom == null ? 0 : this.zoom); 248 248 this.zoom = zoom; 249 249 } … … 255 255 256 256 moveToNewExtent: function (zoomChanged) { 257 if (zoomChanged ) { // reset the layerContainerDiv's location257 if (zoomChanged != null) { // reset the layerContainerDiv's location 258 258 this.layerContainerDiv.style.left = "0px"; 259 259 this.layerContainerDiv.style.top = "0px"; … … 261 261 var bounds = this.getExtent(); 262 262 for (var i = 0; i < this.layers.length; i++) { 263 this.layers[i].moveTo(bounds, zoomChanged);263 this.layers[i].moveTo(bounds, (zoomChanged != null)); 264 264 } 265 265 this.events.triggerEvent("move"); 266 if (zoomChanged) 267 this.events.triggerEvent("zoomend"); 266 if (zoomChanged != null) 267 this.events.triggerEvent("zoomend", 268 {oldZoom: zoomChanged, newZoom: this.zoom}); 268 269 }, 269 270 … … 287 288 var oldZoom = this.zoom; 288 289 this.zoom = zoom; 289 this.moveToNewExtent(true); 290 this.events.triggerEvent("zoomend", {oldZoom: oldZoom, newZoom: this.zoom}); 290 this.moveToNewExtent(oldZoom); 291 291 } 292 292 }, … … 304 304 zoomExtent: function() { 305 305 var fullExtent = this.getFullExtent(); 306 306 var oldZoom = this.zoom; 307 307 this.zoom = this.getZoomForExtent( fullExtent ); 308 308 this.setCenter( … … 312 312 ) 313 313 ); 314 this.moveToNewExtent(true);315 316 314 }, 317 315 … … 338 336 defaultDblClick: function (evt) { 339 337 var newCenter = this.getLatLonFromPixel( evt.xy ); 340 this.zoomIn(); 341 this.setCenter(newCenter); 338 this.setCenter(newCenter, this.zoom + 1); 342 339 }, 343 340 trunk/openlayers/tests/test_Map.html
r64 r66 55 55 } 56 56 function test_05_Map_center(t) { 57 t.plan( 5);57 t.plan(4); 58 58 map = new OpenLayers.Map($('map')); 59 59 map.setCenter(new OpenLayers.LatLon(1,2), 0); 60 60 map.zoomIn(); 61 t.ok( map.getCenter() instanceof OpenLayers.LatLon, "map.getCenter returns a LatLon");62 61 t.eq( map.getZoom(), 1, "map.zoom is correct after calling setCenter,zoom in"); 63 62 t.eq( map.getCenter().lat, 1, "map center lat is correct after calling setCenter,zoom in"); … … 65 64 map.zoomOut(); 66 65 t.eq( map.getZoom(), 0, "map.zoom is correct after calling setCenter,zoom in, zoom out"); 66 } 67 function test_06_Map_zoomend_event (t) { 68 t.plan(3); 69 map = new OpenLayers.Map('map'); 70 map.events.register("zoomend", {count: 0}, function() { 71 this.count++; 72 t.ok(true, "zoomend event was triggered " + this.count + " times"); 73 }); 74 map.setCenter(new OpenLayers.LatLon(1,2), 0); 75 map.zoomIn(); 76 map.zoomOut(); 67 77 } 68 78 function test_99_Map_destroy (t) {
