]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
Added tween stuff
authorDavid Seifried <david.c.seifried@gmail.com>
Sun, 15 May 2011 21:15:22 +0000 (17:15 -0400)
committerDavid Seifried <david.c.seifried@gmail.com>
Sun, 15 May 2011 21:15:22 +0000 (17:15 -0400)
plugins/googlemap/popcorn.googlemap.js
plugins/googlemap/tween.html

index b5d2a1d108a144525a204b9fa1ca5ffa724575e3..44be61585caa49cb476445e66fc24756333f6ed2 100644 (file)
-// PLUGIN: Google Maps
-var googleCallback;
-(function (Popcorn) {
-
-    var i = 1,
-        _mapFired = false,
-        _mapLoaded = false,
-        geocoder, loadMaps;
-    //google api callback 
-    googleCallback = function (data) {
-        // ensure all of the maps functions needed are loaded 
-        // before setting _maploaded to true
-        if (typeof google !== "undefined" && google.maps && google.maps.Geocoder && google.maps.LatLng) {
-            geocoder = new google.maps.Geocoder();
-            _mapLoaded = true;
-        } else {
-            setTimeout(function () {
-                googleCallback(data);
-            }, 1);
-        }
-    };
-    // function that loads the google api
-    loadMaps = function () {
-        // for some reason the Google Map API adds content to the body
-        if (document.body) {
-            _mapFired = true;
-            Popcorn.getScript("http://maps.google.com/maps/api/js?sensor=false&callback=googleCallback");
-        } else {
-            setTimeout(function () {
-                loadMaps();
-            }, 1);
-        }
-    };
-
-    /**
-     * googlemap popcorn plug-in
-     * Adds a map to the target div centered on the location specified by the user
-     * Options parameter will need a start, end, target, type, zoom, lat and lng, and location
-     * -Start is the time that you want this plug-in to execute
-     * -End is the time that you want this plug-in to stop executing
-     * -Target is the id of the DOM element that you want the map to appear in. This element must be in the DOM
-     * -Type [optional] either: HYBRID (default), ROADMAP, SATELLITE, TERRAIN, STREETVIEW
-     * -Zoom [optional] defaults to 0
-     * -Heading [optional] STREETVIEW orientation of camera in degrees relative to true north (0 north, 90 true east, ect)
-     * -Pitch [optional] STREETVIEW vertical orientation of the camera (between 1 and 3 is recommended)
-     * -Lat and Lng: the coordinates of the map must be present if location is not specified.
-     * -Location: the adress you want the map to display, bust be present if lat and log are not specified.
-     * Note: using location requires extra loading time, also not specifying both lat/lng and location will
-     * cause and error.
-     * @param {Object} options
-     *
-     * Example:
-     var p = Popcorn("#video")
-     .googlemap({
-     start: 5, // seconds
-     end: 15, // seconds
-     type: "ROADMAP",
-     target: "map",
-     lat: 43.665429,
-     lng: -79.403323
-     } )
-     *
-     */
-    Popcorn.plugin("googlemap", function (options) {
-        var newdiv, map, location;
-
-        // if this is the firest time running the plugins
-        // call the function that gets the sctipt
-        if (!_mapFired) {
-            loadMaps();
-        }
-
-        // create a new div this way anything in the target div is left intact
-        // this is later passed on to the maps api
-        newdiv = document.createElement("div");
-        newdiv.id = "actualmap" + i;
-        newdiv.style.width = "100%";
-        newdiv.style.height = "100%";
-        i++;
-
-        // ensure the target container the user chose exists
-        if (document.getElementById(options.target)) {
-            document.getElementById(options.target).appendChild(newdiv);
-        } else {
-            throw ("map target container doesn't exist");
-        }
-
-        // ensure that google maps and its functions are loaded
-        // before setting up the map parameters
-        var isMapReady = function () {
-                if (_mapLoaded) {
-                    if (options.location) {
-                        // calls an anonymous google function called on separate thread
-                        geocoder.geocode({
-                            "address": options.location
-                        }, function (results, status) {
-                            if (status === google.maps.GeocoderStatus.OK) {
-                                options.lat = results[0].geometry.location.lat();
-                                options.lng = results[0].geometry.location.lng();
-                                location = new google.maps.LatLng(options.lat, options.lng);
-                                map = new google.maps.Map(newdiv, {
-                                    mapTypeId: google.maps.MapTypeId[options.type] || google.maps.MapTypeId.HYBRID
-                                });
-                                map.getDiv().style.display = "none";
-                            }
-                        });
-                    } else {
-                        location = new google.maps.LatLng(options.lat, options.lng);
-                        map = new google.maps.Map(newdiv, {
-                            mapTypeId: google.maps.MapTypeId[options.type] || google.maps.MapTypeId.HYBRID
-                        });
-                        map.getDiv().style.display = "none";
-                    }
-                } else {
-                    setTimeout(function () {
-                        isMapReady();
-                    }, 5);
-                }
-            };
-
-        isMapReady();
-
-        return {
-            /**
-             * @member webpage
-             * The start function will be executed when the currentTime
-             * of the video reaches the start time provided by the
-             * options variable
-             */
-            start: function (event, options) {
-                // ensure the map has been initialized in the setup function above
-                var isMapSetup = function () {
-                        if (map) {
-                            map.getDiv().style.display = "block";
-                            // reset the location and zoom just in case the user plaid with the map
-                            google.maps.event.trigger(map, 'resize');
-                            map.setCenter(location);
-
-                            // make sure options.zoom is a number
-                            if (options.zoom && typeof options.zoom !== "number") {
-                                options.zoom = +options.zoom;
-                            }
-
-                            options.zoom = options.zoom || 0; // default to 0
-                            map.setZoom(options.zoom);
-
-                            //Make sure heading is a number
-                            if (options.heading && typeof options.heading !== "number") {
-                                options.heading = +options.heading;
-                            }
-                            //Make sure pitch is a number
-                            if (options.pitch && typeof options.pitch !== "number") {
-                                options.pitch = +options.pitch;
-                            }
-
-                                                       
-
-                            if (options.type === "STREETVIEW") {
-                                // Switch this map into streeview mode
-                                map.setStreetView(
-                                // Pass a new StreetViewPanorama instance into our map
-                                sView = new google.maps.StreetViewPanorama(newdiv, {
-                                    position: location,
-                                    pov: {
-                                        heading: options.heading = options.heading || 0,
-                                        pitch: options.pitch = options.pitch || 0,
-                                        zoom: options.zoom
-                                    }
-                                })
-
-
-                                );
-                                
-                                
-                                
-
-                                var tween = function (rM, t) {
-
-                                        setTimeout(function () {
-                                          console.log(rM);
-                                          var p = new google.maps.LatLng(rM.position.lat, rM.position.lng);
-                                          sView.setPosition(p);
-                                          sView.setPov({
-                                            heading: rM.pov.heading,
-                                              zoom: 1,
-                                              pitch: 1
-                                          });
-                                        }, t);
-
-                                }
-                                var tmr = 0;
-        
-                                if ( !!options.startLoc && !!options.endLoc ){
-   
-                                  //  Create an array to store all the lat/lang values along our route
-                                  var checkpoints = [];
-
-                                  //  Helper function to split up each portion on a route into smaller chunks, creating a smoother and more fluent tween
-                                  //  Also pushes the data into the checkpoints array
-                                  var getSteps = function (start, end){
-                                    var latDiff = (end.lat() - start.lat()) / 100,
-                                        lngDiff = (end.lng() - start.lng()) / 100,
-                                        lat = start.lat(), 
-                                        lng = start.lng();
-
-                                    for(var i = ; i < steps; i++){
-                                      lat += latDiff;
-                                      lng += lngDiff;
-                                      checkpoints.push(new google.maps.LatLng(lat, lng));
-                                    }
-                                    checkpoints.push(new google.maps.LatLng(end.lat(), end.lng()));
-                                  }
-
-                                  var directionsService = new google.maps.DirectionsService();
-
-                                  var directionsDisplay = new google.maps.DirectionsRenderer(panorama);
-
-                                  var request = {
-                                    origin: options.startLoc,
-                                    destination:options.endLoc,
-                                    travelMode: google.maps.TravelMode.DRIVING
-                                  };
-
-                                  directionsService.route(request, function(response, status) {
-                                        if (status == google.maps.DirectionsStatus.OK) {
-                                          directionsDisplay.setDirections(response);
-                                          showSteps(response);
-                                        }
-                                  });
-
-                                  function showSteps(directionResult) {
-                                    for (var j = 0; j < directionResult.routes[0].overview_path.length; j++) {
-                                      getSteps(directionResult.routes[0].overview_path[j], directionResult.routes[0].overview_path[j+1]);
-                                    }     
-                                    for ( i = 0; i < checkpoints.length; i++ ) {
-                                      tmr = tmr + options.interval;
-                                      tween( checkpoints[i], tmr );
-                                    }
-                                  }
-                                }
-                                else if ( options.tween.length > 0 ){
-                                  for ( i = 0; i < options.tween.length; i++ ) {
-                                    tmr = tmr + options.tween[i].interval;
-                                    tween( options.tween[i], tmr );
-                                  }
-                                }
-
-                            }
-                        } else {
-                            setTimeout(function () {
-                                isMapSetup();
-                            }, 13);
-                        }
-                    };
-
-                isMapSetup();
-            },
-            /**
-             * @member webpage
-             * The end function will be executed when the currentTime
-             * of the video reaches the end time provided by the
-             * options variable
-             */
-            end: function (event, options) {
-                // if the map exists hide it do not delete the map just in
-                // case the user seeks back to time b/w start and end
-                if (map) {
-                    map.getDiv().style.display = "none";
-                }
-            },
-            _teardown: function (options) {
-                // the map must be manually removed
-                document.getElementById(options.target).removeChild(newdiv);
-                newdiv = map = location = null;
-            }
-        };
-    }, {
-        about: {
-            name: "Popcorn Google Map Plugin",
-            version: "0.1",
-            author: "@annasob",
-            website: "annasob.wordpress.com"
-        },
-        options: {
-            start: {
-                elem: "input",
-                type: "text",
-                label: "In"
-            },
-            end: {
-                elem: "input",
-                type: "text",
-                label: "Out"
-            },
-            target: "map-container",
-            type: {
-                elem: "select",
-                options: ["ROADMAP", "SATELLITE", "STREETVIEW", "HYBRID", "TERRAIN"],
-                label: "Type"
-            },
-            zoom: {
-                elem: "input",
-                type: "text",
-                label: "Zoom"
-            },
-            lat: {
-                elem: "input",
-                type: "text",
-                label: "Lat"
-            },
-            lng: {
-                elem: "input",
-                type: "text",
-                label: "Lng"
-            },
-            location: {
-                elem: "input",
-                type: "text",
-                label: "Location"
-            },
-            heading: {
-                elem: "input",
-                type: "text",
-                label: "Heading"
-            },
-            pitch: {
-                elem: "input",
-                type: "text",
-                label: "Pitch"
-            }
-        }
-    });
-})(Popcorn);
+// PLUGIN: Google Maps\r
+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
+        } 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, bust be present if lat and log 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
+     * @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
+                        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
+                // 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
+                            if (options.type === "STREETVIEW") {\r
+                                // Switch this map into streeview mode\r
+                                map.setStreetView(\r
+                                // Pass a new StreetViewPanorama instance into our map\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
+                                \r
+                                \r
+\r
+                                var tween = function (rM, t) {\r
+\r
+                                        setTimeout(function () {\r
+                                          console.log(rM);\r
+                                          sView.setPosition(rM);\r
+                                          \r
+                                        }, t);\r
+\r
+                                }\r
+                                var tmr = 0;\r
+        \r
+                                if ( !!options.startLoc && !!options.endLoc ){\r
+   \r
+                                  //  Create an array to store all the lat/lang values along our route\r
+                                  var checkpoints = [];\r
+\r
+                                  //  Helper function to split up each portion on a route into smaller chunks, creating a smoother and more fluent tween\r
+                                  //  Also pushes the data into the checkpoints array\r
+                                  var getSteps = function (start, end){\r
+                                    var latDiff = (end.lat() - start.lat()) / 100,\r
+                                        lngDiff = (end.lng() - start.lng()) / 100,\r
+                                        lat = start.lat(), \r
+                                        lng = start.lng();\r
+\r
+                                    for(var i = 0; i < 99; i++){\r
+                                      lat += latDiff;\r
+                                      lng += lngDiff;\r
+                                      checkpoints.push(new google.maps.LatLng(lat, lng));\r
+                                    }\r
+                                    checkpoints.push(new google.maps.LatLng(end.lat(), end.lng()));\r
+                                  }\r
+\r
+                                  var directionsService = new google.maps.DirectionsService();\r
+\r
+                                  var directionsDisplay = new google.maps.DirectionsRenderer(sView);\r
+\r
+                                  var request = {\r
+                                    origin: options.startLoc,\r
+                                    destination:options.endLoc,\r
+                                    travelMode: google.maps.TravelMode.DRIVING\r
+                                  };\r
+\r
+                                  directionsService.route(request, function(response, status) {\r
+                                        if (status == google.maps.DirectionsStatus.OK) {\r
+                                          directionsDisplay.setDirections(response);\r
+                                          showSteps(response);\r
+                                        }\r
+                                  });\r
+\r
+                                  function showSteps(directionResult) {\r
+                                    for (var j = 0; j < directionResult.routes[0].overview_path.length-1; j++) {\r
+                                      getSteps(directionResult.routes[0].overview_path[j], directionResult.routes[0].overview_path[j+1]);\r
+                                    }     \r
+                                    for ( var i = 0; i < checkpoints.length; i++ ) {\r
+                                      tmr = tmr + options.interval;\r
+                                      tween( checkpoints[i], tmr );\r
+                                    }\r
+\r
+\r
+                                  interval = window.setInterval(function(){\r
+                                        i++;\r
+                                        // use trig to adjust the heading towards destination\r
+                                       if ( i > 0 ) {\r
+                                          //console.log(k);\r
+                                          var radians = Math.atan2( ( checkpoints[i].lng() - checkpoints[i-1].lng() ), \r
+                                                                   ( checkpoints[i].lat() - checkpoints[i-1].lat() ) );\r
+                                          var degrees = Math.round( ( radians / (Math.PI/180) ) );\r
+                                          var pov = panorama.getPov();\r
+                                          pov.heading = degrees;\r
+                                          sView.setPov(pov); \r
+                                        }\r
+                                        sView.setPosition(checkpoints[i]);\r
+                                        //console.log(checkpoints.length);\r
+                                        if(i == checkpoints.length-1){\r
+                                          console.log("DONE");\r
+                                          window.clearInterval(interval);\r
+                                      }\r
+                                      }, options.interval);\r
+                                  }\r
+                                }\r
+                                else if ( options.tween.length > 0 ){\r
+                                  for ( i = 0; i < options.tween.length; i++ ) {\r
+                                    tmr = tmr + options.tween[i].interval;\r
+                                    tween( options.tween[i], tmr );\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
+            _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
index 57b5328f345041882504b531d32215b590290c92..d5b04d0dbd38d1a14be9e6e6a8ca0f0a6aa05615 100644 (file)
-<!DOCTYPE html>
-<html>
-<head>
-  <title>Popcorn google Map Plug-in Demo</title>
-  
-  <script src="../../popcorn.js"></script>
-  <script src="popcorn.googlemap.js"></script>
-  <script type="text/javascript">
-    document.addEventListener('DOMContentLoaded', function () {
-      var p = Popcorn('#video')
-      .volume(0)
-      .play()
-      .googlemap({
-        start: 0, // seconds
-        end: 20, // seconds
-        type: "ROADMAP",
-        target: "map",
-        lat: 43.665429,
-        lng: -79.403323,
-        zoom: "10"
-      } )
-      .googlemap({
-        start: 0, // seconds
-        end: 20, // seconds
-        type: "STREETVIEW",
-        target: "map1",
-        lat: 35.7795324,
-        lng: -78.63915450000002,
-        zoom: "1",
-        heading: "180",
-        pitch: "1",
-        tween:[ 
-                       {
-                               position: {lat: 35.778056, lng: -78.63903579999999}, 
-                                   pov: {heading: 183.5, zoom: 1, pitch:1}, 
-                                   interval:2000 
-                               },
-                           {   position: {lat: 35.7770258, lng: -78.63929150000001}, 
-                               pov: {heading: 180, zoom: 1, pitch:1},
-                               interval:2000
-                           },
-                           {   position: {lat: 35.775581, lng: -78.639395}, 
-                               pov: {heading: 180, zoom: 1, pitch:1},
-                               interval:2000
-                           }, 
-                           {   position: {lat: 35.775581, lng: -78.639395}, 
-                               pov: {heading: 105, zoom: 1, pitch:1},
-                               interval:2000
-                           },
-                           {   position: {lat: 35.775581, lng: -78.639395}, 
-                               pov: {heading: 0, zoom: 1, pitch:1},
-                               interval:2000
-                           }   
-                ]
-      } )
-      
-      .googlemap({
-        start: 0, // seconds
-        end: 30, // seconds
-        type: "ROADMAP",
-        target: "map2",
-        location:"boston",
-        zoom: 15
-      } );
-    }, false);
-  </script>
-</head>
-<body>
-
-  <h1 id="qunit-header">Popcorn google Map Plug-in Demo</h1>
-  <p> A Google Map displaying Toronto, Ontario will appear at 0 seconds and disappear at 20 seconds.</p>
-  <p> A Google StreetView Map displaying Toronto, Ontario will appear at 0 seconds and disappear at 20 seconds.</p>
-  <p> A Google Map displaying Boston will appear at 0 seconds and disappear at 30 seconds.</p>
-  <div>
-
-    <video id='video'
-      controls
-      width= '250px'
-      poster="../../test/poster.png">
-
-      <source id='mp4'
-        src="../../test/trailer.mp4"
-        type='video/mp4; codecs="avc1, mp4a"'>
-
-      <source id='ogv'
-        src="../../test/trailer.ogv"
-        type='video/ogg; codecs="theora, vorbis"'>
-
-      <p>Your user agent does not support the HTML5 Video element.</p>
-
-    </video>
-  </div>
-
-  <div style="width:1000px">
-    <div id="map" style="position:relative;float:left;width:300px;height:400px"><p>Locations in this video:</p></div>
-    <div id="map1" style="position:relative;float:left;width:300px;height:400px"><p>Locations in this video:</p></div>
-    <div id="map2" style="position:relative;float:left;width:300px;height:400px"><p>Locations in this video:</p></div>
-  </div>
-</body>
-</html>
+<!DOCTYPE html>\r
+<html>\r
+<head>\r
+  <title>Popcorn google Map Plug-in Demo</title>\r
+  \r
+  <script src="../../popcorn.js"></script>\r
+  <script src="popcorn.googlemap.js"></script>\r
+  <script type="text/javascript">\r
+    document.addEventListener('DOMContentLoaded', function () {\r
+      var p = Popcorn('#video')\r
+      .volume(0)\r
+      .play()\r
+      .googlemap({\r
+        start: 0, // seconds\r
+        end: 20, // seconds\r
+        type: "STREETVIEW",\r
+        target: "map1",\r
+        location:"Toronto",\r
+        zoom: "1",\r
+        heading: "180",\r
+        pitch: "1",\r
+                               interval: 10,\r
+                               startLoc: "Burlington",\r
+                               endLoc: "Oakville"\r
+      } );\r
+    }, false);\r
+  </script>\r
+</head>\r
+<body>\r
+\r
+  <h1 id="qunit-header">Popcorn google Map Plug-in Demo</h1>\r
+  <p> A Google Map displaying Toronto, Ontario will appear at 0 seconds and disappear at 20 seconds.</p>\r
+  <p> A Google StreetView Map displaying Toronto, Ontario will appear at 0 seconds and disappear at 20 seconds.</p>\r
+  <p> A Google Map displaying Boston will appear at 0 seconds and disappear at 30 seconds.</p>\r
+  <div>\r
+\r
+    <video id='video'\r
+      controls\r
+      width= '250px'\r
+      poster="../../test/poster.png">\r
+\r
+      <source id='mp4'\r
+        src="../../test/trailer.mp4"\r
+        type='video/mp4; codecs="avc1, mp4a"'>\r
+\r
+      <source id='ogv'\r
+        src="../../test/trailer.ogv"\r
+        type='video/ogg; codecs="theora, vorbis"'>\r
+\r
+      <p>Your user agent does not support the HTML5 Video element.</p>\r
+\r
+    </video>\r
+  </div>\r
+\r
+  <div style="width:1000px">\r
+    <div id="map" style="position:relative;float:left;width:300px;height:400px"><p>Locations in this video:</p></div>\r
+    <div id="map1" style="position:relative;float:left;width:300px;height:400px"><p>Locations in this video:</p></div>\r
+    <div id="map2" style="position:relative;float:left;width:300px;height:400px"><p>Locations in this video:</p></div>\r
+  </div>\r
+</body>\r
+</html>\r