Skip to content

Commit a681e91

Browse files
Mark JessopMark Jessop
authored andcommitted
Fix geo links on prediction popups
1 parent d702d51 commit a681e91

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

js/tracker.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2281,10 +2281,27 @@ function mapInfoBox_handle_prediction(event) {
22812281
altitude = Math.round(data.alt) + " m";
22822282
}
22832283

2284+
var coords_text;
2285+
var ua = navigator.userAgent.toLowerCase();
2286+
2287+
// determine how to link the vehicle coordinates to a native app, if on a mobile device
2288+
if(ua.indexOf('iphone') > -1) {
2289+
coords_text = '<a href="maps://?q='+data.lat+','+data.lon+'">' +
2290+
roundNumber(data.lat, 5) + ', ' + roundNumber(data.lon, 5) + '</a>';
2291+
} else if(ua.indexOf('android') > -1) {
2292+
coords_text = '<a href="geo:'+data.lat+','+data.lon+'?q='+data.lat+','+data.lon+'(Prediction)">' +
2293+
roundNumber(data.lat, 5) + ', ' + roundNumber(data.lon, 5) +'</a>';
2294+
} else {
2295+
coords_text = '<a href="https://www.google.com/maps/search/?api=1&query='+data.lat+','+data.lon+'" target="_blank" rel="noopener noreferrer">' +
2296+
roundNumber(data.lat, 5) + ', ' + roundNumber(data.lon, 5) +'</a>';
2297+
}
2298+
22842299
mapInfoBox.setContent("<pre>" +
22852300
formatDate(new Date(parseInt(data.time) * 1000), true) + "\n\n" +
22862301
"<b>Altitude:</b> " + altitude + "\n" +
2287-
"<b>Location:</b> <a href='geo:" + data.lat.toFixed(5) + "," + data.lon.toFixed(5) + "'>" + data.lat.toFixed(5) + ", " + data.lon.toFixed(5) + "</a>\n" +
2302+
"<b>Location:</b> " + coords_text +
2303+
//<a href='geo:" + data.lat.toFixed(5) + "," + data.lon.toFixed(5) + "'>" + data.lat.toFixed(5) + ", " + data.lon.toFixed(5) + "</a>"
2304+
"\n" +
22882305
event.target.pred_type +
22892306
"</pre>"
22902307
);

0 commit comments

Comments
 (0)