[OpenLayers-Users] PanZoomBar miscalculating zoom after dragging to
extent
Rohan Parkes
rohan.parkes at pelicancorp.com
Wed Mar 2 20:20:13 EST 2011
I have a map of Singapore using an ArcGIS93Rest layer in EPSG:3414.
The map has 9 zoom levels defined by resolutions [76.4372195411057,
38.2186097705529,
19.1093048852764,
9.55465244263822,
4.77732622131911,
2.38866311065955,
1.19433155532978,
0.597165777664889,
0.298450596901194];
It start up at zoom level 5.
The problem is that the PanZoomBar control, while drawn correctly, generates
the wrong zoom level if dragged to either extent - it should range between 0
and 8, but often calculates the zoom as -1 to 10. Consequently, if you drag
to either extreme, nothing happens. Dragging anywhere else on the zoom bar
generally seems OK.
The problem doesn't seem to occur if you zoom by clicking on the zoom bar.
In the zoomBarUp handler, the code that calculates the zoom is:
var deltaY = this.zoomStart.y - evt.xy.y;
var zoomLevel = this.map.zoom;
zoomLevel += Math.round(deltaY / this.zoomStopHeight);
this.map.zoomTo(zoomLevel);
The problem is that deltaY / this.zoomStopHeight is generating values that
are too large when you zoom to an extent.
I haven't modified the controls or graphics in the control. I'm only viewing
the map in FF 3.6 and IE 8.
For the moment, I've hacked the code to correct the zoom levels if they go
out-of-range. But I'd prefer to find out why this is happening.
Rohan Parkes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110303/d3382ef7/attachment.html
More information about the Users
mailing list