[Users] Map reprojection issue
Hugo
hfpmartins at gmail.com
Fri Aug 12 13:43:25 CEST 2011
Hello all,
For some reason i'm not able to send an email to the openlayers list (i
always get a mail back with error 551) and so i decided to sent to you guys.
Some time ago Matt has highlighted how to achieve reprojection of the
openlayers map upon base layer change and this is working correctly. However
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.
The code i'm using:
function onBaseLayerChange(evtObj){
var mapProj, baseProj, map, newBase, reproject;
map = this;
newBase = evtObj.layer;
mapProj = (map.projection && map.projection instanceof
OpenLayers.Projection) ? map.projection : new
OpenLayers.Projection(map.projection);
baseProj = newBase.projection;
reproject = !(baseProj.equals(mapProj));
if (reproject) {
var center, maxExt;
center = map.getCenter().transform(mapProj, baseProj);
maxExt = newBase.maxExtent;
map.projection = baseProj;
map.resolutions = newBase.resolutions;
map.maxResolution = newBase.maxResolution;
map.minResolution = newBase.minResolution;
map.maxExtent = maxExt;
map.restrictedExtent = newBase.restrictedExtent;
map.setCenter(center);
}
}
I suppose i'm not setting some property... but which one?
Thanks in advance.
Cheers,
Hugo
--
Hugo Martins
LabNT - ISEGI UNL
Campus de Campolide
1070-312 Lisboa
N 38°43'56.84", W 9°9'35.74"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20110812/da817211/attachment.htm
More information about the Users
mailing list