Adding support for fractional zoom to the pan zoom bar. Setting map.fractionalZoom to true allows you to access a continuous range of resolutions with the pan zoom bar. r=crschmidt,me (closes #1288)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@6331 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -241,8 +241,14 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
}
|
||||
var y = evt.xy.y;
|
||||
var top = OpenLayers.Util.pagePosition(evt.object)[1];
|
||||
var levels = Math.floor((y - top)/this.zoomStopHeight);
|
||||
this.map.zoomTo((this.map.getNumZoomLevels() -1) - levels);
|
||||
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);
|
||||
}
|
||||
this.map.zoomTo(zoom);
|
||||
OpenLayers.Event.stop(evt);
|
||||
},
|
||||
|
||||
@@ -314,7 +320,15 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
scope: this
|
||||
});
|
||||
var deltaY = this.zoomStart.y - evt.xy.y;
|
||||
this.map.zoomTo(this.map.zoom + Math.round(deltaY/this.zoomStopHeight));
|
||||
var zoomLevel = this.map.zoom;
|
||||
if (this.map.fractionalZoom) {
|
||||
zoomLevel += deltaY/this.zoomStopHeight;
|
||||
zoomLevel = Math.min(Math.max(zoomLevel, 0),
|
||||
this.map.getNumZoomLevels() - 1);
|
||||
} else {
|
||||
zoomLevel += Math.round(deltaY/this.zoomStopHeight);
|
||||
}
|
||||
this.map.zoomTo(zoomLevel);
|
||||
this.moveZoomBar();
|
||||
this.mouseDragStart = null;
|
||||
OpenLayers.Event.stop(evt);
|
||||
|
||||
Reference in New Issue
Block a user