[OpenLayers-Users] Reproject co-ordinate points

Phil Scadden p.scadden at gns.cri.nz
Sun Aug 26 18:13:20 PDT 2012


its very easy to do the transform in js, especially between 4326 and 
900913. eg
                 var lonLat = this.map.getLonLatFromPixel(e.xy);
                 if (this.map.displayProjection) {
                     lonLat.transform(this.map.getProjectionObject(),
                         this.map.displayProjection );
                 }
If you look at docs for LonLat, you will see the transform method. It 
needs two projection objects. Create one for 4326
eg var p4326 = new OpenLayers.Projection("EPSG:4326");

and then the other will be the map projection. Code might something like:
var p4326 = new OpenLayers.Projection("EPSG:4326");
lonLat = new OpenLayers.LonLat(lon,lat);
lonLat.project(p4326,map.getProjectionObject());



Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.



More information about the Users mailing list