<script src="../../popcorn.js"></script>
<script src="popcorn.googlemap.js"></script>
- <script>
+ <script type="text/javascript">
document.addEventListener('DOMContentLoaded', function () {
var p = Popcorn('#video')
.volume(0)
lng: -79.403323,
zoom: "10"
} )
+ .googlemap({
+ start: 0, // seconds
+ end: 40, // seconds
+ type: "STREETVIEW",
+ target: "map3",
+ location: "6th Line, Oakville, Ontario",
+ //lat: 35.7795324,
+ //lng: -78.63915450000002,
+ zoom: "1",
+ heading: "180",
+ pitch: "1",
+ interval: 1000,
+ endLoc: "York university"
+ })
+ .googlemap({
+ start: 0, // seconds
+ end: 40, // seconds
+ type: "STREETVIEW",
+ target: "map5",
+ location: "Buffallo",
+ //lat: 35.7795324,
+ //lng: -78.63915450000002,
+ zoom: "1",
+ heading: "180",
+ pitch: "1",
+ interval: 1000,
+ endLoc: "Ottawa"
+ })
.googlemap({
start: 0, // seconds
end: 20, // seconds
type: "STREETVIEW",
- target: "map1",
- lat: 43.665429,
- lng: -79.403323,
+ target: "map4",
+ lat: 35.7795324,
+ lng: -78.63915450000002,
zoom: "1",
- heading: "0",
- pitch: "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
target: "map2",
location:"boston",
zoom: 15
+ } )
+ .googlemap({
+ start: 0, // seconds
+ end: 20, // seconds
+ type: "STREETVIEW",
+ target: "map1",
+ lat: 43.665429,
+ lng: -79.403323,
+ zoom: "1",
+ heading: "0",
+ pitch: "1"
} );
}, 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 Streetview image of Toronto, Ontario will appear at 0 seconds and disaapear at 20 seconds</p>
<p> A Google Map displaying Boston will appear at 0 seconds and disappear at 30 seconds.</p>
+ <p> A Google Map Streetview tweening from Oakville, Ontario to York University will appear at 0 seconds and disaapear at 40 seconds</p>
+ <p> A Google Map Streetview tweening from 217 Fayetteville Street to East Davie Street will appear at 0 seconds and disaapear at 20 seconds - Using hardcoded lat+lng values</p>
+ <p> A Google Map Streetview tweening from Buffallo to Ottawa will appear at 0 seconds and disaapear at 40 seconds</p>
<div>
+
<video id='video'
controls
width= '250px'
</video>
</div>
- <div style="width:1000px">
+
+ <div style="width:2000px">
<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 id="map3" style="position:relative;float:left;width:300px;height:400px"><p>Locations in this video:</p></div>
+ <div id="map4" style="position:relative;float:left;width:300px;height:400px"><p>Locations in this video:</p></div>
+ <div id="map5" style="position:relative;float:left;width:300px;height:400px"><p>Locations in this video:</p></div>
</div>
</body>
-</html>
\ No newline at end of file
+</html>
* -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
+ * -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
+ * -endLoc is the end location when using an auto generated route\r
+ * Note that both location and endLoc 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
* 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
// 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
+\r
+ sView = new google.maps.StreetViewPanorama( newdiv, {\r
position: location,\r
pov: {\r
heading: options.heading = options.heading || 0,\r
\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
+ if( options.tween ){\r
\r
- var tween = function (rM, t) {\r
+ for ( var i = 0; i < rM.length; i++ ) {\r
\r
- setTimeout(function () {\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
- if(options.tween){\r
+ var p = new google.maps.LatLng( rM[ i ].position.lat, rM[ i ].position.lng );\r
+ sView3.setPosition( p );\r
\r
- var p = new google.maps.LatLng(rM.position.lat, rM.position.lng);\r
- sView.setPosition(p);\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
- sView.setPov({\r
- heading: rM.pov.heading,\r
- zoom: 1,\r
- pitch: 1\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
- sView.setPosition(rM);\r
+\r
+ for ( var i = 0; i < rM.length; i++ ) {\r
+\r
+ if( that.media.currentTime >= (options.interval*(i+1))/1000 && (that.media.currentTime <= (options.interval*(i+2))/1000 || 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
+ }, t );\r
\r
}\r
\r
- var tmr = 0;\r
- \r
- if ( !options.tween && ( options.location && options.endLoc) ){\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.tween && ( options.location && options.endLoc ) ){\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
- var directionsDisplay = new google.maps.DirectionsRenderer(sView);\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.endLoc,\r
- travelMode: google.maps.TravelMode.DRIVING\r
+ origin: options.location,\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
+ // 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) {\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
+ 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
- for ( var i = 0; i < checkpoints.length; i++ ) {\r
- tmr = tmr + options.interval;\r
- tween( checkpoints[i], tmr );\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 {\r
- for ( i = 0; i < options.tween.length; i++ ) {\r
- tmr = tmr + options.tween[i].interval;\r
- tween( options.tween[i], tmr );\r
+ else if( options.tween ){\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