[OpenLayers-Users] Is any convertion required between GPS coordinate and Spherical Mercator projection?

Greg Allensworth gregor at greeninfo.org
Fri Aug 3 06:45:34 PDT 2012


> I have GPS coordinate data in pure decimal GPS coordinate format for
> example 25.124167 in order to place the feature on the map. And I will
> use Google Maps layer with OpenLayers. Is any convertion required? Does
> OpenLayers implement in the background?

You will do coordinate conversion, yes. The map will use the Web 
Mercator SRS -- to place a marker using WGS84, you would need to convert:

var SRS_GOOGLE = new OpenLayers.Projection("EPSG:900913");
var SRS_LONLAT = new OpenLayers.Projection("EPSG:4326");

var center = new OpenLayers.LonLat(-85.5678, 45.12345);
center.transform(SRS_LONLAT,SRS_GOOGLE);
map.setCenter(center, 10);

var box = new OpenLayers.Bounds(-122,43,-121,44);
box.transform(SRS_LONLAT,SRS_GOOGLE);
map.zoomToBounds(box);


If you forget to do this transform, then your coordinates will be very 
close to the 0,0 mark at the equator & the Greenwich meridian  (-85 and 
45, in meters from 0,0). That's a great debugging tip: if your marker is 
appearing at "practically 0,0" you probably are using "very tiny 
coordinates" for your SRS.

-- 
Greg Allensworth, Web GIS Developer
BS  A+  Network+  Security+  Linux+  Server+
GreenInfo Network - Information and Mapping in the Public Interest
564 Market Street, Suite 510  San Francisco CA 94104
PH: 415-979-0343 x302  FX: 415-979-0371    email: gregor at greeninfo.org
Web: www.GreenInfo.org     www.MapsPortal.org

Subscribe to MapLines, our e-newsletter, at www.GreenInfo.org


More information about the Users mailing list