Hi Jean,<div><br></div><div>Thanks a lot for your input. I&#39;ll be looking into this and try to fix my zoom problem since all the rest is working properly.</div><div><br></div><div>Cheers,</div><div><br></div><div>Hugo<br>
<br><div class="gmail_quote">On Fri, Aug 12, 2011 at 4:06 PM, Jean-François Gigand <span dir="ltr">&lt;<a href="mailto:jf@geonef.fr">jf@geonef.fr</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Hugo,<br>
<br>
I can&#39;t answer your question straightforwardly, but can give some hints.<br>
<br>
- map.projection is only used as the default for new added layers<br>
  The reference is map.getProjectionObject() which returns cloned baseLayer&#39;s.<br>
<br>
- same for maxResolution and minResolution: they matter for the layers,<br>
  not for the map. The baseLayer is the master.<br>
<br>
- the &#39;changebaselayer&#39; event is triggered after the change was made effective,<br>
  so the map.getCenter() in your function would return the new center<br>
  (within the projection of the new baseLayer&#39;s projection)<br>
<br>
- the OpenLayers.Map&#39;s setBaseLayer() function does not seem,<br>
  indeed, to take care of reprojecting the map center.<br>
  As a workaround, you may either :<br>
     - reproject the current center *before* calling setBaseLayer()<br>
       and affect it to map.center<br>
     - make your own Map class extending OpenLayers.Map<br>
       and overload setBaseLayer to handle the reprojection<br>
       (either replacing the implementation, or just reproject this.center<br>
       before calling OpenLayers.Map.prototype.setBaseLayer)<br>
<br>
I recommend your to dive into OpenLayers&#39; source code, which is the<br>
best way to really understand how it behaves, for complex problems<br>
like this one.<br>
<br>
Best regards,<br>
<br>
Jean-François Gigand - Geonef<br>
Paris, France - <a href="http://geonef.fr/" target="_blank">http://geonef.fr/</a><br>
<br>
<br>
<br>
<br>
2011/8/12 Hugo &lt;<a href="mailto:hfpmartins@gmail.com">hfpmartins@gmail.com</a>&gt;:<br>
<div><div></div><div class="h5">&gt; Hello all,<br>
&gt; I&#39;m trying to reproject openlayers map according to the selected base layer.<br>
&gt; So, when the app is loaded my map has the EPSG:900913 projection (so that i<br>
&gt; can use OSM, google, etc). I have other base layers that are in the EPSG:<br>
&gt; 3763 projection and, when the user activate this layers the map will<br>
&gt; automatically reproject itself to this new definition. I was able to<br>
&gt; accomplish this however i have a small bug that i&#39;ve not been able to<br>
&gt; correct until the moment. After reprojecting i can&#39;t pan and if i make a<br>
&gt; zoom it will go to a strange location (i think the zoom is still assuming<br>
&gt; the old coordinates). After making the zoom i&#39;m able to pan and zoom<br>
&gt; normally.<br>
&gt; The code i&#39;m using:<br>
&gt; function onBaseLayerChange(evtObj){<br>
&gt;    var mapProj, baseProj, map, newBase, reproject;<br>
&gt;    map = this;<br>
&gt;    newBase = evtObj.layer;<br>
&gt;    mapProj = (map.projection &amp;&amp; map.projection instanceof<br>
&gt; OpenLayers.Projection) ? map.projection : new<br>
&gt; OpenLayers.Projection(map.projection);<br>
&gt;    baseProj = newBase.projection;<br>
&gt;    reproject = !(baseProj.equals(mapProj));<br>
&gt;    if (reproject) {<br>
&gt;       var center, maxExt;<br>
&gt;       center = map.getCenter().transform(mapProj, baseProj);<br>
&gt;       maxExt = newBase.maxExtent;<br>
&gt;       map.projection = baseProj;<br>
&gt;       map.resolutions = newBase.resolutions;<br>
&gt;       map.maxResolution = newBase.maxResolution;<br>
&gt;       map.minResolution = newBase.minResolution;<br>
&gt;       map.maxExtent = maxExt;<br>
&gt;       map.restrictedExtent = newBase.restrictedExtent;<br>
&gt;       map.setCenter(center);<br>
&gt;    }<br>
&gt; }<br>
&gt; I suppose i&#39;m not setting some property... but which one?<br>
&gt; Thanks in advance.<br>
&gt; Cheers,<br>
&gt; Hugo<br>
&gt;<br>
&gt; --<br>
&gt; Hugo Martins<br>
&gt; LabNT - ISEGI UNL<br>
&gt; Campus de Campolide<br>
&gt; 1070-312 Lisboa<br>
&gt; N 38°43&#39;56.84&quot;, W 9°9&#39;35.74&quot;<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; Users mailing list<br>
&gt; <a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>
&gt; <a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>
&gt;<br>
&gt;<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Hugo Martins<br>LabNT - ISEGI UNL<br>Campus de Campolide<br>1070-312 Lisboa<br>N 38°43&#39;56.84&quot;, W 9°9&#39;35.74&quot;<br>
</div>