I am trying out this code,<div><br></div><div><div>                      var lonLat = evt.xy;</div><div>                      console.log(lonLat.lon, lonLat.lat);</div><div>                      var proj = new OpenLayers.Projection("EPSG:4326");</div>

<div>                      lonLat = new OpenLayers.LonLat(lonLat.lon, lonLat.lat);</div><div>                      lonLat.project(proj, map.getProjectionObject());</div><div><br></div><div>And I keep getting this error,</div>

<div><br></div><div>undefined undefined (for the lonLat.lon, lonLat.lat)</div><div>Uncaught TypeError: Object lon=NaN,lat=NaN has no method 'project' (for  lonLat.project(proj, map.getProjectionObject());)</div><div>

<br></div><div>What should I correct?</div><br><div class="gmail_quote">On Sun, Aug 26, 2012 at 6:13 PM, Phil Scadden <span dir="ltr"><<a href="mailto:p.scadden@gns.cri.nz" target="_blank">p.scadden@gns.cri.nz</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">its very easy to do the transform in js, especially between 4326 and<br>
900913. eg<br>
                 var lonLat = this.map.getLonLatFromPixel(e.xy);<br>
                 if (this.map.displayProjection) {<br>
                     lonLat.transform(this.map.getProjectionObject(),<br>
                         this.map.displayProjection );<br>
                 }<br>
If you look at docs for LonLat, you will see the transform method. It<br>
needs two projection objects. Create one for 4326<br>
eg var p4326 = new OpenLayers.Projection("EPSG:4326");<br>
<br>
and then the other will be the map projection. Code might something like:<br>
var p4326 = new OpenLayers.Projection("EPSG:4326");<br>
lonLat = new OpenLayers.LonLat(lon,lat);<br>
lonLat.project(p4326,map.getProjectionObject());<br>
<br>
<br>
<br>
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.<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Thanks & Regards<div>Smaran Harihar</div><br>
</div>