Skip to content

Instantly share code, notes, and snippets.

@kebman
Created March 31, 2018 20:48
Show Gist options
  • Save kebman/da49631d9d061d76b71f6aa7319aa7c5 to your computer and use it in GitHub Desktop.
Save kebman/da49631d9d061d76b71f6aa7319aa7c5 to your computer and use it in GitHub Desktop.
Converts Google Maps coordinates for use with Adobe Bridge image metadata
<!DOCTYPE html>
<html>
<head>
<title>Google Maps GPS Coordinate to Adobe Bridge - kebman.com</title>
<meta charset="utf-8">
<style type="text/css">
#form {
background-color: MistyRose;
padding: 0.5em;
}
input[name="latlon"] {
width: 30%;
}
input[name="latO"] {
width: 14.75%;
}
input[name="lonO"] {
width: 14.75%;
}
#tcoord {
user-select: text;
}
</style>
</head>
<body>
<article>
<h1>Google Maps → Adobe Bridge coordinate converter</h1>
<p>Convert a Google Maps GPS coordinate (decimal latitude, longtitude) to a format that can be used within Adobe Bridge.</p>
<form id="form">
<p> <input type="text" name="latlon" placeholder="input lat, lon">
<input type="submit" name="submit" value="Compute"></p>
<p> <input type="textbox" name="latO" placeholder="output lat"><input type="textbox" name="lonO" placeholder="output lon"></p>
</form>
<h3>How To</h3>
<p>#1. Paste a Google Maps GPS coordinate into the input box.</p>
<p>#2. Hit Enter (or click Compute).</p>
<p>#3. Click an output box.</p>
<p>The converted coordinate is automatically copied once you click it.</p>
<p>Paste it into the corresponding metadata box in Adobe Bridge.</p>
<p>Enjøy!</p>
<h3>Examples</h3>
<p>Here's an example of a Google GPS Coordinate: <span id="tcoord">44.437132, 26.114168</span></p>
<p>Click it to copy it for testing.</p>
<p>Here's an example of formatted coordinates: 44,26.22792N, 26,6.85008W</p>
<hr>
<p>This app may not work in older browsers. Sorry for the inconvenience.</p>
<p>Note: This page does not use end-to-end encryption. However, as long as the GPS locations that you share with this page aren't confidential, then it poses no security risk.</p>
</article>
</body>
</html>
<script type="text/javascript">
// Aaah, snooping around, are we? Feel free to use any code found on this page for your own projects.
const form = document.getElementById("form");
function reformat(coord) {
let coordN = Math.floor(coord);
let coordD = coord-coordN;
return coordD*60;
}
form.submit.addEventListener('click', function (e) {
e.preventDefault();
let latlon = form.latlon.value;
let latlonA = form.latlon.value.split(",");
let lat = latlonA[0];
let lon = latlonA[1];
let latN = Math.floor(lat);
let latM = (lat-latN)*60;
let latC = latN + "," +latM.toFixed(5) + "N";
let lonN = Math.floor(lon);
let lonM = (lon-lonN)*60;
let lonC = lonN + "," +lonM.toFixed(5) + "W";
form.latO.value = latC;
form.lonO.value = lonC;
}, false);
form.latlon.addEventListener('click', function (e) {
this.form.latlon.value = "";
}, false);
form.latO.addEventListener('click', function (e) {
this.form.latO.select();
document.execCommand('copy');
}, false);
form.lonO.addEventListener('click', function (e) {
this.form.lonO.select();
document.execCommand('copy');
}, false);
const spanE = document.getElementById("tcoord");
function selectText(obj) {
if (window.getSelection && document.createRange) {
let sel = window.getSelection()
let range = document.createRange()
range.selectNodeContents(obj)
sel.removeAllRanges()
sel.addRange(range)
} else if (document.selection && document.body.createTextRange) {
let textRange = document.body.createTextRange()
textRange.moveToElementText(obj)
textRange.select()
}
}
spanE.addEventListener('click', function (e) {
selectText(spanE);
document.execCommand('copy');
}, false);
/*
Sample Google Coordinate:
44.437132, 26.114168
Where we want to end up:
44,26.22792N, 26,06.85008W
Process:
Separate number from decimals:
44
0.437132
Compute minutes from decimals:
0.437132*60=26.22792
Concatenate numbers:
44,26.22792
Add cardinal direction:
44,26.22792N
Repeat for second coordinate, but add W instead of N.
Congratulations! You now have coordinates fully formatted for Adobe Bridge.
*/
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment