<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7651.59">
<TITLE>Re: [OpenLayers-Users] setCenter not working with EPSG:900913projection</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>On Mon, 2009-01-05 at 09:52 -0500, Heidt, Christopher M. wrote:<BR>
> you need to transform the values you are applying to the setcenter.<BR>
> Map.setCenter( new OpenLayers.LonLat(lon,<BR>
> lat).transform(map.displayProjection, map.projection),null);<BR>
<BR>
I thought I was already doing that, see code below:<BR>
<BR>
> > map = new OpenLayers.Map('map', {projection: new<BR>
> > OpenLayers.Projection("EPSG:900913")});<BR>
> > var gmap = new OpenLayers.Layer.Google("Google Streets", {<BR>
> > sphericalMercator: true }); // streets is the default<BR>
> ><BR>
> > map.addLayers([gmap]);<BR>
> ><BR>
> > var center = new OpenLayers.LonLat(-41.27, 173.28);<BR>
> > alert('['+center.lon+','+center.lat+']');<BR>
> > var proj = new OpenLayers.Projection("EPSG:4326");<BR>
> > center.transform(proj, map.getProjectionObject());<BR>
> > alert('['+center.lon+','+center.lat+']');<BR>
> > map.setCenter(center, 13);<BR>
<BR>
Perhaps I'm not doing this correctly, but the conversion appears to be<BR>
working according to the alert statements.<BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>