[OpenLayers-Dev] Bug in the maps zoomTo method since OL 2.13

Andreas Hocevar ahocevar at boundlessgeo.com
Wed Nov 27 04:14:02 PST 2013


With your above example, your zoom level when you call map.getZoom() will
be something between 0 and 5. This is because map.zoomTo() is asynchronous
now, at least when a zoomMethod is configured for the map.

So instead of calling getZoom() directly, you should register for a zoomend
listener and call getZoom() there.

Andreas.


On Wed, Nov 27, 2013 at 11:17 AM, Johannes Weskamm <weskamm at terrestris.de>wrote:

>  Hi,
>
> I think i found a bug in the zoomTo Method of the map, while investigating
> an issue in geoext 2 ( https://github.com/geoext/geoext2/issues/205).
> The problem seems to be introduced since OL 2.13 and is also occuring in
> 2.13.1:
>
> When you zoom the map with the zoomTo Method multiple times in a row, the
> result will be confusing.
> To be exact, it will not be the last zoomValue you have given to the
> method, instead it will become e.g. 0.
>
> Here is the simple code which i used to test the behaviour:
>
> m = map;
> m.zoomTo(1);
> m.zoomTo(2);
> m.zoomTo(3);
> m.zoomTo(4);
> m.zoomTo(5);
> m.getZoom();
>
> The result of the last line should return a value of 5. But since OL 2.13,
> it returns 0 or some other non-correct value.
> I checked this with the official examples of OL 2.12, 2.13 and 2.13.1:
>
>
> http://dev.openlayers.org/releases/OpenLayers-2.12/examples/all-overlays.html
>
> In 2.12, everything works as expected, but in
>
>
> http://dev.openlayers.org/releases/OpenLayers-2.13/examples/all-overlays.html
>
> or
>
>
> http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/all-overlays.html
>
> it does not, like described above.
> A first finding is that when you use "zoomMethod: null" on map
> instanciation, the problem disappears. So this bug could have something
> todo with the " zoomTween" on the map. Maybe someone could have a detailed
> look at this?
>
> Best regards,
>
> Johannes Weskamm
>
> _______________________________________________
> Dev mailing list
> Dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20131127/808cb9cb/attachment.html>


More information about the Dev mailing list