@@ -354,7 +354,7 @@ function load() {
354354 overlay . draw = function ( ) { } ;
355355 overlay . setMap ( map ) ;
356356
357- google . maps . event . addListener ( map , 'idle ' , function ( ) {
357+ google . maps . event . addListener ( map , 'zoom_changed ' , function ( ) {
358358 updateZoom ( ) ;
359359 } ) ;
360360
@@ -530,9 +530,13 @@ function habitat_data(jsondata) {
530530function updateAltitude ( vcallsign ) {
531531 var pixel_altitude = 0 ;
532532 var zoom = map . getZoom ( ) ;
533- var position = vehicles [ vcallsign ] . curr_position ;
533+ var vehicle = vehicles [ vcallsign ] ;
534+ var position = vehicle . curr_position ;
534535
535- if ( vehicles [ vcallsign ] . marker . mode == 'landed' ) return ;
536+ if ( vehicle . marker . mode == 'landed' ) {
537+ vehicle . marker . setPosition ( vehicle . marker . getPosition ( ) ) ;
538+ return ;
539+ }
536540
537541 if ( zoom > 18 ) zoom = 18 ;
538542 if ( position . gps_alt > 0 ) {
@@ -543,15 +547,22 @@ function updateAltitude(vcallsign) {
543547 } else if ( position . gps_alt > 55000 ) {
544548 position . gps_alt = 55000 ;
545549 }
546- vehicles [ vcallsign ] . marker . setAltitude ( pixel_altitude ) ;
550+ vehicle . marker . setAltitude ( pixel_altitude ) ;
547551}
548552
549553function updateZoom ( ) {
550- for ( var vcallsign in vehicles ) {
551- if ( vehicles [ vcallsign ] . vehicle_type == "balloon" ) {
552- updateAltitude ( vcallsign ) ;
554+ for ( var vcallsign in vehicles ) {
555+ var vehicle = vehicles [ vcallsign ] ;
556+
557+ if ( vehicle . vehicle_type == "balloon" ) {
558+ updateAltitude ( vcallsign ) ;
559+ } else {
560+ vehicle . marker . setPosition ( vehicle . marker . getPosition ( ) ) ;
561+ }
562+
563+ if ( vehicle . marker_shadow )
564+ vehicle . marker_shadow . setPosition ( vehicle . marker_shadow . getPosition ( ) ) ;
553565 }
554- }
555566}
556567
557568function focusVehicle ( vcallsign , ignoreOpt ) {
@@ -1189,13 +1200,13 @@ function addPosition(position) {
11891200 } ;
11901201 }
11911202 this . setIcon ( img ) ;
1203+ this . setPosition ( this . getPosition ( ) ) ;
11921204 } ;
11931205 marker . setAltitude = function ( alt ) {
11941206 var pos = overlay . getProjection ( ) . fromLatLngToDivPixel ( this . shadow . getPosition ( ) ) ;
11951207 pos . y -= alt ;
11961208 this . setPosition ( overlay . getProjection ( ) . fromDivPixelToLatLng ( pos ) ) ;
11971209 } ;
1198- marker . setAltitude ( 0 ) ;
11991210
12001211 horizon_circle = new google . maps . Circle ( {
12011212 map : map ,
@@ -1210,6 +1221,35 @@ function addPosition(position) {
12101221 editable : false
12111222 } ) ;
12121223 horizon_circle . bindTo ( 'center' , marker_shadow , 'position' ) ;
1224+
1225+ // label
1226+ var label = new google . maps . Label ( { map : map , strokeColor : horizon_circle . get ( 'strokeColor' ) } ) ;
1227+ //label.bindTo('visible', horizon_circle, 'visible');
1228+ label . bindTo ( 'opacity' , horizon_circle , 'strokeOpacity' ) ;
1229+ label . bindTo ( 'zIndex' , horizon_circle , 'zIndex' ) ;
1230+ label . bindTo ( 'strokeColor' , horizon_circle , 'strokeColor' ) ;
1231+
1232+ var refresh_func = function ( ) {
1233+ if ( marker . mode == "landed" ) return ;
1234+
1235+ var north = google . maps . geometry . spherical . computeOffset ( horizon_circle . getCenter ( ) , horizon_circle . getRadius ( ) , 0 ) ;
1236+ var south = google . maps . geometry . spherical . computeOffset ( horizon_circle . getCenter ( ) , horizon_circle . getRadius ( ) , 180 ) ;
1237+
1238+ var projection = label . getProjection ( ) ;
1239+ var dist = projection . fromLatLngToDivPixel ( south ) . y -
1240+ projection . fromLatLngToDivPixel ( north ) . y ;
1241+
1242+ var val = horizon_circle . getRadius ( ) / 1000 ;
1243+ val = offline . get ( 'opt_imperial' ) ? Math . round ( val * 0.621371192 ) + "mi" : Math . round ( val ) + "km" ;
1244+
1245+ label . set ( 'visible' , ( 75 < dist ) ) ;
1246+ label . set ( 'position' , google . maps . geometry . spherical . computeOffset ( horizon_circle . getCenter ( ) , horizon_circle . getRadius ( ) , 180 ) ) ;
1247+ label . set ( 'text' , val ) ;
1248+ } ;
1249+
1250+ google . maps . event . addListener ( horizon_circle , 'center_changed' , refresh_func ) ;
1251+ google . maps . event . addListener ( horizon_circle , 'radius_changed' , refresh_func ) ;
1252+
12131253 subhorizon_circle = new google . maps . Circle ( {
12141254 map : map ,
12151255 radius : 1 ,
@@ -1223,7 +1263,48 @@ function addPosition(position) {
12231263 editable : false
12241264 } ) ;
12251265 subhorizon_circle . bindTo ( 'center' , marker_shadow , 'position' ) ;
1266+
1267+ var label2 = new google . maps . Label ( { map : map , strokeColor : subhorizon_circle . get ( 'strokeColor' ) } ) ;
1268+ //label2.bindTo('visible', subhorizon_circle, 'visible');
1269+ label2 . bindTo ( 'opacity' , subhorizon_circle , 'strokeOpacity' ) ;
1270+ label2 . bindTo ( 'zIndex' , subhorizon_circle , 'zIndex' ) ;
1271+ label2 . bindTo ( 'strokeColor' , subhorizon_circle , 'strokeColor' ) ;
1272+
1273+ refresh_func = function ( ) {
1274+ if ( marker . mode == "landed" ) return ;
1275+
1276+ var north = google . maps . geometry . spherical . computeOffset ( subhorizon_circle . getCenter ( ) , subhorizon_circle . getRadius ( ) , 0 ) ;
1277+ var south = google . maps . geometry . spherical . computeOffset ( subhorizon_circle . getCenter ( ) , subhorizon_circle . getRadius ( ) , 180 ) ;
1278+
1279+ var projection = label2 . getProjection ( ) ;
1280+ var dist = projection . fromLatLngToDivPixel ( south ) . y -
1281+ projection . fromLatLngToDivPixel ( north ) . y ;
1282+
1283+ var val = subhorizon_circle . getRadius ( ) / 1000 ;
1284+ val = offline . get ( 'opt_imperial' ) ? Math . round ( val * 0.621371192 ) + "mi" : Math . round ( val ) + "km" ;
1285+
1286+ label2 . set ( 'visible' , ( 75 < dist ) ) ;
1287+ label2 . set ( 'position' , google . maps . geometry . spherical . computeOffset ( subhorizon_circle . getCenter ( ) , subhorizon_circle . getRadius ( ) , 180 ) ) ;
1288+ label2 . set ( 'text' , val ) ;
1289+ } ;
1290+ google . maps . event . addListener ( subhorizon_circle , 'center_changed' , refresh_func ) ;
1291+ google . maps . event . addListener ( subhorizon_circle , 'radius_changed' , refresh_func ) ;
1292+
1293+ marker . setAltitude ( 0 ) ;
12261294 }
1295+
1296+ // add label above every marker
1297+ var mlabel = new google . maps . Label ( { map : map , textOnly : true , position : marker . getPosition ( ) } ) ;
1298+ mlabel . bindTo ( 'text' , marker , 'title' ) ;
1299+ mlabel . bindTo ( 'zIndex' , marker , 'zIndex' ) ;
1300+ google . maps . event . addListener ( marker , 'position_changed' , function ( ) {
1301+ var pos = mlabel . getProjection ( ) . fromLatLngToDivPixel ( marker . getPosition ( ) ) ;
1302+ pos . y -= marker . icon . size . height + 10 ;
1303+ mlabel . set ( 'position' , mlabel . getProjection ( ) . fromDivPixelToLatLng ( pos ) ) ;
1304+ } ) ;
1305+ marker . _label = mlabel ;
1306+ marker . setPosition ( marker . getPosition ( ) ) ; // activates the logic above to reposition the label
1307+
12271308 var vehicle_info = {
12281309 uuid : elm_uuid ++ ,
12291310 vehicle_type : vehicle_type ,
0 commit comments