<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
<br>
Just in case somebody is having the same problem. Center/zoom works
well for all layers using the code below:<br>
<br>
<pre id="line12">    function init() {
        map = new OpenLayers.Map('map', {
            projection: new OpenLayers.Projection("EPSG:900913"),
            displayProjection: new OpenLayers.Projection("EPSG:4326"),
            units: "m",
            numZoomLevels: 20,
            controls: [
                new OpenLayers.Control.Navigation(),
                new OpenLayers.Control.PanZoomBar(),
                new OpenLayers.Control.LayerSwitcher(),
                new OpenLayers.Control.Permalink(),
                new OpenLayers.Control.ScaleLine(),
            ]
        });

        var osmLayer = new OpenLayers.Layer.OSM.Mapnik("OpenStreetMap");
        var gMapLayer = new OpenLayers.Layer.Google("Google", {sphericalMercator:true});
        var gPhysicalLayer = new OpenLayers.Layer.Google("Google Physical", {type: G_PHYSICAL_MAP, sphericalMercator:true});
        var gSatelliteLayer = new OpenLayers.Layer.Google("Google Satellite", {type: G_SATELLITE_MAP, sphericalMercator:true});
        map.addLayers([osmLayer, gMapLayer, gPhysicalLayer, gSatelliteLayer]);

        map.zoomTo(zoom);
    }

    function triggerUpdate() {
        triggerUpdateActive = true;
        window.setTimeout("update()", refreshSeconds * 1000);
    }

    function update() {
        triggerUpdate();
        if(rss != null) {
            rss.destroy();
        }
        rss = new OpenLayers.Layer.GeoRSS(trackingID, geoRssUrl, {'projection': new OpenLayers.Projection("EPSG:4326")} );
        rss.events.register("loadend", window, populateMap);
        map.addLayer(rss);
    }

    function populateMap() {
        map.zoomTo(zoom);

        if(rss.markers.length &gt;= 1) {
            var lastMarker=rss.markers[rss.markers.length-1];
            map.setCenter(lastMarker.lonlat);
       }
       map.raiseLayer(rss, 1);
    }


Regards,

Axel
</pre>
<br>
<blockquote cite="mid:4A52467C.6010307@avanux.de" type="cite">
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
Andrea,<br>
  <br>
Andreas Hocevar wrote:
  <blockquote
 cite="mid:5b021dd0907060056i647dbfcdt9069c58d676f8cb4@mail.gmail.com"
 type="cite">
    <blockquote type="cite">
      <pre wrap="">Based on some parameters I change the zoom level using
map.setCenter(lonlat, zoom).
This works perfectly for OSM Mapnik layer but not for Google layer where
the pan zoom bar reflects the new zoom level but the map itself still
shows the previous zoom level. Am I missing something?

osmLayer = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
gMapLayer = new OpenLayers.Layer.Google("Google Maps", {numZoomLevels:
20, isBaseLayer: true });
    </pre>
    </blockquote>
    <pre wrap=""><!---->
Using Google layers like this only works in a few use cases. You have
to use Spherical Mercator to make it behave like you are expecting.
See <a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://docs.openlayers.org/library/spherical_mercator.html">http://docs.openlayers.org/library/spherical_mercator.html</a> for
explanation, tutorial and howto.
  </pre>
  </blockquote>
Thanks for pointing me to this documentation. I'm using Spherical
Mercator now but the underlying problem is still the same:<br>
While being on the Google layer, a call to
map.setCenter(lastMarker.lonlat, zoom) causes the zoom bar to show the
new zoom level but the map is still displayed for the previously
selected zoom level.&nbsp; If I switch to OSM layer and back to Google
layer, the map in the Google layer is shown with the correct zoom
level, matching the zoom level indicated by the zoom bar.<br>
  <br>
Best regards,<br>
  <br>
Axel<br>
  <br>
  <br>
Below is the relevant part of JS:<br>
  <br>
  <br>
&nbsp;&nbsp;&nbsp; function init() {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; map = new OpenLayers.Map('map', {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; projection: new OpenLayers.Projection("EPSG:900913"),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; displayProjection: new OpenLayers.Projection("EPSG:4326"),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; units: "m",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; controls: [<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new OpenLayers.Control.Navigation(),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new OpenLayers.Control.PanZoomBar(),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new
OpenLayers.Control.LayerSwitcher({'ascending':false}),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new OpenLayers.Control.Permalink(),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new OpenLayers.Control.ScaleLine(),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new OpenLayers.Control.Permalink('permalink'),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new OpenLayers.Control.MousePosition(),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new OpenLayers.Control.OverviewMap(),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ]<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });<br>
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var gMapLayer = new OpenLayers.Layer.Google("Google Maps",
{isBaseLayer: true, 'sphericalMercator': true });<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var osmLayer = new OpenLayers.Layer.OSM();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; map.addLayers([gMapLayer, osmLayer]);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; map.zoomTo(zoom);<br>
&nbsp;&nbsp;&nbsp; }<br>
  <br>
&nbsp;&nbsp;&nbsp; function triggerUpdate() {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; triggerUpdateActive = true;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; window.setTimeout("update()", refreshSeconds * 1000);<br>
&nbsp;&nbsp;&nbsp; }<br>
  <br>
&nbsp;&nbsp;&nbsp; function update() {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; triggerUpdate();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(rss != null) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rss.destroy();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rss = new OpenLayers.Layer.GeoRSS(trackingID, geoRssUrl,
{'projection': new OpenLayers.Projection("EPSG:4326")} );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rss.events.register("loadend", window, populateMap);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; map.addLayer(rss);<br>
&nbsp;&nbsp;&nbsp; }<br>
  <br>
&nbsp;&nbsp;&nbsp; function populateMap() {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(rss.markers.length &gt;= 1) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var lastMarker=rss.markers[rss.markers.length-1];<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; map.setCenter(lastMarker.lonlat, zoom);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; map.raiseLayer(rss, 1);<br>
&nbsp;&nbsp;&nbsp; }<br>
  <br>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@openlayers.org">Users@openlayers.org</a>
<a class="moz-txt-link-freetext" href="http://openlayers.org/mailman/listinfo/users">http://openlayers.org/mailman/listinfo/users</a>
  </pre>
</blockquote>
<br>
</body>
</html>