]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
working map needs unit tests [#171]
authorAnna Sobiepanek <annaopensource@gmail.com>
Fri, 10 Dec 2010 21:44:40 +0000 (16:44 -0500)
committerAnna Sobiepanek <annaopensource@gmail.com>
Fri, 10 Dec 2010 21:44:40 +0000 (16:44 -0500)
plugins/googleMap/popcorn.googleMap.html
plugins/googleMap/popcorn.googleMap.js

index 4a52b64a47c06909419d023bf668ebe60dbc79e2..060bd2b6c0ffa67e38cc44fa19a7ea4a12f135ff 100644 (file)
       var p = Popcorn('#video')
       .play() 
       .googleMap({
-        start: 15, // seconds
-        end: 50, // seconds
+        start: 5, // seconds
+        end: 45, // seconds
         type: 'ROADMAP',
         target: 'map',
-        lat: "29.2720",
-        long: "-90.0233"
-      } )
-
+        lat: 43.665429,
+        long: -79.403323,
+        zoom: 10
+      } );
     }, false);
-
   </script>
 </head>
 <body>
   <h1 id="qunit-header">Popcorn google Map Plug-in Demo</h1>
-  <p> A footnote displaying This video made exclusively for drumbeat.org' will appear at 5 seconds and disappear at 15 seconds.</p>
-  <p> A footnote displaying 'Visit webmademovies.org for more details' will appear at 20 seconds and disappear at 45 seconds.</p>
+  <p> A Google Map  displaying Toronto, Ontario will appear at 5 seconds and disappear at 45 seconds.</p>
   <div>
     <video id='video' 
       controls preload='none' 
@@ -44,7 +42,7 @@
 
     </video> 
   </div>
-  <div id="map" width="50%" height="50%">
+  <div id="map" style="width:400px;height:400px"><p>Locations in this video:</p>
   </div>
 </body>
 </html>
index e3572608590764dc650065c4c3bb2383b9fd0c95..020ffa31e5165e1b1bc525bc9a877e9bdd70ba8d 100644 (file)
@@ -12,6 +12,7 @@
    * Target is the id of the document element that the text needs to be 
    * Type either: HYBRID (default), ROADMAP, SATELLITE, TERRAIN
    * attached to, this target element must exist on the DOM
+   * Zoom [optional] defaults to 0
    * Src [optional]
    * MapInfo [optional]
    * Note: 
         } )
    *
    */
+  // 
+  window.google = window.google || {};
+  google.maps = google.maps || {};
+
+  (function() {
+    var modules = google.maps.modules = {};
+
+    google.maps.__gjsload__ = function(name, text) {
+      modules[name] = text;
+    };
+
+    google.maps.Load = function(apiLoad) {
+      delete google.maps.Load;
+      apiLoad([null,[[["http://mt0.google.com/vt?lyrs=m@140\u0026src=api\u0026hl=en-US\u0026","http://mt1.google.com/vt?lyrs=m@140\u0026src=api\u0026hl=en-US\u0026"]],[["http://khm0.google.com/kh?v=75\u0026hl=en-US\u0026","http://khm1.google.com/kh?v=75\u0026hl=en-US\u0026"],null,null,null,1],[["http://mt0.google.com/vt?lyrs=h@140\u0026src=api\u0026hl=en-US\u0026","http://mt1.google.com/vt?lyrs=h@140\u0026src=api\u0026hl=en-US\u0026"],null,null,"imgtp=png32\u0026"],[["http://mt0.google.com/vt?lyrs=t@126,r@140\u0026src=api\u0026hl=en-US\u0026","http://mt1.google.com/vt?lyrs=t@126,r@140\u0026src=api\u0026hl=en-US\u0026"]],null,[[null,0,7,7,[[[330000000,1246050000],[386200000,1293600000]],[[366500000,1297000000],[386200000,1320034790]]],["http://mt0.gmaptiles.co.kr/mt?v=kr1.12\u0026hl=en-US\u0026","http://mt1.gmaptiles.co.kr/mt?v=kr1.12\u0026hl=en-US\u0026"]],[null,0,8,9,[[[330000000,1246050000],[386200000,1279600000]],[[345000000,1279600000],[386200000,1286700000]],[[348900000,1286700000],[386200000,1293600000]],[[354690000,1293600000],[386200000,1320034790]]],["http://mt0.gmaptiles.co.kr/mt?v=kr1.12\u0026hl=en-US\u0026","http://mt1.gmaptiles.co.kr/mt?v=kr1.12\u0026hl=en-US\u0026"]],[null,0,10,19,[[[329890840,1246055600],[386930130,1284960940]],[[344646740,1284960940],[386930130,1288476560]],[[350277470,1288476560],[386930130,1310531620]],[[370277730,1310531620],[386930130,1320034790]]],["http://mt0.gmaptiles.co.kr/mt?v=kr1.12\u0026hl=en-US\u0026","http://mt1.gmaptiles.co.kr/mt?v=kr1.12\u0026hl=en-US\u0026"]],[null,3,7,7,[[[330000000,1246050000],[386200000,1293600000]],[[366500000,1297000000],[386200000,1320034790]]],["http://mt0.gmaptiles.co.kr/mt?v=kr1p.12\u0026hl=en-US\u0026","http://mt1.gmaptiles.co.kr/mt?v=kr1p.12\u0026hl=en-US\u0026"]],[null,3,8,9,[[[330000000,1246050000],[386200000,1279600000]],[[345000000,1279600000],[386200000,1286700000]],[[348900000,1286700000],[386200000,1293600000]],[[354690000,1293600000],[386200000,1320034790]]],["http://mt0.gmaptiles.co.kr/mt?v=kr1p.12\u0026hl=en-US\u0026","http://mt1.gmaptiles.co.kr/mt?v=kr1p.12\u0026hl=en-US\u0026"]],[null,3,10,null,[[[329890840,1246055600],[386930130,1284960940]],[[344646740,1284960940],[386930130,1288476560]],[[350277470,1288476560],[386930130,1310531620]],[[370277730,1310531620],[386930130,1320034790]]],["http://mt0.gmaptiles.co.kr/mt?v=kr1p.12\u0026hl=en-US\u0026","http://mt1.gmaptiles.co.kr/mt?v=kr1p.12\u0026hl=en-US\u0026"]]],[["http://cbk0.google.com/cbk?","http://cbk1.google.com/cbk?"]],[["http://khmdb0.google.com/kh?v=33\u0026hl=en-US\u0026","http://khmdb1.google.com/kh?v=33\u0026hl=en-US\u0026"]],[["http://mt0.google.com/mapslt?hl=en-US\u0026","http://mt1.google.com/mapslt?hl=en-US\u0026"]],[["http://mt0.google.com/mapslt/ft?hl=en-US\u0026","http://mt1.google.com/mapslt/ft?hl=en-US\u0026"]]],["en-US","US",null,0,null,"http://maps.google.com","http://maps.gstatic.com/intl/en_us/mapfiles/","http://gg.google.com","https://maps.googleapis.com","http://maps.googleapis.com"],["http://maps.gstatic.com/intl/en_us/mapfiles/api-3/3/3a","3.3.3a"],[3023581072],1,null,null,null,null,0,""], loadScriptTime);
+    };
+    var loadScriptTime = (new Date).getTime();
+    var head = document.getElementsByTagName('head')[0];
+    var script = document.createElement('script');
+
+    script.src = "http://maps.gstatic.com/intl/en_us/mapfiles/api-3/3/3a/main.js";
+    script.type = "text/javascript";
+
+    head.insertBefore( script, head.firstChild );  
+  })();
+
+  // IMPORTANT ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   Popcorn.plugin( "googleMap" , (function(){
       
-    var temp,head, script,location, map, link;
+    var location, map, link,opt,target, newdiv;
     
     return {
-      _setup : function( event, options ) {
-        // check if google map api is already loaded
-        head = document.getElementsByTagName('head')[0];
-             script = document.createElement('script');
-        script.onload = function() {
-          alert("he");
-          location = new google.maps.LatLng(options.lat, options.long);
-          map = new google.maps.Map(document.getElementById(options.target), {mapTypeId: options.type | google.maps.MapTypeId.HYBRID });
-          
-        }
-        script.src = "http://maps.google.com/maps/api/js?sensor=false";
-        script.type = 'text/javascript';
-        head.appendChild(script)
-        //head.insertBefore( script, head.firstChild );
-        // setup isready
+      _setup : function( options ) {
+        
+        target  = document.getElementById(options.target),
+        // create a new div this way anything in the target div
+        // will stay intack 
+        newdiv              = document.createElement('div');
+        newdiv.id           = "actualmap";
+        newdiv.style.width  = "100%";
+        newdiv.style.height = "100%";
         
+        target.appendChild(newdiv);
       },
       /**
        * @member webpage 
        * options variable
        */
       start: function(event, options){
-        temp  = document.getElementById( options.target );
-        temp.innerHTML  = options.text;
+        location = new google.maps.LatLng(options.lat, options.long);
+        map = new google.maps.Map(newdiv, {mapTypeId: google.maps.MapTypeId[options.type] || google.maps.MapTypeId.HYBRID });
         
         map.setCenter(location);
-        map.setZoom(options.zoom);
-        if (options.src && options.mapinfo) {
-          link = document.createElement("a");
-          link.setAttribute("href", options.src);
-          link.setAttribute("target", "_blank");
-          link.appendChild(document.createTextNode(options.description||options.src));
-          document.getElementById(options.mapinfo).appendChild(link);
-        }
+        map.setZoom(options.zoom || 0);
       },
       /**
        * @member webpage 
@@ -76,8 +91,8 @@
        * options variable
        */
       end: function(event, options){
-        //temp.innerHTML  = "";
-        //figure out how to delete map
+        // remove the map from the target div
+        target.removeChild(map.getDiv());
       }
       
     };