@@ -428,6 +428,27 @@ function load() {
428428
429429 L . control . status ( { position : 'bottomright' } ) . addTo ( map ) ;
430430
431+ L . Control . PeriodControl = L . Control . extend ( {
432+ onAdd : function ( map ) {
433+ var div = L . DomUtil . create ( 'div' ) ;
434+
435+ div . innerHTML = '<select name="timeperiod" id="timeperiod" style="width:auto !important;height:30px;" onchange="clean_refresh(this.value)"><option value="1 hour">1 hour</option><option value="3 hours" selected="selected">3 hours</option><option value="6 hours">6 hours</option><option value="12 hours">12 hours</option></select>' ;
436+ div . innerHTML . onload = setTimeValue ( ) ;
437+
438+ return div ;
439+ } ,
440+
441+ onRemove : function ( map ) {
442+ // Nothing to do here
443+ }
444+ } ) ;
445+
446+ L . control . periodcontrol = function ( opts ) {
447+ return new L . Control . PeriodControl ( opts ) ;
448+ }
449+
450+ L . control . periodcontrol ( { position : 'topleft' } ) . addTo ( map ) ;
451+
431452 // update current position if we geolocation is available
432453 if ( currentPosition ) updateCurrentPosition ( currentPosition . lat , currentPosition . lon ) ;
433454
@@ -449,15 +470,7 @@ function load() {
449470 showLaunchSites ( ) ;
450471 map . addLayer ( launches ) ;
451472 }
452-
453- map . on ( 'moveend' , function ( e ) {
454- lhash_update ( ) ;
455- } ) ;
456-
457- map . on ( 'baselayerchange' , function ( e ) {
458- selectedLayer = e . layer . id ;
459- } ) ;
460-
473+
461474 map . on ( 'zoomend' , function ( ) {
462475 //do check for horizon labels
463476 if ( ! offline . get ( "opt_hide_horizon" ) ) {
@@ -491,42 +504,20 @@ function load() {
491504 if ( ! wvar . embeded ) manual_pan = true ;
492505 } ) ;
493506
494- // only start population the map, once its completely loaded
495- var callBack = function ( ) {
507+ map . once ( 'move' , function ( ) {
496508 load_hash ( null ) ;
497509
498- L . Control . PeriodControl = L . Control . extend ( {
499- onAdd : function ( map ) {
500- var div = L . DomUtil . create ( 'div' ) ;
501-
502- div . innerHTML = '<select name="timeperiod" id="timeperiod" style="width:auto !important;height:30px;" onchange="clean_refresh(this.value)"><option value="1 hour">1 hour</option><option value="3 hours" selected="selected">3 hours</option><option value="6 hours">6 hours</option><option value="12 hours">12 hours</option></select>' ;
503- div . innerHTML . onload = setTimeValue ( ) ;
504-
505- return div ;
506- } ,
507-
508- onRemove : function ( map ) {
509- // Nothing to do here
510- }
511- } ) ;
512-
513- L . control . periodcontrol = function ( opts ) {
514- return new L . Control . PeriodControl ( opts ) ;
515- }
516-
517- L . control . periodcontrol ( { position : 'topleft' } ) . addTo ( map ) ;
518-
519- map . on ( 'idle' , function ( ) {
510+ map . on ( 'moveend' , function ( ) {
520511 lhash_update ( ) ;
521- } ) ;
522- map . on ( 'baselayerchange' , function ( ) {
512+ } ) ;
513+
514+ map . on ( 'baselayerchange' , function ( e ) {
515+ selectedLayer = e . layer . id ;
523516 lhash_update ( ) ;
524517 } ) ;
525-
518+
526519 startAjax ( ) ;
527- } ;
528-
529- map . whenReady ( callBack ) ;
520+ } ) ;
530521
531522 // animate-in the timebox,
532523 setTimeout ( function ( ) {
@@ -2628,12 +2619,6 @@ function refresh() {
26282619 periodical = setTimeout ( refresh , 2000 ) ;
26292620 return ;
26302621 }
2631-
2632- if ( ajax_inprogress_old == wvar . query ) {
2633- if ( vehicles . hasOwnProperty ( wvar . query ) ) {
2634- return ;
2635- }
2636- }
26372622
26382623 if ( ajax_inprogress_old != wvar . query ) {
26392624 document . getElementById ( "timeperiod" ) . disabled = false ;
0 commit comments