-
Notifications
You must be signed in to change notification settings - Fork 2
/
ShowOnGoogleMaps.jsx
41 lines (41 loc) · 1.62 KB
/
ShowOnGoogleMaps.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//@target bridge
if (BridgeTalk.appName === "bridge") {
mapFromGPS = MenuElement.create("command", "Show location on Google Maps", "at the end of Thumbnail");
}
mapFromGPS.onSelect = function () {
if (app.document.selections.length < 1) return;
var thumb = app.document.selections[0];
var md = thumb.synchronousMetadata;
md.namespace = "http://ns.adobe.com/exif/1.0/";
var lat = md.GPSLatitude ? md.GPSLatitude : "" ;
var lon = md.GPSLongitude ? md.GPSLongitude : "";
if (lat === "") return;
if (lon === "") return;
var latparts = lat.match(/\d+/g);
var lat1 = (Number(latparts[0]) +(Number(latparts[1].toString()+"."+latparts[2].toString())/60)).toFixed(4);
var lonparts = lon.match(/\d+/g);
var lon1 = (Number(lonparts[0]) +(Number(lonparts[1].toString()+"."+lonparts[2].toString())/60)).toFixed(4);
var latneg = "";
switch (lat.match(/.$/).toString()) {
case "S":
latneg = "-";
break;
case "W":
latneg = "-";
break;
}
var lonneg = "";
switch (lon.match(/.$/).toString()){
case "S":
lonneg = "-";
break;
case "W":
lonneg = "-";
break;
}
var latResult = latneg+lat1;
var lonResult = lonneg+lon1;
// var cmd = "start /B \"C:\\Program Files\\Mozilla Firefox\\firefox.exe\" \""+ "https://www.google.com/maps/search/?api=1&query=" + latResult + "," + lonResult + "\"";
var cmd = "start /B \"\" \"https://www.google.com/maps/search/?api=1&query=" + latResult + "," + lonResult + "\""; // Should open url in default browser
app.system(cmd);
};