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:
@@ -13,7 +13,10 @@
|
||||
var map;
|
||||
|
||||
function init() {
|
||||
map = new OpenLayers.Map('map');
|
||||
map = new OpenLayers.Map('map',
|
||||
{controls: [new OpenLayers.Control.Navigation(),
|
||||
new OpenLayers.Control.PanZoomBar()],
|
||||
numZoomLevels: 10 });
|
||||
var wms = new OpenLayers.Layer.WMS(
|
||||
"OpenLayers WMS",
|
||||
"http://labs.metacarta.com/wms/vmap0",
|
||||
@@ -22,7 +25,6 @@
|
||||
map.addLayers([wms]);
|
||||
|
||||
map.events.register("moveend", null, displayZoom);
|
||||
map.addControl( new OpenLayers.Control.LayerSwitcher() );
|
||||
|
||||
map.zoomToMaxExtent();
|
||||
|
||||
@@ -36,6 +38,7 @@
|
||||
|
||||
function update(input) {
|
||||
map.fractionalZoom = input.checked;
|
||||
map.zoomTo(Math.round(map.zoom));
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@@ -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