@@ -1269,13 +1269,15 @@ function updateVehicleInfo(vcallsign, newPosition) {
12691269 // Balloon is still in flight, so update the marker.
12701270 vehicle . landing_marker . setLatLng ( new L . LatLng ( newPosition . data . pred_lat , newPosition . data . pred_lon ) ) ;
12711271 // Re-add to map if it's been removed previously.
1272- if ( vehicle . landing_marker . getMap ( ) == null ) {
1273- map . addLayer ( vehicle . landing_marker ) ;
1272+ if ( vehicle . landing_marker_enabled == false ) {
1273+ vehicle . landing_marker . addTo ( map ) ;
1274+ vehicle . landing_marker_enabled = true ;
12741275 }
12751276 } else {
12761277 // Balloon has landed, so hide the marker.
12771278 // Should we do this? Can we re-add it safely?
1278- map . removeLayer ( vehicle . landing_marker ) ;
1279+ vehicle . landing_marker . remove ( ) ;
1280+ vehicle . landing_marker_enabled = false ;
12791281 }
12801282 } else {
12811283 // Landing marker has not been initialised yet.
@@ -1301,6 +1303,7 @@ function updateVehicleInfo(vcallsign, newPosition) {
13011303
13021304 // Add the marker to the vehicle object.
13031305 vehicle . landing_marker = landing_marker ;
1306+ vehicle . landing_marker_enabled = true ;
13041307 }
13051308
13061309 }
@@ -2496,11 +2499,14 @@ function addPosition(position) {
24962499 title : vcallsign + " Onboard Landing Prediction" ,
24972500 zIndexOffset : Z_CAR ,
24982501 } ) . addTo ( map ) ;
2502+ landing_marker_enabled = true ;
24992503 } else {
25002504 landing_marker = null ;
2505+ landing_marker_enabled = false ;
25012506 }
25022507 } else {
25032508 landing_marker = null ;
2509+ landing_marker_enabled = false ;
25042510 }
25052511
25062512 horizon_circle = new L . Circle ( point , {
@@ -2595,6 +2601,7 @@ function addPosition(position) {
25952601 title : title ,
25962602 marker_shadow : marker_shadow ,
25972603 landing_marker : landing_marker ,
2604+ landing_marker_enabled : landing_marker_enabled ,
25982605 image_src : image_src ,
25992606 image_src_size : image_src_size ,
26002607 image_src_offset : image_src_offset ,
0 commit comments