简体   繁体   English

如何从点击事件中以X°Y′Z“格式获取坐标(而不是XY ==小数)

[英]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.

相关问题 从带有 (x,y) 坐标的列表中获取项目 - Get an item from a list with (x,y) coords 如何使用JavaScript从地图协调中心获取x1,y1,x2,y2? - how to get x1,y1,x2,y2 from map coords with javascript? [] .concat([“x”,“y”],“z”) - >如何获得[[“x”,“y”],“z”]而不是[“x”,“y”, “Z”]? - [].concat([“x”,“y”],“z”) -> How to get [[“x”,“y”],“z”] instead of [“x”,“y”,“z”]? 关于“函数xy(){…}”的语法错误? - SyntaxError on “function x.y () {…}”? Android studio 点击坐标xy - Android studio click on coords x y KineticJS:从Circle的“ click”事件中获取鼠标按钮x和y - KineticJS: Get the mouse button, x and y from the 'click' event on a Circle TypeError:xy不是函数,显然它是 - TypeError: x.y is not a function, when apparently it is Three.js 2D X,Y坐标始终位于镜头前的3D X,Y,Z坐标 - Three.js 2D X, Y coords to 3D X, Y, Z coords always in front of camera 如何在Matrix3d上获得比例尺(x,y,z)和旋转量(x,y,z)? - How to get the scale(x,y,z) together with rotation(x,y,z) on a matrix3d? 通过Coords X,Y Fabric JS发出点击事件 - Emit click events by coords x, y fabric js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM