give PanZoomBar control an option to force fixed zoomlevels even if the map has fractionalZoom, patch by marcjansen, r=me, (closes #2288)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9751 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -58,6 +58,13 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
*/
|
||||
zoomWorldIcon: false,
|
||||
|
||||
/**
|
||||
* APIProperty: forceFixedZoomLevel
|
||||
* {Boolean} Force a fixed zoom level even though the map has
|
||||
* fractionalZoom
|
||||
*/
|
||||
forceFixedZoomLevel: false,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.PanZoomBar
|
||||
*/
|
||||
@@ -266,7 +273,7 @@ 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;
|
||||
if(!this.map.fractionalZoom) {
|
||||
if(this.forceFixedZoomLevel || !this.map.fractionalZoom) {
|
||||
levels = Math.floor(levels);
|
||||
}
|
||||
var zoom = (this.map.getNumZoomLevels() - 1) - levels;
|
||||
@@ -344,7 +351,7 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
});
|
||||
var deltaY = this.zoomStart.y - evt.xy.y;
|
||||
var zoomLevel = this.map.zoom;
|
||||
if (this.map.fractionalZoom) {
|
||||
if (!this.forceFixedZoomLevel && this.map.fractionalZoom) {
|
||||
zoomLevel += deltaY/this.zoomStopHeight;
|
||||
zoomLevel = Math.min(Math.max(zoomLevel, 0),
|
||||
this.map.getNumZoomLevels() - 1);
|
||||
|
||||
Reference in New Issue
Block a user