Adding distance display to the info windows.
This commit is contained in:
parent
5cd0847362
commit
4423c7f13a
@ -353,6 +353,23 @@ $(function(){
|
|||||||
'">' + callsign + '</a>';
|
'">' + callsign + '</a>';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var distanceKm = function(p1, p2) {
|
||||||
|
// Earth radius in km
|
||||||
|
var R = 6371.0;
|
||||||
|
// Convert degrees to radians
|
||||||
|
var rlat1 = p1.lat() * (Math.PI/180);
|
||||||
|
var rlat2 = p2.lat() * (Math.PI/180);
|
||||||
|
// Compute difference in radians
|
||||||
|
var difflat = rlat2-rlat1;
|
||||||
|
var difflon = (p2.lng()-p1.lng()) * (Math.PI/180);
|
||||||
|
// Compute distance
|
||||||
|
d = 2 * R * Math.asin(Math.sqrt(
|
||||||
|
Math.sin(difflat/2) * Math.sin(difflat/2) +
|
||||||
|
Math.cos(rlat1) * Math.cos(rlat2) * Math.sin(difflon/2) * Math.sin(difflon/2)
|
||||||
|
));
|
||||||
|
return Math.round(d);
|
||||||
|
}
|
||||||
|
|
||||||
var infowindow;
|
var infowindow;
|
||||||
var showLocatorInfoWindow = function(locator, pos) {
|
var showLocatorInfoWindow = function(locator, pos) {
|
||||||
var infowindow = getInfoWindow();
|
var infowindow = getInfoWindow();
|
||||||
@ -364,8 +381,10 @@ $(function(){
|
|||||||
}).sort(function(a, b){
|
}).sort(function(a, b){
|
||||||
return b.lastseen - a.lastseen;
|
return b.lastseen - a.lastseen;
|
||||||
});
|
});
|
||||||
|
var distance = receiverMarker?
|
||||||
|
" (at " + distanceKm(receiverMarker.position, pos) + "km)" : "";
|
||||||
infowindow.setContent(
|
infowindow.setContent(
|
||||||
'<h3>Locator: ' + locator + '</h3>' +
|
'<h3>Locator: ' + locator + distance + '</h3>' +
|
||||||
'<div>Active Callsigns:</div>' +
|
'<div>Active Callsigns:</div>' +
|
||||||
'<ul>' +
|
'<ul>' +
|
||||||
inLocator.map(function(i){
|
inLocator.map(function(i){
|
||||||
|
Loading…
Reference in New Issue
Block a user