if( typeof options.tween === "object" ) {
- for ( var i = 0; i < rM.length; i++ ) {
+ for ( var i = 0, m = rM.length; i < m; i++ ) {
// Checks if this position along the tween should be displayed or not
if ( that.media.currentTime >= ( rM[ i ].interval * ( i + 1 ) ) / 1000 &&
( that.media.currentTime <= ( rM[ i ].interval * ( i + 2 ) ) / 1000 ||
- that.media.currentTime >= rM[ i ].interval * ( rM.length ) / 1000 ) ) {
+ that.media.currentTime >= rM[ i ].interval * ( m ) / 1000 ) ) {
sView3.setPosition( new google.maps.LatLng( rM[ i ].position.lat, rM[ i ].position.lng ) );
sView3.setPov({
- heading: rM[ i ].pov.heading || 0,
+ heading: rM[ i ].pov.heading || google.maps.geometry.spherical.computeHeading( rM[ k ], rM[ k + 1 ] ) || 0,
zoom: rM[ i ].pov.zoom || 0,
pitch: rM[ i ].pov.pitch || 0
});
tween( rM, rM[ 0 ].interval );
} else {
- for ( var k = 0; k < rM.length; k++ ) {
+ for ( var k = 0, l = rM.length; k < l; k++ ) {
if( that.media.currentTime >= (options.interval * ( k + 1 ) ) / 1000 &&
( that.media.currentTime <= (options.interval * ( k + 2 ) ) / 1000 ||
- that.media.currentTime >= options.interval * ( rM.length ) / 1000 ) ) {
-
- sView2.setPosition( checkpoints[ k ] );
+ that.media.currentTime >= options.interval * ( l ) / 1000 ) ) {
sView2.setPov({
- heading: options.heading || 0,
+ heading: google.maps.geometry.spherical.computeHeading( rM[ k ], rM[ k + 1 ] ) || 0,
zoom: options.zoom,
pitch: options.pitch || 0
});
+ sView2.setPosition( checkpoints[ k ] );
}
}
var showSteps = function ( directionResult, that ) {
- // Push new google map lat and lng values into an array from our list of lat and lng values
- for ( var j = 0; j < directionResult.routes[ 0 ].overview_path.length; j++ ) {
- checkpoints.push( new google.maps.LatLng( directionResult.routes[ 0 ].overview_path[ j ].lat(), directionResult.routes[ 0 ].overview_path[ j ].lng() ) );
+ // Push new google map lat and lng values into an array from our list of lat and lng values
+ var routes = directionResult.routes[ 0 ].overview_path;
+ for ( var j = 0, k = routes.length; j < k; j++ ) {
+ checkpoints.push( new google.maps.LatLng( routes[ j ].lat(), routes[ j ].lng() ) );
}
// Check to make sure the interval exists, if not, set to a default of 1000
// Same as the above to stop streetview maps from overflowing into one another
var sView3 = sView;
- for ( var i = 0; i < options.tween.length; i++ ) {
+ for ( var i = 0, l = options.tween.length; i < l; i++ ) {
// Make sure interval exists, if not, set to 1000
options.tween[ i ].interval = options.tween[ i ].interval || 1000;