]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
Changed spacing issues
authorDavid Seifried <david.c.seifried@gmail.com>
Tue, 17 May 2011 16:53:13 +0000 (12:53 -0400)
committerDavid Seifried <david.c.seifried@gmail.com>
Tue, 17 May 2011 16:53:13 +0000 (12:53 -0400)
plugins/googlemap/popcorn.googlemap.js

index 39debcc4697aa322aa86e60027a66e216cf0f834..df3230051ac489bb11af7e014f5a4be2a222074b 100644 (file)
 var googleCallback;\r
 (function (Popcorn) {\r
 \r
-    var i = 1,\r
-        _mapFired = false,\r
-        _mapLoaded = false,\r
-        geocoder, loadMaps;\r
-    //google api callback \r
-    googleCallback = function (data) {\r
-        // ensure all of the maps functions needed are loaded \r
-        // before setting _maploaded to true\r
-        if (typeof google !== "undefined" && google.maps && google.maps.Geocoder && google.maps.LatLng) {\r
-            geocoder = new google.maps.Geocoder();\r
-            _mapLoaded = true;\r
+  var i = 1,\r
+    _mapFired = false,\r
+    _mapLoaded = false,\r
+    geocoder, loadMaps;\r
+  //google api callback \r
+  googleCallback = function (data) {\r
+    // ensure all of the maps functions needed are loaded \r
+    // before setting _maploaded to true\r
+    if (typeof google !== "undefined" && google.maps && google.maps.Geocoder && google.maps.LatLng) {\r
+      geocoder = new google.maps.Geocoder();\r
+      _mapLoaded = true;\r
+    } else {\r
+      setTimeout(function () {\r
+        googleCallback(data);\r
+      }, 1);\r
+    }\r
+  };\r
+  // function that loads the google api\r
+  loadMaps = function () {\r
+    // for some reason the Google Map API adds content to the body\r
+    if (document.body) {\r
+      _mapFired = true;\r
+      Popcorn.getScript("http://maps.google.com/maps/api/js?sensor=false&callback=googleCallback");\r
+    } else {\r
+      setTimeout(function () {\r
+        loadMaps();\r
+      }, 1);\r
+    }\r
+  };\r
+\r
+  /**\r
+   * googlemap popcorn plug-in\r
+   * Adds a map to the target div centered on the location specified by the user\r
+   * Options parameter will need a start, end, target, type, zoom, lat and lng, and location\r
+   * -Start is the time that you want this plug-in to execute\r
+   * -End is the time that you want this plug-in to stop executing\r
+   * -Target is the id of the DOM element that you want the map to appear in. This element must be in the DOM\r
+   * -Type [optional] either: HYBRID (default), ROADMAP, SATELLITE, TERRAIN, STREETVIEW\r
+   * -Zoom [optional] defaults to 0\r
+   * -Heading [optional] STREETVIEW orientation of camera in degrees relative to true north (0 north, 90 true east, ect)\r
+   * -Pitch [optional] STREETVIEW vertical orientation of the camera (between 1 and 3 is recommended)\r
+   * -Lat and Lng: the coordinates of the map must be present if location is not specified.\r
+   * -Location: the adress you want the map to display, must be present if lat and lng are not specified.\r
+   * Note: using location requires extra loading time, also not specifying both lat/lng and location will\r
+   * cause and error.\r
+   *\r
+   * Tweening works using the following specifications:\r
+   * -location is the start point when using an auto generated route\r
+   * -tween when used in this context is a string which specifies the end location for your route\r
+   * Note that both location and tween must be present when using an auto generated route, or the map will not tween\r
+   * -interval is the speed in which the tween will be executed, a reasonable time is 1000 ( time in milliseconds )\r
+   * Heading, Zoom, and Pitch streetview values are also used in tweening with the autogenerated route\r
+   *\r
+   * -tween is an array of objects, each containing data for one frame of a tween\r
+   * -position is an object with has two paramaters, lat and lng, both which are mandatory for a tween to work\r
+   * -pov is an object which houses heading, pitch, and zoom paramters, which are all optional, if undefined, these values default to 0\r
+   * -interval is the speed in which the tween will be executed, a reasonable time is 1000 ( time in milliseconds )\r
+   *\r
+   * @param {Object} options\r
+   *\r
+   * Example:\r
+   var p = Popcorn("#video")\r
+   .googlemap({\r
+   start: 5, // seconds\r
+   end: 15, // seconds\r
+   type: "ROADMAP",\r
+   target: "map",\r
+   lat: 43.665429,\r
+   lng: -79.403323\r
+   } )\r
+   *\r
+   */\r
+  Popcorn.plugin("googlemap", function (options) {\r
+    var newdiv, map, location;\r
+\r
+    // if this is the firest time running the plugins\r
+    // call the function that gets the sctipt\r
+    if (!_mapFired) {\r
+      loadMaps();\r
+    }\r
+\r
+    // create a new div this way anything in the target div is left intact\r
+    // this is later passed on to the maps api\r
+    newdiv = document.createElement("div");\r
+    newdiv.id = "actualmap" + i;\r
+    newdiv.style.width = "100%";\r
+    newdiv.style.height = "100%";\r
+    i++;\r
+\r
+    // ensure the target container the user chose exists\r
+    if (document.getElementById(options.target)) {\r
+      document.getElementById(options.target).appendChild(newdiv);\r
+    } else {\r
+      throw ("map target container doesn't exist");\r
+    }\r
+\r
+    // ensure that google maps and its functions are loaded\r
+    // before setting up the map parameters\r
+    var isMapReady = function () {\r
+        if (_mapLoaded) {\r
+          if (options.location) {\r
+            // calls an anonymous google function called on separate thread\r
+            geocoder.geocode({\r
+              "address": options.location\r
+            }, function (results, status) {\r
+              if (status === google.maps.GeocoderStatus.OK) {\r
+                options.lat = results[0].geometry.location.lat();\r
+                options.lng = results[0].geometry.location.lng();\r
+                location = new google.maps.LatLng(options.lat, options.lng);\r
+                map = new google.maps.Map(newdiv, {\r
+                  mapTypeId: google.maps.MapTypeId[options.type] || google.maps.MapTypeId.HYBRID\r
+                });\r
+                map.getDiv().style.display = "none";\r
+              }\r
+            });\r
+          } else {\r
+            location = new google.maps.LatLng(options.lat, options.lng);\r
+            map = new google.maps.Map(newdiv, {\r
+              mapTypeId: google.maps.MapTypeId[options.type] || google.maps.MapTypeId.HYBRID\r
+            });\r
+            map.getDiv().style.display = "none";\r
+          }\r
         } else {\r
-            setTimeout(function () {\r
-                googleCallback(data);\r
-            }, 1);\r
+          setTimeout(function () {\r
+            isMapReady();\r
+          }, 5);\r
         }\r
-    };\r
-    // function that loads the google api\r
-    loadMaps = function () {\r
-        // for some reason the Google Map API adds content to the body\r
-        if (document.body) {\r
-            _mapFired = true;\r
-            Popcorn.getScript("http://maps.google.com/maps/api/js?sensor=false&callback=googleCallback");\r
-        } else {\r
-            setTimeout(function () {\r
-                loadMaps();\r
-            }, 1);\r
-        }\r
-    };\r
+      };\r
+\r
+    isMapReady();\r
+\r
+    return {\r
+      /**\r
+       * @member webpage\r
+       * The start function will be executed when the currentTime\r
+       * of the video reaches the start time provided by the\r
+       * options variable\r
+       */\r
+      start: function (event, options) {\r
+        var that = this;\r
+\r
+        // ensure the map has been initialized in the setup function above\r
+        var isMapSetup = function () {\r
+            if (map) {\r
+              map.getDiv().style.display = "block";\r
+              // reset the location and zoom just in case the user plaid with the map\r
+              google.maps.event.trigger(map, 'resize');\r
+              map.setCenter(location);\r
+\r
+              // make sure options.zoom is a number\r
+              if (options.zoom && typeof options.zoom !== "number") {\r
+                options.zoom = +options.zoom;\r
+              }\r
+\r
+              options.zoom = options.zoom || 0; // default to 0\r
+              map.setZoom(options.zoom);\r
+\r
+              //Make sure heading is a number\r
+              if (options.heading && typeof options.heading !== "number") {\r
+                options.heading = +options.heading;\r
+              }\r
+              //Make sure pitch is a number\r
+              if (options.pitch && typeof options.pitch !== "number") {\r
+                options.pitch = +options.pitch;\r
+              }\r
 \r
-    /**\r
-     * googlemap popcorn plug-in\r
-     * Adds a map to the target div centered on the location specified by the user\r
-     * Options parameter will need a start, end, target, type, zoom, lat and lng, and location\r
-     * -Start is the time that you want this plug-in to execute\r
-     * -End is the time that you want this plug-in to stop executing\r
-     * -Target is the id of the DOM element that you want the map to appear in. This element must be in the DOM\r
-     * -Type [optional] either: HYBRID (default), ROADMAP, SATELLITE, TERRAIN, STREETVIEW\r
-     * -Zoom [optional] defaults to 0\r
-     * -Heading [optional] STREETVIEW orientation of camera in degrees relative to true north (0 north, 90 true east, ect)\r
-     * -Pitch [optional] STREETVIEW vertical orientation of the camera (between 1 and 3 is recommended)\r
-     * -Lat and Lng: the coordinates of the map must be present if location is not specified.\r
-     * -Location: the adress you want the map to display, must be present if lat and lng are not specified.\r
-     * Note: using location requires extra loading time, also not specifying both lat/lng and location will\r
-     * cause and error.\r
-     *\r
-     * Tweening works using the following specifications:\r
-     * -location is the start point when using an auto generated route\r
-     * -tween when used in this context is a string which specifies the end location for your route\r
-     * Note that both location and tween must be present when using an auto generated route, or the map will not tween\r
-     * -interval is the speed in which the tween will be executed, a reasonable time is 1000 ( time in milliseconds )\r
-     * Heading, Zoom, and Pitch streetview values are also used in tweening with the autogenerated route\r
-     *\r
-     * -tween is an array of objects, each containing data for one frame of a tween\r
-     * -position is an object with has two paramaters, lat and lng, both which are mandatory for a tween to work\r
-     * -pov is an object which houses heading, pitch, and zoom paramters, which are all optional, if undefined, these values default to 0\r
-     * -interval is the speed in which the tween will be executed, a reasonable time is 1000 ( time in milliseconds )\r
-     *\r
-     * @param {Object} options\r
-     *\r
-     * Example:\r
-     var p = Popcorn("#video")\r
-     .googlemap({\r
-     start: 5, // seconds\r
-     end: 15, // seconds\r
-     type: "ROADMAP",\r
-     target: "map",\r
-     lat: 43.665429,\r
-     lng: -79.403323\r
-     } )\r
-     *\r
-     */\r
-    Popcorn.plugin("googlemap", function (options) {\r
-        var newdiv, map, location;\r
-\r
-        // if this is the firest time running the plugins\r
-        // call the function that gets the sctipt\r
-        if (!_mapFired) {\r
-            loadMaps();\r
-        }\r
+                                                       \r
 \r
-        // create a new div this way anything in the target div is left intact\r
-        // this is later passed on to the maps api\r
-        newdiv = document.createElement("div");\r
-        newdiv.id = "actualmap" + i;\r
-        newdiv.style.width = "100%";\r
-        newdiv.style.height = "100%";\r
-        i++;\r
-\r
-        // ensure the target container the user chose exists\r
-        if (document.getElementById(options.target)) {\r
-            document.getElementById(options.target).appendChild(newdiv);\r
-        } else {\r
-            throw ("map target container doesn't exist");\r
-        }\r
+              if (options.type === "STREETVIEW") {\r
+                // Switch this map into streeview mode\r
+                map.setStreetView(\r
+                // Pass a new StreetViewPanorama instance into our map\r
+\r
+                sView = new google.maps.StreetViewPanorama( newdiv, {\r
+                  position: location,\r
+                  pov: {\r
+                    heading: options.heading = options.heading || 0,\r
+                    pitch: options.pitch = options.pitch || 0,\r
+                    zoom: options.zoom\r
+                  }\r
+                })\r
+\r
+\r
+                );\r
+    \r
+                //  Function to handle tweening using a set timeout\r
+                var tween = function ( rM, t ) {\r
+\r
+                  setTimeout( function () {\r
+      \r
+                  //  Checks whether this is a generated route or not\r
+\r
+                  if( typeof options.tween === "object" ){\r
+\r
+                    for ( var i = 0; i < rM.length; i++ ) {\r
+\r
+                    //  Checks if this position along the tween should be displayed or not\r
+                    if( that.media.currentTime >= ( rM[ i ].interval*( i+1 ) )/1000 &&\r
+                      ( that.media.currentTime <= (rM[ i ].interval*( i+2 ) )/1000 || \r
+                      that.media.currentTime >= rM[ i ].interval*( rM.length )/1000 ) ){\r
+\r
+                           sView3.setPosition( new google.maps.LatLng( rM[ i ].position.lat, rM[ i ].position.lng ) );\r
+\r
+                           sView3.setPov({\r
+                             heading: rM[ i ].pov.heading || 0,\r
+                             zoom:  rM[ i ].pov.zoom || 0,\r
+                             pitch:   rM[ i ].pov.pitch || 0\r
+                           });\r
 \r
-        // ensure that google maps and its functions are loaded\r
-        // before setting up the map parameters\r
-        var isMapReady = function () {\r
-                if (_mapLoaded) {\r
-                    if (options.location) {\r
-                        // calls an anonymous google function called on separate thread\r
-                        geocoder.geocode({\r
-                            "address": options.location\r
-                        }, function (results, status) {\r
-                            if (status === google.maps.GeocoderStatus.OK) {\r
-                                options.lat = results[0].geometry.location.lat();\r
-                                options.lng = results[0].geometry.location.lng();\r
-                                location = new google.maps.LatLng(options.lat, options.lng);\r
-                                map = new google.maps.Map(newdiv, {\r
-                                    mapTypeId: google.maps.MapTypeId[options.type] || google.maps.MapTypeId.HYBRID\r
-                                });\r
-                                map.getDiv().style.display = "none";\r
-                            }\r
-                        });\r
-                    } else {\r
-                        location = new google.maps.LatLng(options.lat, options.lng);\r
-                        map = new google.maps.Map(newdiv, {\r
-                            mapTypeId: google.maps.MapTypeId[options.type] || google.maps.MapTypeId.HYBRID\r
-                        });\r
-                        map.getDiv().style.display = "none";\r
                     }\r
-                } else {\r
-                    setTimeout(function () {\r
-                        isMapReady();\r
-                    }, 5);\r
-                }\r
-            };\r
-\r
-        isMapReady();\r
-\r
-        return {\r
-            /**\r
-             * @member webpage\r
-             * The start function will be executed when the currentTime\r
-             * of the video reaches the start time provided by the\r
-             * options variable\r
-             */\r
-            start: function (event, options) {\r
-                var that = this;\r
-\r
-                // ensure the map has been initialized in the setup function above\r
-                var isMapSetup = function () {\r
-                        if (map) {\r
-                            map.getDiv().style.display = "block";\r
-                            // reset the location and zoom just in case the user plaid with the map\r
-                            google.maps.event.trigger(map, 'resize');\r
-                            map.setCenter(location);\r
-\r
-                            // make sure options.zoom is a number\r
-                            if (options.zoom && typeof options.zoom !== "number") {\r
-                                options.zoom = +options.zoom;\r
-                            }\r
-\r
-                            options.zoom = options.zoom || 0; // default to 0\r
-                            map.setZoom(options.zoom);\r
-\r
-                            //Make sure heading is a number\r
-                            if (options.heading && typeof options.heading !== "number") {\r
-                                options.heading = +options.heading;\r
-                            }\r
-                            //Make sure pitch is a number\r
-                            if (options.pitch && typeof options.pitch !== "number") {\r
-                                options.pitch = +options.pitch;\r
-                            }\r
 \r
-                                                       \r
+                    }\r
+                    //  Calls the tween function again at the interval set by the user\r
+                    tween( rM, rM[ 0 ].interval );\r
+                  }\r
+                  else{\r
 \r
-                            if (options.type === "STREETVIEW") {\r
-                                // Switch this map into streeview mode\r
-                                map.setStreetView(\r
-                                // Pass a new StreetViewPanorama instance into our map\r
+                    for ( var i = 0; i < rM.length; i++ ) {\r
 \r
-                                sView = new google.maps.StreetViewPanorama( newdiv, {\r
-                                    position: location,\r
-                                    pov: {\r
-                                        heading: options.heading = options.heading || 0,\r
-                                        pitch: options.pitch = options.pitch || 0,\r
-                                        zoom: options.zoom\r
-                                    }\r
-                                })\r
+                      if( that.media.currentTime >= (options.interval*( i+1 ) )/1000 &&\r
+                      ( that.media.currentTime <= (options.interval*( i+2 ) )/1000 ||\r
+                       that.media.currentTime >= options.interval*( rM.length )/1000 ) ){\r
 \r
+                        sView2.setPosition( checkpoints[i] );\r
 \r
-                                );\r
-      \r
-                                //  Function to handle tweening using a set timeout\r
-                                var tween = function ( rM, t ) {\r
-\r
-                                  setTimeout( function () {\r
-          \r
-                                    //  Checks whether this is a generated route or not\r
-\r
-                                    if( typeof options.tween === "object" ){\r
-\r
-                                      for ( var i = 0; i < rM.length; i++ ) {\r
-\r
-                                        //  Checks if this position along the tween should be displayed or not\r
-                                        if( that.media.currentTime >= ( rM[ i ].interval*( i+1 ) )/1000 &&\r
-                                          ( that.media.currentTime <= (rM[ i ].interval*( i+2 ) )/1000 || \r
-                                            that.media.currentTime >= rM[ i ].interval*( rM.length )/1000 ) ){\r
-\r
-                                               sView3.setPosition( new google.maps.LatLng( rM[ i ].position.lat, rM[ i ].position.lng ) );\r
-\r
-                                               sView3.setPov({\r
-                                                 heading: rM[ i ].pov.heading || 0,\r
-                                                 zoom:    rM[ i ].pov.zoom || 0,\r
-                                                 pitch:   rM[ i ].pov.pitch || 0\r
-                                               });\r
-\r
-                                        }\r
-\r
-                                      }\r
-                                      //  Calls the tween function again at the interval set by the user\r
-                                      tween( rM, rM[ 0 ].interval );\r
-                                    }\r
-                                    else{\r
-\r
-                                      for ( var i = 0; i < rM.length; i++ ) {\r
-\r
-                                          if( that.media.currentTime >= (options.interval*( i+1 ) )/1000 &&\r
-                                            ( that.media.currentTime <= (options.interval*( i+2 ) )/1000 ||\r
-                                             that.media.currentTime >= options.interval*( rM.length )/1000 ) ){\r
-\r
-                                          sView2.setPosition( checkpoints[i] );\r
-\r
-                                          sView2.setPov({\r
-                                                 heading: options.heading || 0,\r
-                                                 zoom:    options.zoom,\r
-                                                 pitch:   options.pitch || 0\r
-                                               }); \r
-                                      } \r
-\r
-                                    }\r
-                                    tween( checkpoints, options.interval );\r
-                                    }   \r
-                                  }, t );\r
-\r
-                                }\r
-\r
-                                \r
-                                //  Determines if we should use hardcoded values ( using options.tween ),\r
-                                //  or if we should use a start and end location and let google generate\r
-                                //  the route for us\r
-                                if ( options.location && typeof options.tween === "string" ){\r
-\r
-                                //  Creating another variable to hold the streetview map for tweening,\r
-                                //  Doing this because if there was more then one streetview map, the tweening would sometimes appear in other maps\r
-                                var sView2 = sView;\r
-                                  \r
-                                  //  Create an array to store all the lat/lang values along our route\r
-                                  var checkpoints = [];\r
-\r
-                                  //  Creates a new direction service, later used to create a route\r
-                                  var directionsService = new google.maps.DirectionsService();\r
-\r
-                                  //  Creates a new direction renderer using the current map\r
-                                  //  This enables us to access all of the route data that is returned to us\r
-                                  var directionsDisplay = new google.maps.DirectionsRenderer( sView2 );\r
-\r
-                                  var request = {\r
-                                    origin:      options.location,\r
-                                    destination: options.tween,\r
-                                    travelMode:  google.maps.TravelMode.DRIVING\r
-                                  };\r
-\r
-                                  //  Create the route using the direction service and renderer\r
-                                  directionsService.route( request, function( response, status ) {\r
-\r
-                                    if ( status == google.maps.DirectionsStatus.OK ) {\r
-                                      directionsDisplay.setDirections( response );\r
-                                      showSteps( response, that );\r
-                                    }\r
-\r
-                                  });\r
-\r
-                                  function showSteps( directionResult, that ) {\r
-                                    \r
-                                    //  Push new google map lat and lng values into an array from our list of lat and lng values\r
-                                    for ( var j = 0; j < directionResult.routes[ 0 ].overview_path.length; j++ ) {\r
-                                      checkpoints.push( new google.maps.LatLng( directionResult.routes[ 0 ].overview_path[ j ].lat(), directionResult.routes[ 0 ].overview_path[ j ].lng() ) );\r
-                                    }     \r
-                                      \r
-                                      //  Check to make sure the interval exists, if not, set to a default of 1000\r
-                                      options.interval = options.interval || 1000;\r
-                                      tween( checkpoints, 10);\r
-\r
-                                  }\r
-                                }\r
-                                else if( typeof options.tween === "object" ){\r
-\r
-                                  //  Same as the above to stop streetview maps from overflowing into one another\r
-                                  var sView3 = sView;\r
-\r
-                                  for ( var i = 0; i < options.tween.length; i++ ) {\r
-                                   \r
-                                    //  Make sure interval exists, if not, set to 1000\r
-                                    options.tween[ i ].interval = options.tween[ i ].interval || 1000;\r
-                                    tween( options.tween, 10 );\r
-                                  }\r
-\r
-                                }\r
-\r
-                            }\r
-                        } else {\r
-                            setTimeout(function () {\r
-                                isMapSetup();\r
-                            }, 13);\r
-                        }\r
-                    };\r
+                        sView2.setPov({\r
+                               heading: options.heading || 0,\r
+                               zoom:  options.zoom,\r
+                               pitch:   options.pitch || 0\r
+                             }); \r
+                      }  \r
+\r
+                    }\r
+\r
+                    tween( checkpoints, options.interval );\r
+                  }   \r
+                  }, t );\r
 \r
-                isMapSetup();\r
-            },\r
-            /**\r
-             * @member webpage\r
-             * The end function will be executed when the currentTime\r
-             * of the video reaches the end time provided by the\r
-             * options variable\r
-             */\r
-            end: function (event, options) {\r
-                // if the map exists hide it do not delete the map just in\r
-                // case the user seeks back to time b/w start and end\r
-                if (map) {\r
-                    map.getDiv().style.display = "none";\r
                 }\r
-            },\r
-            _teardown: function (options) {\r
-                // the map must be manually removed\r
-                document.getElementById(options.target).removeChild(newdiv);\r
-                newdiv = map = location = null;\r
-            }\r
-        };\r
-    }, {\r
-        about: {\r
-            name: "Popcorn Google Map Plugin",\r
-            version: "0.1",\r
-            author: "@annasob",\r
-            website: "annasob.wordpress.com"\r
-        },\r
-        options: {\r
-            start: {\r
-                elem: "input",\r
-                type: "text",\r
-                label: "In"\r
-            },\r
-            end: {\r
-                elem: "input",\r
-                type: "text",\r
-                label: "Out"\r
-            },\r
-            target: "map-container",\r
-            type: {\r
-                elem: "select",\r
-                options: ["ROADMAP", "SATELLITE", "STREETVIEW", "HYBRID", "TERRAIN"],\r
-                label: "Type"\r
-            },\r
-            zoom: {\r
-                elem: "input",\r
-                type: "text",\r
-                label: "Zoom"\r
-            },\r
-            lat: {\r
-                elem: "input",\r
-                type: "text",\r
-                label: "Lat"\r
-            },\r
-            lng: {\r
-                elem: "input",\r
-                type: "text",\r
-                label: "Lng"\r
-            },\r
-            location: {\r
-                elem: "input",\r
-                type: "text",\r
-                label: "Location"\r
-            },\r
-            heading: {\r
-                elem: "input",\r
-                type: "text",\r
-                label: "Heading"\r
-            },\r
-            pitch: {\r
-                elem: "input",\r
-                type: "text",\r
-                label: "Pitch"\r
+\r
+                \r
+                //  Determines if we should use hardcoded values ( using options.tween ),\r
+                //  or if we should use a start and end location and let google generate\r
+                //  the route for us\r
+                if ( options.location && typeof options.tween === "string" ){\r
+\r
+                //  Creating another variable to hold the streetview map for tweening,\r
+                //  Doing this because if there was more then one streetview map, the tweening would sometimes appear in other maps\r
+                var sView2 = sView;\r
+                  \r
+                  //  Create an array to store all the lat/lang values along our route\r
+                  var checkpoints = [];\r
+\r
+                  //  Creates a new direction service, later used to create a route\r
+                  var directionsService = new google.maps.DirectionsService();\r
+\r
+                  //  Creates a new direction renderer using the current map\r
+                  //  This enables us to access all of the route data that is returned to us\r
+                  var directionsDisplay = new google.maps.DirectionsRenderer( sView2 );\r
+\r
+                  var request = {\r
+                  origin:    options.location,\r
+                  destination: options.tween,\r
+                  travelMode:  google.maps.TravelMode.DRIVING\r
+                  };\r
+\r
+                  //  Create the route using the direction service and renderer\r
+                  directionsService.route( request, function( response, status ) {\r
+\r
+                  if ( status == google.maps.DirectionsStatus.OK ) {\r
+                    directionsDisplay.setDirections( response );\r
+                    showSteps( response, that );\r
+                  }\r
+\r
+                  });\r
+\r
+                  function showSteps( directionResult, that ) {\r
+                  \r
+                  //  Push new google map lat and lng values into an array from our list of lat and lng values\r
+                  for ( var j = 0; j < directionResult.routes[ 0 ].overview_path.length; j++ ) {\r
+                    checkpoints.push( new google.maps.LatLng( directionResult.routes[ 0 ].overview_path[ j ].lat(), directionResult.routes[ 0 ].overview_path[ j ].lng() ) );\r
+                  }   \r
+                    \r
+                    //  Check to make sure the interval exists, if not, set to a default of 1000\r
+                    options.interval = options.interval || 1000;\r
+                    tween( checkpoints, 10);\r
+\r
+                  }\r
+                }\r
+                else if( typeof options.tween === "object" ){\r
+\r
+                  //  Same as the above to stop streetview maps from overflowing into one another\r
+                  var sView3 = sView;\r
+\r
+                  for ( var i = 0; i < options.tween.length; i++ ) {\r
+                   \r
+                  //  Make sure interval exists, if not, set to 1000\r
+                  options.tween[ i ].interval = options.tween[ i ].interval || 1000;\r
+                  tween( options.tween, 10 );\r
+                  }\r
+\r
+                }\r
+\r
+              }\r
+            } else {\r
+              setTimeout(function () {\r
+                isMapSetup();\r
+              }, 13);\r
             }\r
+          };\r
+\r
+        isMapSetup();\r
+      },\r
+      /**\r
+       * @member webpage\r
+       * The end function will be executed when the currentTime\r
+       * of the video reaches the end time provided by the\r
+       * options variable\r
+       */\r
+      end: function (event, options) {\r
+        // if the map exists hide it do not delete the map just in\r
+        // case the user seeks back to time b/w start and end\r
+        if (map) {\r
+          map.getDiv().style.display = "none";\r
         }\r
-    });\r
+      },\r
+      _teardown: function (options) {\r
+        // the map must be manually removed\r
+        document.getElementById(options.target).removeChild(newdiv);\r
+        newdiv = map = location = null;\r
+      }\r
+    };\r
+  }, {\r
+    about: {\r
+      name: "Popcorn Google Map Plugin",\r
+      version: "0.1",\r
+      author: "@annasob",\r
+      website: "annasob.wordpress.com"\r
+    },\r
+    options: {\r
+      start: {\r
+        elem: "input",\r
+        type: "text",\r
+        label: "In"\r
+      },\r
+      end: {\r
+        elem: "input",\r
+        type: "text",\r
+        label: "Out"\r
+      },\r
+      target: "map-container",\r
+      type: {\r
+        elem: "select",\r
+        options: ["ROADMAP", "SATELLITE", "STREETVIEW", "HYBRID", "TERRAIN"],\r
+        label: "Type"\r
+      },\r
+      zoom: {\r
+        elem: "input",\r
+        type: "text",\r
+        label: "Zoom"\r
+      },\r
+      lat: {\r
+        elem: "input",\r
+        type: "text",\r
+        label: "Lat"\r
+      },\r
+      lng: {\r
+        elem: "input",\r
+        type: "text",\r
+        label: "Lng"\r
+      },\r
+      location: {\r
+        elem: "input",\r
+        type: "text",\r
+        label: "Location"\r
+      },\r
+      heading: {\r
+        elem: "input",\r
+        type: "text",\r
+        label: "Heading"\r
+      },\r
+      pitch: {\r
+        elem: "input",\r
+        type: "text",\r
+        label: "Pitch"\r
+      }\r
+    }\r
+  });\r
 })(Popcorn);\r