|
|
@@ -1,4 +1,5 @@
|
|
|
|
|
|
+
|
|
|
/*
|
|
|
205.395583333332 = 205°23'44.1"
|
|
|
1,直接读取"度":205
|
|
|
@@ -9,10 +10,16 @@
|
|
|
function latLngDecimalToDegrees(decimal) {
|
|
|
let absDecimal = Math.abs(decimal);
|
|
|
let isNegative = Math.abs(decimal) != decimal;
|
|
|
- let degrees = Math.floor(absDecimal); //度
|
|
|
- let minutes = Math.floor((absDecimal - degrees) * 60); //分
|
|
|
- let seconds = Math.round((absDecimal - degrees) * 3600 % 60); //秒
|
|
|
- return (isNegative ? "-" : "") + degrees + '°' + minutes + "′" + seconds + '″';
|
|
|
+ let d = Math.floor(absDecimal); //度
|
|
|
+ let m = Math.floor((absDecimal - d) * 60); //分
|
|
|
+ let s = Math.round((absDecimal - d) * 3600 % 60); //秒
|
|
|
+ if(s == 60) {s = 0; m++}
|
|
|
+ if(m == 60) {m = 0; d++}
|
|
|
+ //d = ('000'+d).slice(-3); // left-pad with leading zeros
|
|
|
+ m = ('00'+m).slice(-2); // left-pad with leading zeros
|
|
|
+ s = ('00'+s).slice(-2);
|
|
|
+ //if (s<10) s = '0' + s; // left-pad with leading zeros (note may include decimals)
|
|
|
+ return (isNegative ? "-" : "") + d + '°' + m + "′" + s + '″';
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
@@ -89,4 +96,4 @@ module.exports = {
|
|
|
isSafeString,
|
|
|
hasLine,
|
|
|
hasPoint
|
|
|
-}
|
|
|
+}
|