[英]How get coords from click event in X°Y′Z" format (not in X.Y == decimal)
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? 下面代码中的
e.get('coords')
以十进制格式返回坐标,但是我需要X°Y′Z“格式。有没有办法手动转换?
myMap.events.add('click', setCoords);
function setCoords(e) {
var coords = e.get('coords');
$('#id_lat').val(coords[0]);
$('#id_lon').val(coords[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+'"';
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.