0

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]);
}
madzohan
  • 11,488
  • 9
  • 40
  • 67

1 Answers1

1

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+'"';
}
vp_arth
  • 14,461
  • 4
  • 37
  • 66
  • thanks, but `without manual converting?`. In their api docs I've found only one reference to coordinate formats - that `geocoder` recognise `+-deg° mm' ss", +-deg° mm' ss"` but looks like returns only in decimal format. https://tech.yandex.ru/maps/doc/geocoder/desc/concepts/input_params-docpage/ – madzohan Nov 21 '14 at 13:22
  • from http://help.yandex.ru/ "Поясните, пожалуйста, подробнее, что Вы имеете в виду." xD ... ok I'll accept this answer, but I think that ability of representation in multiple formats should be implemented in api. – madzohan Nov 22 '14 at 08:49
  • go to yandex guys with your feature request :) I can't to implement it in their API – vp_arth Nov 22 '14 at 10:48