2.6 accidentally broke behavior when clicking on the panzoombar. Thanks to Linda Rawson's report of this issue, this is now fixed, by moving the Math.floor call to a different part of the code. r=euzuro (Pullup #1486)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@6799 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -242,12 +242,11 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
var y = evt.xy.y;
|
||||
var top = OpenLayers.Util.pagePosition(evt.object)[1];
|
||||
var levels = (y - top)/this.zoomStopHeight;
|
||||
var zoom = (this.map.getNumZoomLevels() - 1) - levels;
|
||||
if(this.map.fractionalZoom) {
|
||||
zoom = Math.min(Math.max(zoom, 0), this.map.getNumZoomLevels() - 1);
|
||||
} else {
|
||||
zoom = Math.floor(zoom);
|
||||
if(!this.map.fractionalZoom) {
|
||||
levels = Math.floor(levels);
|
||||
}
|
||||
var zoom = (this.map.getNumZoomLevels() - 1) - levels;
|
||||
zoom = Math.min(Math.max(zoom, 0), this.map.getNumZoomLevels() - 1);
|
||||
this.map.zoomTo(zoom);
|
||||
OpenLayers.Event.stop(evt);
|
||||
},
|
||||
|
||||
@@ -33,6 +33,23 @@
|
||||
map.addControl(control2, new OpenLayers.Pixel(100,100));
|
||||
t.eq( control2.div.style.top, "100px", "2nd control div is located correctly");
|
||||
}
|
||||
function test_Control_PanZoomBar_divClick (t) {
|
||||
t.plan(2);
|
||||
map = new OpenLayers.Map('map', {controls:[]});
|
||||
var layer = new OpenLayers.Layer.WMS("Test Layer",
|
||||
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||
{map: "/mapdata/vmap_wms.map", layers: "basic"});
|
||||
map.addLayer(layer);
|
||||
control = new OpenLayers.Control.PanZoomBar();
|
||||
map.addControl(control);
|
||||
control.divClick({'xy': {'x': 0, 'y': 50}, which: 1});
|
||||
t.eq(map.zoom, 11, "zoom is correct on standard map");
|
||||
|
||||
map.fractionalZoom = true;
|
||||
control.divClick({'xy': {'x': 0, 'y': 49}, which: 1});
|
||||
t.eq(map.zoom.toFixed(3), '10.545', "zoom is correct on fractional zoom map");
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
Reference in New Issue
Block a user