# Map Coordinates to WGS84

**URL:** <https://community.thinkgeo.com/t/map-coordinates-to-wgs84/5381>\
**Category:** WebForms\
**Created:** [July 1, 2010, 7:52am UTC](https://community.thinkgeo.com/t/map-coordinates-to-wgs84/5381 "2010-07-01T07:52:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ayhan](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/8491ac/32.png) [@Ayhan](https://community.thinkgeo.com/u/Ayhan)\
**Post date:** [July 1, 2010, 7:52am UTC](https://community.thinkgeo.com/t/map-coordinates-to-wgs84/5381/1 "2010-07-01T07:52:23Z")

</div>

&nbsp;Hi,

&nbsp;&nbsp;&nbsp;I&nbsp;am&nbsp;triying&nbsp;to&nbsp;get&nbsp;coordinates&nbsp;in&nbsp;WGS84&nbsp;mode&nbsp;using&nbsp;javascript.&nbsp;Is&nbsp;there&nbsp;any&nbsp;API&nbsp;functions&nbsp;used&nbsp;by&nbsp;JavaScript&nbsp;for&nbsp;this?

&nbsp;var&nbsp;tgMap&nbsp;=&nbsp;null;

var&nbsp;showScreenPosition&nbsp;=&nbsp;function(e)&nbsp;{  
&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;lonlat&nbsp;=&nbsp;this.getLonLatFromViewPortPx(e.xy);  
&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;result&nbsp;=&nbsp;'';  
&nbsp;&nbsp;&nbsp;&nbsp;result&nbsp;+=&nbsp;'screenX&nbsp;=&nbsp;'&nbsp;+&nbsp;e.xy.x&nbsp;+&nbsp;',';  
&nbsp;&nbsp;&nbsp;&nbsp;result&nbsp;+=&nbsp;'screenY&nbsp;=&nbsp;'&nbsp;+&nbsp;e.xy.y&nbsp;+&nbsp;',';  
&nbsp;&nbsp;&nbsp;&nbsp;result&nbsp;+=&nbsp;'lon&nbsp;=&nbsp;'&nbsp;+&nbsp;lonlat.lon&nbsp;+&nbsp;',';  
&nbsp;&nbsp;&nbsp;&nbsp;result&nbsp;+=&nbsp;'lat&nbsp;=&nbsp;'&nbsp;+&nbsp;lonlat.lat;  
  
&nbsp;&nbsp;&nbsp;&nbsp;alert(result);  
}  
  
var&nbsp;OnMapCreated&nbsp;=&nbsp;function(map)&nbsp;{  
&nbsp;&nbsp;&nbsp;&nbsp;tgMap&nbsp;=&nbsp;map;  
&nbsp;&nbsp;&nbsp;&nbsp;tgMap.events.register('mouseover',&nbsp;tgMap,&nbsp;showScreenPosition);  
}  
  
  
  
this&nbsp;function&nbsp;gives&nbsp;me&nbsp;the&nbsp;result&nbsp;such&nbsp;this&nbsp;:&nbsp;3192096.0102896634&nbsp;5035699.2570279529  
but&nbsp;I&nbsp;want&nbsp;it&nbsp;as&nbsp;:28.6750863442015&nbsp;41.1581665281288  
  
Thanks,  
  
Ayhan

---

<div class="post-metadata">

**Author:** ![Khalil](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/k/bc8723/32.png) [@Khalil](https://community.thinkgeo.com/u/Khalil)\
**Post date:** [July 1, 2010, 8:28pm UTC](https://community.thinkgeo.com/t/map-coordinates-to-wgs84/5381/2 "2010-07-01T20:28:36Z")

</div>

Hi,&nbsp;Ayhan&nbsp;  
&nbsp;&nbsp;  
&nbsp;If&nbsp;you&nbsp;want&nbsp;to&nbsp;project&nbsp;the&nbsp;lonlat&nbsp;on&nbsp;the&nbsp;client-side,&nbsp;you&nbsp;may&nbsp;need&nbsp;to&nbsp;refer&nbsp;to&nbsp;the&nbsp;OpenLayers.Projection&nbsp;object.&nbsp;You&nbsp;could&nbsp;use&nbsp;it&nbsp;like&nbsp;this:&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;projectedLonLat&nbsp;=&nbsp;lonlat.transform(new&nbsp;OpenLayers.Projection("EPSG:900913"),&nbsp;new&nbsp;OpenLayers.Projection("EPSG:4326"));&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(projectedLonLat);&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Khalil
