<div>Hello all,</div><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>function onBaseLayerChange(evtObj){</div><div> var mapProj, baseProj, map, newBase, reproject;</div><div> map = this;</div><div> newBase = evtObj.layer;</div>
<div> mapProj = (map.projection && map.projection instanceof OpenLayers.Projection) ? map.projection : new OpenLayers.Projection(map.projection);</div><div> baseProj = newBase.projection;</div><div> reproject = !(baseProj.equals(mapProj));</div>
<div> if (reproject) {</div><div> var center, maxExt;</div><div> center = map.getCenter().transform(mapProj, baseProj);</div><div> maxExt = newBase.maxExtent;</div><div> map.projection = baseProj;</div>
<div> map.resolutions = newBase.resolutions;</div><div> map.maxResolution = newBase.maxResolution;</div><div> map.minResolution = newBase.minResolution;</div><div> map.maxExtent = maxExt;</div><div> map.restrictedExtent = newBase.restrictedExtent;</div>
<div> map.setCenter(center);</div><div> }</div><div>}</div><div><br></div><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><br>-- <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>