Ticket #1288: frac.patch
| File frac.patch, 2.7 kB (added by tschaub, 11 months ago) |
|---|
-
lib/OpenLayers/Control/PanZoomBar.js
old new 241 241 } 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 (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 }, 248 254 … … 314 320 scope: this 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; 320 334 OpenLayers.Event.stop(evt); -
examples/fractional-zoom.html
old new 13 13 var map; 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", 19 22 "http://labs.metacarta.com/wms/vmap0", … … 22 25 map.addLayers([wms]); 23 26 24 27 map.events.register("moveend", null, displayZoom); 25 map.addControl( new OpenLayers.Control.LayerSwitcher() );26 28 27 29 map.zoomToMaxExtent(); 28 30 … … 36 38 37 39 function update(input) { 38 40 map.fractionalZoom = input.checked; 41 map.zoomTo(Math.round(map.zoom)); 39 42 } 40 43 </script> 41 44 </head>
