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 <wesk...@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 > d...@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/openlayers-dev >
_______________________________________________ Dev mailing list d...@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/openlayers-dev