@@ -998,27 +998,25 @@ function load() {
998998 map . on ( 'zoomend' , function ( ) {
999999 sub_to_nearby_sondes ( ) ;
10001000 //do check for horizon labels
1001- if ( offline . get ( "opt_hide_horizon" ) ) {
1002- for ( key in vehicles ) {
1003- if ( vehicles [ key ] [ "vehicle_type" ] == "balloon" ) {
1004- if ( vehicles [ key ] [ "horizon_circle" ] [ "_map" ] )
1005- {
1006- try {
1007- var zoom = map . getZoom ( ) ;
1008- var horizonzoom = ( Math . abs ( Math . log ( vehicles [ key ] [ "horizon_circle" ] . getRadius ( ) / 2000000 ) / 0.75 ) ) ;
1009- var subhorizonzoom = ( Math . abs ( Math . log ( vehicles [ key ] [ "subhorizon_circle" ] . getRadius ( ) / 2000000 ) / 0.75 ) ) ;
1010- if ( horizonzoom > zoom ) {
1011- map . removeLayer ( vehicles [ key ] [ "horizon_circle_title" ] ) ;
1012- } else {
1013- map . addLayer ( vehicles [ key ] [ "horizon_circle_title" ] ) ;
1014- }
1015- if ( subhorizonzoom > zoom ) {
1016- map . removeLayer ( vehicles [ key ] [ "subhorizon_circle_title" ] ) ;
1017- } else {
1018- map . addLayer ( vehicles [ key ] [ "subhorizon_circle_title" ] ) ;
1019- }
1020- } catch ( e ) { } ;
1021- }
1001+ for ( key in vehicles ) {
1002+ if ( vehicles [ key ] [ "vehicle_type" ] == "balloon" ) {
1003+ if ( vehicles [ key ] [ "horizon_circle" ] [ "_map" ] )
1004+ {
1005+ try {
1006+ var zoom = map . getZoom ( ) ;
1007+ var horizonzoom = ( Math . abs ( Math . log ( vehicles [ key ] [ "horizon_circle" ] . getRadius ( ) / 2000000 ) / 0.75 ) ) ;
1008+ var subhorizonzoom = ( Math . abs ( Math . log ( vehicles [ key ] [ "subhorizon_circle" ] . getRadius ( ) / 2000000 ) / 0.75 ) ) ;
1009+ if ( horizonzoom > zoom ) {
1010+ map . removeLayer ( vehicles [ key ] [ "horizon_circle_title" ] ) ;
1011+ } else {
1012+ map . addLayer ( vehicles [ key ] [ "horizon_circle_title" ] ) ;
1013+ }
1014+ if ( subhorizonzoom > zoom ) {
1015+ map . removeLayer ( vehicles [ key ] [ "subhorizon_circle_title" ] ) ;
1016+ } else {
1017+ map . addLayer ( vehicles [ key ] [ "subhorizon_circle_title" ] ) ;
1018+ }
1019+ } catch ( e ) { } ;
10221020 }
10231021 }
10241022 }
@@ -1564,6 +1562,7 @@ function stopFollow(no_data_reset) {
15641562 if ( follow_vehicle !== null ) {
15651563 if ( ! no_data_reset ) {
15661564 focusVehicle ( null ) ;
1565+ hideHorizonRings ( ) ;
15671566
15681567 // remove target mark
15691568 $ ( "#main .row.follow" ) . removeClass ( "follow" ) ;
@@ -1612,6 +1611,7 @@ function followVehicle(vcallsign, noPan, force) {
16121611
16131612 follow_vehicle = vcallsign ;
16141613 vehicles [ follow_vehicle ] . follow = true ;
1614+ updateHorizonVisibility ( ) ;
16151615
16161616 // add target mark
16171617 $ ( "#main .row.follow" ) . removeClass ( "follow" ) ;
@@ -3307,12 +3307,7 @@ function addPosition(position) {
33073307 } else {
33083308 map . addLayer ( vehicle . marker . shadow ) ;
33093309
3310- if ( ! offline . get ( 'opt_hide_horizon' ) == false ) {
3311- map . addLayer ( vehicle . horizon_circle ) ;
3312- map . addLayer ( vehicle . subhorizon_circle ) ;
3313- map . addLayer ( vehicle . horizon_circle_title ) ;
3314- map . addLayer ( vehicle . subhorizon_circle_title ) ;
3315- }
3310+ updateHorizonVisibility ( ) ;
33163311
33173312 if ( mode == "parachute" ) {
33183313 img_src = recolorSVG ( host_url + markers_url + "parachute.svg" , this . balloonColor ) ;
@@ -3384,11 +3379,6 @@ function addPosition(position) {
33843379 title : "Line-of-right (radio) horizon of the payload"
33853380 } ) ;
33863381
3387- if ( offline . get ( "opt_hide_horizon" ) ) {
3388- horizon_circle . addTo ( map ) ;
3389- horizon_circle_title . addTo ( map ) ;
3390- }
3391-
33923382 horizon_circle . on ( 'move' , function ( e ) {
33933383 try {
33943384 var latlng = L . latLng ( e . target . getBounds ( ) . _southWest . lat , ( ( e . target . getBounds ( ) . _northEast . lng + e . target . getBounds ( ) . _southWest . lng ) / 2 ) ) ;
@@ -3417,11 +3407,6 @@ function addPosition(position) {
34173407 title : "Payload is greater than 5 degrees above the horizon within this circle, which indicates it should be fairly easily receivable."
34183408 } ) ;
34193409
3420- if ( offline . get ( "opt_hide_horizon" ) ) {
3421- subhorizon_circle . addTo ( map ) ;
3422- subhorizon_circle_title . addTo ( map ) ;
3423- }
3424-
34253410 subhorizon_circle . on ( 'move' , function ( e ) {
34263411 try {
34273412 var latlng = L . latLng ( e . target . getBounds ( ) . _southWest . lat , ( ( e . target . getBounds ( ) . _northEast . lng + e . target . getBounds ( ) . _southWest . lng ) / 2 ) ) ;
@@ -3587,6 +3572,7 @@ function addPosition(position) {
35873572 }
35883573
35893574 vehicles [ vcallsign ] = vehicle_info ;
3575+ updateHorizonVisibility ( ) ;
35903576 }
35913577
35923578 var vehicle = vehicles [ vcallsign ] ;
@@ -5059,17 +5045,21 @@ function hideHorizonRings(){
50595045 }
50605046}
50615047
5062- function showHorizonRings ( ) {
5063- for ( var vcallsign in vehicles ) {
5064- if ( vehicles [ vcallsign ] . vehicle_type == "balloon" ) {
5065- map . addLayer ( vehicles [ vcallsign ] . horizon_circle ) ;
5066- map . addLayer ( vehicles [ vcallsign ] . subhorizon_circle ) ;
5067- vehicles [ vcallsign ] . horizon_circle . fire ( "move" )
5068- vehicles [ vcallsign ] . subhorizon_circle . fire ( "move" )
5069- map . addLayer ( vehicles [ vcallsign ] . horizon_circle_title ) ;
5070- map . addLayer ( vehicles [ vcallsign ] . subhorizon_circle_title ) ;
5071- }
5072- }
5048+ function updateHorizonVisibility ( ) {
5049+ // Only show horizon rings for the sonde we are currently 'following'
5050+ // (the last selected sonde)
5051+ hideHorizonRings ( ) ;
5052+
5053+ if ( follow_vehicle === null ) return ;
5054+ if ( ! vehicles . hasOwnProperty ( follow_vehicle ) ) return ;
5055+ if ( vehicles [ follow_vehicle ] . vehicle_type != "balloon" ) return ;
5056+
5057+ map . addLayer ( vehicles [ follow_vehicle ] . horizon_circle ) ;
5058+ map . addLayer ( vehicles [ follow_vehicle ] . subhorizon_circle ) ;
5059+ vehicles [ follow_vehicle ] . horizon_circle . fire ( "move" ) ;
5060+ vehicles [ follow_vehicle ] . subhorizon_circle . fire ( "move" ) ;
5061+ map . addLayer ( vehicles [ follow_vehicle ] . horizon_circle_title ) ;
5062+ map . addLayer ( vehicles [ follow_vehicle ] . subhorizon_circle_title ) ;
50735063}
50745064
50755065function hideTitles ( ) {
0 commit comments