Hello all,<div><br></div><div>I'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've not been able to correct until the moment. After reprojecting i can'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'm able to pan and zoom normally. </div>
<div><br></div><div>The code i'm using:</div><div><br></div><div><span class="Apple-style-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 && 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 class="Apple-style-span" style="font-family: Arial; background-color: rgb(255, 255, 255); "> map.projection = baseProj;<br>
</span><span class="Apple-style-span" style="font-family: Arial; background-color: rgb(255, 255, 255); ">map.resolutions = newBase.resolutions;</span></div><div><span class="Apple-style-span" style="font-family: Arial; background-color: rgb(255, 255, 255); "> </span><span class="Apple-style-span" style="font-family: Arial; background-color: rgb(255, 255, 255); ">map.maxResolution = newBase.maxResolution;</span></div>
<span class="Apple-style-span" style="font-family: Arial; background-color: rgb(255, 255, 255); "><div> map.minResolution = newBase.minResolution;</div></span><div><span class="Apple-style-span" style="font-family: Arial; background-color: rgb(255, 255, 255); "> map.maxExtent = maxExt;<br>
</span><span class="Apple-style-span" style="font-family: Arial; background-color: rgb(255, 255, 255); ">map.restrictedExtent = newBase.restrictedExtent;</span></div><div><span class="Apple-style-span" style="font-family: Arial; background-color: rgb(255, 255, 255); "> map.setCenter(center);<br>
}<br>}</span></div><div></div><div><span class="Apple-style-span" style="font-family: Arial; background-color: rgb(255, 255, 255); "><br></span></div><div><span class="Apple-style-span" style="font-family: Arial; background-color: rgb(255, 255, 255); "><div>
I suppose i'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><div>-- <br>Hugo Martins<br>LabNT - ISEGI UNL<br>
Campus de Campolide<br>1070-312 Lisboa<br>N 38°43'56.84", W 9°9'35.74"<br>
</div>