@@ -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
@@ -483,43 +504,20 @@ function load() {
483504 if ( ! wvar . embeded ) manual_pan = true ;
484505 } ) ;
485506
486- // only start population the map, once its completely loaded
487- var callBack = function ( ) {
507+ map . once ( 'move' , function ( ) {
488508 load_hash ( null ) ;
489509
490- L . Control . PeriodControl = L . Control . extend ( {
491- onAdd : function ( map ) {
492- var div = L . DomUtil . create ( 'div' ) ;
493-
494- 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>' ;
495- div . innerHTML . onload = setTimeValue ( ) ;
496-
497- return div ;
498- } ,
499-
500- onRemove : function ( map ) {
501- // Nothing to do here
502- }
503- } ) ;
504-
505- L . control . periodcontrol = function ( opts ) {
506- return new L . Control . PeriodControl ( opts ) ;
507- }
508-
509- L . control . periodcontrol ( { position : 'topleft' } ) . addTo ( map ) ;
510-
511510 map . on ( 'moveend' , function ( ) {
512511 lhash_update ( ) ;
513- } ) ;
512+ } ) ;
513+
514514 map . on ( 'baselayerchange' , function ( e ) {
515515 selectedLayer = e . layer . id ;
516516 lhash_update ( ) ;
517517 } ) ;
518-
518+
519519 startAjax ( ) ;
520- } ;
521-
522- map . whenReady ( callBack ) ;
520+ } ) ;
523521
524522 // animate-in the timebox,
525523 setTimeout ( function ( ) {
@@ -2621,12 +2619,6 @@ function refresh() {
26212619 periodical = setTimeout ( refresh , 2000 ) ;
26222620 return ;
26232621 }
2624-
2625- if ( ajax_inprogress_old == wvar . query ) {
2626- if ( vehicles . hasOwnProperty ( wvar . query ) ) {
2627- return ;
2628- }
2629- }
26302622
26312623 if ( ajax_inprogress_old != wvar . query ) {
26322624 document . getElementById ( "timeperiod" ) . disabled = false ;
0 commit comments