Ticket #1032: resolution.patch
| File resolution.patch, 2.7 kB (added by tschaub, 1 year ago) |
|---|
-
lib/OpenLayers/Map.js
old new 110 110 center: null, 111 111 112 112 /** 113 * Property: resolution 114 * {Float} The resolution of the map. 115 */ 116 resolution: null, 117 118 /** 113 119 * Property: zoom 114 120 * {Integer} The current zoom level of the map 115 121 */ … … 703 709 if (center != null) { 704 710 if (oldExtent == null) { 705 711 // simply set center but force zoom change 706 this.setCenter(center, this.getZoom(), false, true); 712 this.setCenter( 713 center, 714 this.getZoomForResolution(this.resolution), 715 false, true 716 ); 707 717 } else { 708 718 // zoom to oldExtent *and* force zoom change 709 719 this.setCenter(oldExtent.getCenterLonLat(), … … 1121 1131 1122 1132 if (zoomChanged) { 1123 1133 this.zoom = zoom; 1134 this.resolution = this.baseLayer.getResolution(); 1124 1135 // zoom level has changed, increment viewRequestID. 1125 1136 this.viewRequestID++; 1126 1137 } -
tests/test_Map.html
old new 277 277 t.ok(map.baseLayer == wmslayer2, "setbaselayer correctly sets 'baseLayer' property"); 278 278 } 279 279 280 function test_Map_removeLayer_res(t) { 281 t.plan(2); 282 283 map = new OpenLayers.Map('map'); 284 285 var layer0 = new OpenLayers.Layer.WMS( 286 'Test Layer 0', 287 "http://octo.metacarta.com/cgi-bin/mapserv", 288 {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'}, 289 {resolutions: [4, 2, 1]} 290 ); 291 292 var layer1 = new OpenLayers.Layer.WMS( 293 'Test Layer 1', 294 "http://octo.metacarta.com/cgi-bin/mapserv", 295 {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'}, 296 {resolutions: [4, 2]} 297 ); 298 299 map.addLayers([layer0, layer1]); 300 map.zoomToMaxExtent(); 301 map.zoomTo(2); 302 t.eq(map.getResolution(), layer0.resolutions[2], 303 "correct resolution before removal"); 304 map.removeLayer(layer0); 305 t.eq(map.getResolution(), layer0.resolutions[1], 306 "correct resolution after removal"); 307 } 308 280 309 function test_13_Map_setBaseLayer_after_pan (t) { 281 310 t.plan(1); 282 311
