[OpenLayers-Users] Congrats and query? Using spherical Mercator -- can I get at the WGS84 geographic values?

Mike Adair madair at dmsolutions.ca
Mon Sep 17 14:47:54 EDT 2007


Hi,

On the subject of coordinate transformations, I'd like to propose 
incorporating Proj4js into OpenLayers for coordinate transformations 
like this. Proj4js is a JavaScript port of the Proj4 C library 
(currently called cscs in the MapBuilder svn: 
http://svn.codehaus.org/mapbuilder/cscs and look for lib/Proj4js.js in 
particular). 

Projection definitions may be loaded statically when the app is built if 
the projections you will be using are know before hand, otherwise it 
does a lookup of the proj4 command line params with an AJAX call to 
spatialreference.org.  The code I have now also dynamically loads the 
projection class code at runtime (eg. spherical mecator, lambert 
conformal conic, etc.) but these can also be specified when the app is 
coded.

The way it works is you create a projection object, passing the 
projection code to the constructor.  This object then provides forward 
(LL to XY), inverse (XY to LL) and transform (XY to another XY) methods, 
including datum transformations.  This means that you could load vectors 
with coords in one projection and have it rendered over a map in another 
projection for example.

There is more work to be done to complete Proj4js, especially for demos 
and docs, but I'll be demoing this at FOSS4G in the state that it's in.

Mike


Christopher Schmidt wrote:
> On Sat, Sep 15, 2007 at 06:59:11PM -0500, Lance Dyas wrote:
>   
>> Most of the geocoding services and search facilities on the web are in  
>> bad old EPSG:4326
>> I am using Spherical Mercator version of Google Maps layer (in part 
>> because it is just more
>> correct ) but would like to get at the coords in geographic projection...
>>     
>
> http://dev.openlayers.org/docs/files/OpenLayers/Layer/SphericalMercator-js.html#OpenLayers.Layer.SphericalMercator.forwardMercator
> http://dev.openlayers.org/docs/files/OpenLayers/Layer/SphericalMercator-js.html#OpenLayers.Layer.SphericalMercator.inverseMercator
>
> Note that these are *not* API methods at the moment -- in the future, I
> expect OpenLayers will have reprojection code in it or alongside it that
> we encourage people to use, but at the moment, these functions will do
> what you need to take in lon/lat and convert to spherical mercator or
> the other direction.  
>
> Regards,
>   




More information about the Users mailing list