Changeset 6331
- Timestamp:
- 02/20/08 18:44:34 (6 months ago)
- Files:
-
- trunk/openlayers/examples/fractional-zoom.html (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Control/PanZoomBar.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/examples/fractional-zoom.html
r6145 r6331 14 14 15 15 function init() { 16 map = new OpenLayers.Map('map'); 16 map = new OpenLayers.Map('map', 17 {controls: [new OpenLayers.Control.Navigation(), 18 new OpenLayers.Control.PanZoomBar()], 19 numZoomLevels: 10 }); 17 20 var wms = new OpenLayers.Layer.WMS( 18 21 "OpenLayers WMS", … … 23 26 24 27 map.events.register("moveend", null, displayZoom); 25 map.addControl( new OpenLayers.Control.LayerSwitcher() );26 28 27 29 map.zoomToMaxExtent(); … … 37 39 function update(input) { 38 40 map.fractionalZoom = input.checked; 41 map.zoomTo(Math.round(map.zoom)); 39 42 } 40 43 </script> trunk/openlayers/lib/OpenLayers/Control/PanZoomBar.js
r6149 r6331 242 242 var y = evt.xy.y; 243 243 var top = OpenLayers.Util.pagePosition(evt.object)[1]; 244 var levels = Math.floor((y - top)/this.zoomStopHeight); 245 this.map.zoomTo((this.map.getNumZoomLevels() -1) - levels); 244 var levels = (y - top)/this.zoomStopHeight; 245 var zoom = (this.map.getNumZoomLevels() - 1) - levels; 246 if(this.map.fractionalZoom) { 247 zoom = Math.min(Math.max(zoom, 0), this.map.getNumZoomLevels() - 1); 248 } else { 249 zoom = Math.floor(zoom); 250 } 251 this.map.zoomTo(zoom); 246 252 OpenLayers.Event.stop(evt); 247 253 }, … … 315 321 }); 316 322 var deltaY = this.zoomStart.y - evt.xy.y; 317 this.map.zoomTo(this.map.zoom + Math.round(deltaY/this.zoomStopHeight)); 323 var zoomLevel = this.map.zoom; 324 if (this.map.fractionalZoom) { 325 zoomLevel += deltaY/this.zoomStopHeight; 326 zoomLevel = Math.min(Math.max(zoomLevel, 0), 327 this.map.getNumZoomLevels() - 1); 328 } else { 329 zoomLevel += Math.round(deltaY/this.zoomStopHeight); 330 } 331 this.map.zoomTo(zoomLevel); 318 332 this.moveZoomBar(); 319 333 this.mouseDragStart = null;
