Ticket #1486: panzoombarfix.patch
| File panzoombarfix.patch, 2.1 kB (added by crschmidt, 9 months ago) |
|---|
-
tests/Control/PanZoomBar.html
old new 33 33 map.addControl(control2, new OpenLayers.Pixel(100,100)); 34 34 t.eq( control2.div.style.top, "100px", "2nd control div is located correctly"); 35 35 } 36 function test_Control_PanZoomBar_divClick (t) { 37 t.plan(2); 38 map = new OpenLayers.Map('map', {controls:[]}); 39 var layer = new OpenLayers.Layer.WMS("Test Layer", 40 "http://octo.metacarta.com/cgi-bin/mapserv?", 41 {map: "/mapdata/vmap_wms.map", layers: "basic"}); 42 map.addLayer(layer); 43 control = new OpenLayers.Control.PanZoomBar(); 44 map.addControl(control); 45 control.divClick({'xy': {'x': 0, 'y': 50}, which: 1}); 46 t.eq(map.zoom, 11, "zoom is correct on standard map"); 36 47 48 map.fractionalZoom = true; 49 control.divClick({'xy': {'x': 0, 'y': 49}, which: 1}); 50 t.eq(map.zoom.toFixed(3), '10.545', "zoom is correct on fractional zoom map"); 51 52 } 53 37 54 </script> 38 55 </head> 39 56 <body> -
lib/OpenLayers/Control/PanZoomBar.js
old new 241 241 } 242 242 var y = evt.xy.y; 243 243 var top = OpenLayers.Util.pagePosition(evt.object)[1]; 244 var levels = (y - top)/this.zoomStopHeight;245 var zoom = (this.map.getNumZoomLevels() - 1) - levels;246 244 if(this.map.fractionalZoom) { 247 zoom = Math.min(Math.max(zoom, 0), this.map.getNumZoomLevels() - 1);245 var levels = (y - top)/this.zoomStopHeight; 248 246 } else { 249 zoom = Math.floor(zoom);247 var levels = Math.floor((y - top)/this.zoomStopHeight); 250 248 } 249 var zoom = (this.map.getNumZoomLevels() - 1) - levels; 250 zoom = Math.min(Math.max(zoom, 0), this.map.getNumZoomLevels() - 1); 251 251 this.map.zoomTo(zoom); 252 252 OpenLayers.Event.stop(evt); 253 253 },
