How get coords from click event in X°Y′Z" format (not in X.Y == decimal)

138 views Asked by At

e.get('coords') from code below, returns coords in decimal format, but I need them in X°Y′Z" format. Is there any way to get this without manual converting?

myMap.events.add('click', setCoords);

function setCoords(e) {
    var coords = e.get('coords');

     $('#id_lat').val(coords[0]);
     $('#id_lon').val(coords[1]);
}
1

There are 1 answers

3
vp_arth On BEST ANSWER

Try function like this:

function format(coords) {
  var deg = parseInt(coords);
  var min = parseInt((60 * coords) % 60);
  var sec = (60*60 * coords) % 60;
  return deg+'deg'+min+"'"+sec+'"';
}