@@ -112,8 +112,10 @@ function unload() {
112112}
113113
114114function panTo ( vehicle_index ) {
115- if ( vehicles [ vehicle_index ] . marker_shadow ) map . panTo ( vehicles [ vehicle_index ] . marker_shadow . getPosition ( ) ) ;
116- else map . panTo ( vehicles [ vehicle_index ] . marker . getPosition ( ) ) ;
115+ if ( vehicle_index < 0 ) return ;
116+
117+ if ( vehicles [ vehicle_index ] . marker_shadow ) map . panTo ( vehicles [ vehicle_index ] . marker_shadow . getPosition ( ) ) ;
118+ else map . panTo ( vehicles [ vehicle_index ] . marker . getPosition ( ) ) ;
117119}
118120
119121function optional ( caption , value , postfix ) {
@@ -273,9 +275,7 @@ function stopFollow() {
273275}
274276
275277function followVehicle ( index ) {
276- if ( vehicles . length < 1 ) return ;
277-
278- if ( follow_vehicle != - 1 ) vehicles [ follow_vehicle ] . follow = false ;
278+ if ( follow_vehicle != - 1 && vehicles . length ) vehicles [ follow_vehicle ] . follow = false ;
279279
280280 if ( follow_vehicle == index ) {
281281 vehicles [ follow_vehicle ] . follow = false ;
@@ -1248,9 +1248,9 @@ function update(response) {
12481248function zoom_on_payload ( ) {
12491249 // find a the first balloon
12501250 var i = - 1 , ii = vehicles . length ;
1251- while ( ++ i < ii && ! vehicles [ i ] . marker_shadow ) ;
1251+ while ( ++ i < ii ) if ( vehicles [ i ] . type == "balloon" ) break ;
12521252
1253- if ( i == ii ) { i = 0 }
1253+ if ( i == ii ) return ;
12541254 else {
12551255 // find the bounds of the ballons first and last positions
12561256 var bounds = new google . maps . LatLngBounds ( ) ;
0 commit comments