Skip to content

Commit ad079fa

Browse files
Mark JessopMark Jessop
authored andcommitted
Switch geo links on predictions to same method used in info pane
1 parent 638c218 commit ad079fa

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
@@ -2687,10 +2687,27 @@ function mapInfoBox_handle_prediction(event) {
26872687
altitude = Math.round(data.alt) + " m";
26882688
}
26892689

2690+
var coords_text;
2691+
var ua = navigator.userAgent.toLowerCase();
2692+
2693+
// determine how to link the vehicle coordinates to a native app, if on a mobile device
2694+
if(ua.indexOf('iphone') > -1) {
2695+
coords_text = '<a href="maps://?q='+data.lat+','+data.lon+'">' +
2696+
roundNumber(data.lat, 5) + ', ' + roundNumber(data.lon, 5) + '</a>';
2697+
} else if(ua.indexOf('android') > -1) {
2698+
coords_text = '<a href="geo:'+data.lat+','+data.lon+'?q='+data.lat+','+data.lon+'(Prediction)">' +
2699+
roundNumber(data.lat, 5) + ', ' + roundNumber(data.lon, 5) +'</a>';
2700+
} else {
2701+
coords_text = '<a href="https://www.google.com/maps/search/?api=1&query='+data.lat+','+data.lon+'" target="_blank" rel="noopener noreferrer">' +
2702+
roundNumber(data.lat, 5) + ', ' + roundNumber(data.lon, 5) +'</a>';
2703+
}
2704+
26902705
mapInfoBox.setContent("<pre>" +
26912706
formatDate(new Date(parseInt(data.time) * 1000), true) + "\n\n" +
26922707
"<b>Altitude:</b> " + altitude + "\n" +
2693-
"<b>Location:</b> <a href='geo:" + data.lat.toFixed(5) + "," + data.lon.toFixed(5) + "'>" + data.lat.toFixed(5) + ", " + data.lon.toFixed(5) + "</a>\n" +
2708+
"<b>Location:</b> " + coords_text +
2709+
//<a href='geo:" + data.lat.toFixed(5) + "," + data.lon.toFixed(5) + "'>" + data.lat.toFixed(5) + ", " + data.lon.toFixed(5) + "</a>"
2710+
"\n" +
26942711
event.target.pred_type +
26952712
"</pre>"
26962713
);

0 commit comments

Comments
 (0)