Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Initial stab at per-payload onboard landing prediction markers.
  • Loading branch information
darksidelemm committed Sep 14, 2019
commit 2e74897551a5d45feb5080691aff077aca5ad2fd
45 changes: 45 additions & 0 deletions js/tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,26 @@ function updateVehicleInfo(vcallsign, newPosition) {
} else {
vehicle.marker.setMode("parachute");
}

// Update landing marker if data is available
if (newPosition.data.hasOwnProperty("pred_lat") && newPosition.data.hasOwnProperty("pred_lon")){
// Landing prediction data exists..
if (vehicle.landing_marker !== null){
// We already have a marker initialized.
if(newPosition.gps_alt > 350){
// Balloon is still in flight, so update the marker.
vehicle.landing_marker.setPosition(new google.maps.LatLng(newPosition.data.pred_lat, newPosition.data.pred_lon));
// Re-add to map if it's been removed previously.
if (vehicle.landing_marker.getMap() == null){
vehicle.landing_marker.setMap(map);
}
}else{
// Balloon has landed, so hide the marker.
// Should we do this? Can we re-add it safely?
vehicle.landing_marker.setMap(null);
}
}
}
}

var image = vehicle.image_src;
Expand Down Expand Up @@ -1657,6 +1677,30 @@ function addPosition(position) {
this.setPosition(overlay.getProjection().fromDivPixelToLatLng(pos));
};

// Add landing marker if the payload provides a predicted landing position.
if (position.data.hasOwnProperty('pred_lat') && position.data.hasOwnProperty('pred_lon')){
landing_image_src = host_url + markers_url + "balloon-xmark.png";
landing_image_src_size = new google.maps.Size(48,38);
landing_image_src_offset = new google.maps.Point(0,-38);

landing_marker = new google.maps.Marker({
icon: {
url: landing_image_src,
size: landing_image_src_size,
scaledSize: landing_image_src_size,
anchor: new google.maps.Point(24,18)
},
zIndex: Z_CAR,
position: new google.maps.LatLng(position.data.pred_lat, position.data.pred_lon),
map: map,
optimized: false,
title: vcallsign + " Onboard Landing Prediction"
});
gmaps_elements.push(landing_marker);
} else {
landing_marker = null;
}

horizon_circle = new google.maps.Circle({
map: map,
zIndex: Z_RANGE,
Expand Down Expand Up @@ -1790,6 +1834,7 @@ function addPosition(position) {
vehicle_type: vehicle_type,
marker: marker,
marker_shadow: marker_shadow,
landing_marker: landing_marker,
image_src: image_src,
image_src_size: image_src_size,
image_src_offset: image_src_offset,
Expand Down