Add a "follow" link to the selected plane info.
This commit is contained in:
parent
35e0364670
commit
b78b28d95f
|
@ -116,7 +116,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr class="infoblock_body">
|
<tr class="infoblock_body">
|
||||||
<td colspan="2">Position: <span id="selected_position">n/a</span></td>
|
<td colspan="2">Position: <span id="selected_position">n/a</span> <span id="selected_follow" onclick="toggleFollowSelected();" class="pointer">[ follow ⇒ ]</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr class="infoblock_body">
|
<tr class="infoblock_body">
|
||||||
|
|
|
@ -5,6 +5,7 @@ var GoogleMap = null;
|
||||||
var Planes = {};
|
var Planes = {};
|
||||||
var PlanesOrdered = [];
|
var PlanesOrdered = [];
|
||||||
var SelectedPlane = null;
|
var SelectedPlane = null;
|
||||||
|
var FollowSelected = false;
|
||||||
|
|
||||||
var SpecialSquawks = {
|
var SpecialSquawks = {
|
||||||
'7500' : { cssClass: 'squawk7500', markerColor: 'rgb(255, 85, 85)', text: 'Aircraft Hijacking' },
|
'7500' : { cssClass: 'squawk7500', markerColor: 'rgb(255, 85, 85)', text: 'Aircraft Hijacking' },
|
||||||
|
@ -414,6 +415,14 @@ function initialize_map() {
|
||||||
google.maps.event.addListener(GoogleMap, 'center_changed', function() {
|
google.maps.event.addListener(GoogleMap, 'center_changed', function() {
|
||||||
localStorage['CenterLat'] = GoogleMap.getCenter().lat();
|
localStorage['CenterLat'] = GoogleMap.getCenter().lat();
|
||||||
localStorage['CenterLon'] = GoogleMap.getCenter().lng();
|
localStorage['CenterLon'] = GoogleMap.getCenter().lng();
|
||||||
|
if (FollowSelected) {
|
||||||
|
// On manual navigation, disable follow
|
||||||
|
var selected = Planes[SelectedPlane];
|
||||||
|
if (Math.abs(GoogleMap.getCenter().lat() - selected.position.lat()) > 0.0001 &&
|
||||||
|
Math.abs(GoogleMap.getCenter().lng() - selected.position.lng()) > 0.0001) {
|
||||||
|
FollowSelected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
google.maps.event.addListener(GoogleMap, 'zoom_changed', function() {
|
google.maps.event.addListener(GoogleMap, 'zoom_changed', function() {
|
||||||
|
@ -637,12 +646,16 @@ function refreshSelected() {
|
||||||
|
|
||||||
if (selected.position === null) {
|
if (selected.position === null) {
|
||||||
$('#selected_position').text('n/a');
|
$('#selected_position').text('n/a');
|
||||||
|
$('#selected_follow').addClass('hidden');
|
||||||
} else {
|
} else {
|
||||||
if (selected.seen_pos > 1) {
|
if (selected.seen_pos > 1) {
|
||||||
$('#selected_position').text(format_latlng(selected.position) + " (" + selected.seen_pos + "s ago)");
|
$('#selected_position').text(format_latlng(selected.position) + " (" + selected.seen_pos + "s ago)");
|
||||||
} else {
|
} else {
|
||||||
$('#selected_position').text(format_latlng(selected.position));
|
$('#selected_position').text(format_latlng(selected.position));
|
||||||
}
|
}
|
||||||
|
$('#selected_follow').removeClass('hidden');
|
||||||
|
if (FollowSelected)
|
||||||
|
GoogleMap.panTo(selected.position);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#selected_sitedist').text(format_distance_long(selected.sitedist));
|
$('#selected_sitedist').text(format_distance_long(selected.sitedist));
|
||||||
|
@ -811,6 +824,12 @@ function selectPlaneByHex(hex) {
|
||||||
SelectedPlane = null;
|
SelectedPlane = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FollowSelected = false;
|
||||||
|
refreshSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleFollowSelected() {
|
||||||
|
FollowSelected = !FollowSelected;
|
||||||
refreshSelected();
|
refreshSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue