Answers for "javascript converting latitude longitude to gps coordinates"

0

javascript converting latitude longitude to gps coordinates

#Convert lat/long to gps coordinates
function ConvertDEGToDMS(deg, lat) {
    var absolute = Math.abs(deg);

    var degrees = Math.floor(absolute);
    var minutesNotTruncated = (absolute - degrees) * 60;
    var minutes = Math.floor(minutesNotTruncated);
    var seconds = ((minutesNotTruncated - minutes) * 60).toFixed(2);

    if (lat) {
        var direction = deg >= 0 ? "N" : "S";
    } else {
        var direction = deg >= 0 ? "E" : "W";
    }

    return degrees + "°" + minutes + "'" + seconds + "\"" + direction;
}
Posted by: Guest on November-24-2020

Code answers related to "javascript converting latitude longitude to gps coordinates"

Code answers related to "Javascript"

Browse Popular Code Answers by Language