[OpenLayers-Users] setCenter not working with
EPSG:900913projection
Robert Connolly
r.connolly at auckland.ac.nz
Mon Jan 5 15:36:45 EST 2009
On Mon, 2009-01-05 at 09:52 -0500, Heidt, Christopher M. wrote:
> you need to transform the values you are applying to the setcenter.
> Map.setCenter( new OpenLayers.LonLat(lon,
> lat).transform(map.displayProjection, map.projection),null);
I thought I was already doing that, see code below:
> > map = new OpenLayers.Map('map', {projection: new
> > OpenLayers.Projection("EPSG:900913")});
> > var gmap = new OpenLayers.Layer.Google("Google Streets", {
> > sphericalMercator: true }); // streets is the default
> >
> > map.addLayers([gmap]);
> >
> > var center = new OpenLayers.LonLat(-41.27, 173.28);
> > alert('['+center.lon+','+center.lat+']');
> > var proj = new OpenLayers.Projection("EPSG:4326");
> > center.transform(proj, map.getProjectionObject());
> > alert('['+center.lon+','+center.lat+']');
> > map.setCenter(center, 13);
Perhaps I'm not doing this correctly, but the conversion appears to be
working according to the alert statements.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090106/dd1deaf1/attachment.html
More information about the Users
mailing list