@@ -572,7 +572,9 @@ function habitat_data(jsondata, alternative) {
572572 "radiation" : "Radiation (CPM)" ,
573573 "temperature_radio" : "Temperature, Radio" ,
574574 "uplink_rssi" : "Uplink RSSI" ,
575- "light_intensity" : "Light Intensity"
575+ "light_intensity" : "Light Intensity" ,
576+ "pred_lat" : "Onboard Prediction (Lat)" ,
577+ "pred_lon" : "Onboard Prediction (Lon)"
576578 } ;
577579
578580 var hide_keys = {
@@ -919,6 +921,53 @@ function updateVehicleInfo(vcallsign, newPosition) {
919921 } else {
920922 vehicle . marker . setMode ( "parachute" ) ;
921923 }
924+
925+ // Update landing marker if data is available
926+ if ( newPosition . data . hasOwnProperty ( "pred_lat" ) && newPosition . data . hasOwnProperty ( "pred_lon" ) ) {
927+ // Landing prediction data exists..
928+ if ( vehicle . landing_marker !== null ) {
929+ // We already have a marker initialized.
930+ if ( newPosition . gps_alt > 350 ) {
931+ // Balloon is still in flight, so update the marker.
932+ vehicle . landing_marker . setPosition ( new google . maps . LatLng ( newPosition . data . pred_lat , newPosition . data . pred_lon ) ) ;
933+ // Re-add to map if it's been removed previously.
934+ if ( vehicle . landing_marker . getMap ( ) == null ) {
935+ vehicle . landing_marker . setMap ( map ) ;
936+ }
937+ } else {
938+ // Balloon has landed, so hide the marker.
939+ // Should we do this? Can we re-add it safely?
940+ vehicle . landing_marker . setMap ( null ) ;
941+ }
942+ } else {
943+ // Landing marker has not been initialised yet.
944+ if ( ( newPosition . data . pred_lat !== 0.0 ) && ( newPosition . data . pred_lon !== 0.0 ) ) {
945+
946+ landing_image_src = host_url + markers_url + "balloon-xmark.png" ;
947+ landing_image_src_size = new google . maps . Size ( 48 , 38 ) ;
948+ landing_image_src_offset = new google . maps . Point ( 0 , - 38 ) ;
949+
950+ landing_marker = new google . maps . Marker ( {
951+ icon : {
952+ url : landing_image_src ,
953+ size : landing_image_src_size ,
954+ scaledSize : landing_image_src_size ,
955+ anchor : new google . maps . Point ( 24 , 18 )
956+ } ,
957+ zIndex : Z_CAR ,
958+ position : new google . maps . LatLng ( position . data . pred_lat , position . data . pred_lon ) ,
959+ map : map ,
960+ optimized : false ,
961+ title : vcallsign + " Onboard Landing Prediction"
962+ } ) ;
963+
964+ // Add the marker to the map, and to the vehicle object.
965+ landing_marker . setMap ( map ) ;
966+ vehicle . landing_marker = landing_marker ;
967+ }
968+
969+ }
970+ }
922971 }
923972
924973 var image = vehicle . image_src ;
@@ -1657,6 +1706,34 @@ function addPosition(position) {
16571706 this . setPosition ( overlay . getProjection ( ) . fromDivPixelToLatLng ( pos ) ) ;
16581707 } ;
16591708
1709+ // Add landing marker if the payload provides a predicted landing position.
1710+ // TODO: Only create this if the lat/lon are not zero.
1711+ if ( position . data . hasOwnProperty ( 'pred_lat' ) && position . data . hasOwnProperty ( 'pred_lon' ) ) {
1712+ // Only create the marker if the pred lat/lon are not zero (as will be the case during ascent).
1713+ if ( ( position . data . pred_lat !== 0.0 ) && ( position . data . pred_lon !== 0.0 ) ) {
1714+ landing_image_src = host_url + markers_url + "balloon-xmark.png" ;
1715+ landing_image_src_size = new google . maps . Size ( 48 , 38 ) ;
1716+ landing_image_src_offset = new google . maps . Point ( 0 , - 38 ) ;
1717+
1718+ landing_marker = new google . maps . Marker ( {
1719+ icon : {
1720+ url : landing_image_src ,
1721+ size : landing_image_src_size ,
1722+ scaledSize : landing_image_src_size ,
1723+ anchor : new google . maps . Point ( 24 , 18 )
1724+ } ,
1725+ zIndex : Z_CAR ,
1726+ position : new google . maps . LatLng ( position . data . pred_lat , position . data . pred_lon ) ,
1727+ map : map ,
1728+ optimized : false ,
1729+ title : vcallsign + " Onboard Landing Prediction"
1730+ } ) ;
1731+ gmaps_elements . push ( landing_marker ) ;
1732+ }
1733+ } else {
1734+ landing_marker = null ;
1735+ }
1736+
16601737 horizon_circle = new google . maps . Circle ( {
16611738 map : map ,
16621739 zIndex : Z_RANGE ,
@@ -1790,6 +1867,7 @@ function addPosition(position) {
17901867 vehicle_type : vehicle_type ,
17911868 marker : marker ,
17921869 marker_shadow : marker_shadow ,
1870+ landing_marker : landing_marker ,
17931871 image_src : image_src ,
17941872 image_src_size : image_src_size ,
17951873 image_src_offset : image_src_offset ,
0 commit comments