Zoom level restriction improvements #524

Merged
merged 4 commits into from Jun 22, 2012

Projects

None yet

2 participants

@ahocevar
OpenLayers member

There are currently two issues with the zoom level restriction that applies to the map when its base layer is configured with wrapDateLine: true:

  • The PanZoomBar shows zoom steps that are not available.
  • The zoom level restriction does not respect the map's fractionalZoom setting.

This pull request is intended to fix these issues.

For the PanZoomBar, we need a redraw every time the map resizes, to adjust to a changed zoom level restriction. I added a new "updatesize" map event and a getMinZoom method to make this possible. The new event and method are also useful for zoom sliders that are created outside OpenLayers, e.g. the GeoExt ZoomSlider.

To respect the fractionalZoom setting of the map, the adjustZoom method needs to handle two cases - if fractionalZoom is set to true, getZoomForResolution can be used to get the fracitonal zoom level at which the map width matches the world width.

The pull request also adds unit tests. Tests pass in Safari5. Thanks for any review.

ahocevar added some commits Jun 12, 2012
@ahocevar ahocevar Respect zoom level restriction. 1d680df
@ahocevar ahocevar Create a new reliable updatesize event.
The resize event is not fired in all browsers. What we actually need is an event that is called every time the updateSize method is called.
7141d23
@ahocevar ahocevar Adding a getMinZoom API method.
This can be used by zoom slider controls, e.g. the GeoExt.ZoomSlider. Note that adjustZoom now also respects the map's fractionalZoom setting.
032df4b
@ahocevar ahocevar Adding unit tests. fe31af5
@bartvde
OpenLayers member

Excellent work @ahocevar, please merge.

@ahocevar ahocevar merged commit 78d07c8 into openlayers:master Jun 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment