(function() { // Defining variables that need to be available to some functions var map, infoWindow; window.onload = function() { // Creating a map var options = { zoom: 3, center: new google.maps.LatLng(37.09, -95.71), mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById('map'), options); // Adding a marker var marker = new google.maps.Marker({ position: new google.maps.LatLng(40.756054, -73.986951), map: map, title: 'Click me' }); google.maps.event.addListener(marker, 'click', function() { // Check to see if an InfoWindow already exists if (!infoWindow) { infoWindow = new google.maps.InfoWindow(); } // Creating the video element var video = document.createElement('video'); //setting the attributes for the video element video.setAttribute('src', 'http://upload.wikimedia.org/wikipedia/commons/3/3f/ACA_Allertor_125_video.ogv'); video.setAttribute('width', '300'); video.setAttribute('height', '200'); video.setAttribute('controls', 'controls'); video.setAttribute('autoplay', 'autoplay'); //pass the video variable as the content for the InfoWindow infoWindow.setContent(video); //opening the infoWindow infoWindow.open(map, marker); //open infoWindow when the map loads google.maps.event.trigger(marker, 'click'); }); } })();