Dear All,
I would like to conver map coordinates (-103.5234,48.56781) to DMS(Degrees Minutes Sec). My map is in WKI:4269.
Can anybody help me how to do it in JSAPI.
Thanks,
Uday
Hi,
Here is my code to show DMS coordinates on Map Screen using ArcGIS API Javascript
// Coordinates on Screen map.on("load", function() { //after map loads, connect to listen to mouse move & drag events map.on("mouse-move", showCoordinates); map.on("mouse-drag", showCoordinates); }); function deg_to_dms (deg) { var d = Math.floor (deg); var minfloat = (deg-d)*60; var m = Math.floor(minfloat); var secfloat = (minfloat-m)*60; var s = Math.round(secfloat); if (s==60) { m++; s=0; } if (m==60) { d++; m=0; } return ("" + d + '°' + m + '\'' + s + '" '); } function showCoordinates(evt) { //the map is in web mercator but display coordinates in geographic (lat, long) var mp = webMercatorUtils.webMercatorToGeographic(evt.mapPoint); //convert DD to DMS var lat = deg_to_dms(mp.y); var lon = deg_to_dms(mp.x); //display mouse coordinates dom.byId("coordinate").innerHTML = lat + 'N' + ", " + lon + 'E'; }
Regards,
Amri