<div dir="ltr">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.<div>
<br></div><div>So instead of calling getZoom() directly, you should register for a zoomend listener and call getZoom() there.</div><div><br></div><div>Andreas.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Wed, Nov 27, 2013 at 11:17 AM, Johannes Weskamm <span dir="ltr"><<a href="mailto:weskamm@terrestris.de" target="_blank">weskamm@terrestris.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

  

    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Hi,<br>
    <br>
    I think i found a bug in the zoomTo Method of the map, while
    investigating an issue in geoext 2 (
    
    <a href="https://github.com/geoext/geoext2/issues/205" target="_blank">https://github.com/geoext/geoext2/issues/205</a>).<br>
    The problem seems to be introduced since OL 2.13 and is also
    occuring in 2.13.1:<br>
    <br>
    When you zoom the map with the zoomTo Method multiple times in a
    row, the result will be confusing.<br>
    To be exact, it will not be the last zoomValue you have given to the
    method, instead it will become e.g. 0.<br>
    <br>
    Here is the simple code which i used to test the behaviour:<br>
    <br>
    
    m = map;<br>
    m.zoomTo(1);<br>
    m.zoomTo(2);<br>
    m.zoomTo(3);<br>
    m.zoomTo(4);<br>
    m.zoomTo(5);<br>
    m.getZoom();<br>
    <br>
    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.<br>
    I checked this with the official examples of OL 2.12, 2.13 and
    2.13.1:<br>
    <br>
    
    <a href="http://dev.openlayers.org/releases/OpenLayers-2.12/examples/all-overlays.html" target="_blank">http://dev.openlayers.org/releases/OpenLayers-2.12/examples/all-overlays.html</a><br>
    <br>
    In 2.12, everything works as expected, but in<br>
    <br>
    
    <a href="http://dev.openlayers.org/releases/OpenLayers-2.13/examples/all-overlays.html" target="_blank">http://dev.openlayers.org/releases/OpenLayers-2.13/examples/all-overlays.html</a><br>
    <br>
    or<br>
    <br>
    
    <a href="http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/all-overlays.html" target="_blank">http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/all-overlays.html</a><br>
    <br>
    it does not, like described above.<br>
    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?<br>
    <br>
    Best regards,<br>
    <br>
    Johannes Weskamm<br>
  </div>

<br>_______________________________________________<br>
Dev mailing list<br>
<a href="mailto:Dev@lists.osgeo.org">Dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/openlayers-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-dev</a><br></blockquote></div><br></div>