<div class="gmail_quote">Hello all,<div><br></div><div>I&#39;m trying to reproject openlayers map according to the selected base layer. So, when the app is loaded my map has the EPSG:900913 projection (so that i can use OSM, google, etc). I have other base layers that are in the EPSG: 3763 projection and, when the user activate this layers the map will automatically reproject itself to this new definition. I was able to accomplish this however i have a small bug that i&#39;ve not been able to correct until the moment. After reprojecting i can&#39;t pan and if i make a zoom it will go to a strange location (i think the zoom is still assuming the old coordinates). After making the zoom i&#39;m able to pan and zoom normally. </div>


<div><br></div><div>The code i&#39;m using:</div><div><br></div><div><span style="font-family:Arial;background-color:rgb(255, 255, 255)">function onBaseLayerChange(evtObj){<br>   var mapProj, baseProj, map, newBase, reproject;<br>

   map = this;<br>   newBase = evtObj.layer;<br>   mapProj = (map.projection &amp;&amp; map.projection instanceof OpenLayers.Projection) ? map.projection : new OpenLayers.Projection(map.projection);<br>   baseProj = newBase.projection;<br>

   reproject = !(baseProj.equals(mapProj));<br>   if (reproject) {<br>      var center, maxExt;<br>      center = map.getCenter().transform(mapProj, baseProj);<br>      maxExt = newBase.maxExtent;<br></span><span style="font-family:Arial;background-color:rgb(255, 255, 255)">      map.projection = baseProj;<br>

      </span><span style="font-family:Arial;background-color:rgb(255, 255, 255)">map.resolutions = newBase.resolutions;</span></div><div><span style="font-family:Arial;background-color:rgb(255, 255, 255)">      </span><span style="font-family:Arial;background-color:rgb(255, 255, 255)">map.maxResolution = newBase.maxResolution;</span></div>

<span style="font-family:Arial;background-color:rgb(255, 255, 255)"><div>      map.minResolution = newBase.minResolution;</div></span><div><span style="font-family:Arial;background-color:rgb(255, 255, 255)">      map.maxExtent = maxExt;<br>

      </span><span style="font-family:Arial;background-color:rgb(255, 255, 255)">map.restrictedExtent = newBase.restrictedExtent;</span></div><div><span style="font-family:Arial;background-color:rgb(255, 255, 255)">      map.setCenter(center);<br>

   }<br>}</span></div><div></div><div><span style="font-family:Arial;background-color:rgb(255, 255, 255)"><br></span></div><div><span style="font-family:Arial;background-color:rgb(255, 255, 255)"><div>
I suppose i&#39;m not setting some property... but which one?</div><div><br></div><div>Thanks in advance.</div><div>Cheers,</div><div>Hugo</div><div><br></div><div><br></div></span></div><font color="#888888"><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;</div></font></div>