]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
Updated repo so OpenMaps plugin can be updated
authorNick Doiron <ndoiron@mapmeld.com>
Wed, 4 May 2011 21:55:04 +0000 (18:55 -0300)
committerNick Doiron <ndoiron@mapmeld.com>
Wed, 4 May 2011 21:55:04 +0000 (18:55 -0300)
plugins/openmap/popcorn.openmap.html
plugins/openmap/popcorn.openmap.js
plugins/openmap/popcorn.openmap.unit.html
plugins/openmap/popcorn.openmap.unit.js
plugins/openmap/readme.txt [deleted file]

index c88b9b158e11d4acadf004b0c34cd7817ddb6d83..6b25b2e3ab4af5ecb78ee475091d17c4353d5b50 100644 (file)
@@ -31,7 +31,7 @@
             location: "Cambridge, MA",
             icon: "http://google-maps-icons.googlecode.com/files/vegetarian.png",
             text: "Clickable markers",
-            size: 10
+                       size: 10
           },
           {
             lat: 42.358544,
 
       <source id='mp4'
         src="../../test/trailer.mp4"
-        type='video/mp4;' codecs="avc1, mp4a"> 
+        type='video/mp4;' codecs="avc1, mp4a"'> 
 
       <source id='ogv'
         src="../../test/trailer.ogv"
-        type='video/ogg;' codecs="theora, vorbis"> 
+        type='video/ogg;' codecs="theora, vorbis"'> 
 
       <p>Your user agent does not support the HTML5 Video element.</p> 
 
index 988354ea4b9fc9acba017b823b634d54c67a1263..2853e998965f9727a7d9d80f400c451f75934d78 100644 (file)
@@ -4,13 +4,13 @@ var openmapCallback;
   
   /**
    * openmap popcorn plug-in 
-   * Adds an OpenLayers + OpenStreetMap map to the target div centered on the location specified by the user
+   * Adds an OpenLayers map and open map tiles (OpenStreetMap [default], NASA WorldWind, or USGS Topographic)
    * Based on the googlemap popcorn plug-in. No StreetView support
    * Options parameter will need a start, end, target, type, zoom, lat and lng
    * -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: ROADMAP (OpenStreetMap), SATELLITE (NASA WorldWind / LandSat), or TERRAIN (USGS)
+   * -Type [optional] either: ROADMAP (OpenStreetMap), SATELLITE (NASA WorldWind / LandSat), or TERRAIN (USGS).  ROADMAP/OpenStreetMap is the default.
    * -Zoom [optional] defaults to 2
    * -Lat and Lng are the coordinates of the map if location is not named
    * -Location is a name of a place to center the map, geocoded to coordinates using TinyGeocoder.com
@@ -41,9 +41,18 @@ var openmapCallback;
       _mapFired = false,
       _mapLoaded = false;
 
+  // insert openlayers api script once
+  if ( !_mapFired ) {
+    _mapFired = true;
+    Popcorn.getScript('http://openlayers.org/api/OpenLayers.js',
+    function() {
+      _mapLoaded = true;
+    } );
+  }
+
   Popcorn.plugin( "openmap" , function( options ){
     var newdiv,
-        map,
+           map,
         centerlonlat,
         projection,
         displayProjection,
@@ -51,15 +60,6 @@ var openmapCallback;
         selectControl,
         popup;
 
-    // insert openlayers api script once
-    if ( !_mapFired ) {
-      _mapFired = true;
-      Popcorn.getScript('http://openlayers.org/api/OpenLayers.js',
-      function() {
-        _mapLoaded = true;
-      } );
-    }
-
     // create a new div within the target div
     // this is later passed on to the maps api
     newdiv               = document.createElement( 'div' );
@@ -91,18 +91,10 @@ var openmapCallback;
         } else {
           centerlonlat = new OpenLayers.LonLat( options.lng, options.lat );
         }
-        if( options.type == "ROADMAP" ) {
-          // add OpenStreetMap layer
-          projection = new OpenLayers.Projection( 'EPSG:900913' );
-          displayProjection = new OpenLayers.Projection( 'EPSG:4326' );
-          centerlonlat = centerlonlat.transform( displayProjection, projection );
-          map = new OpenLayers.Map( { div: newdiv, projection: projection, "displayProjection": displayProjection } );
-          var osm = new OpenLayers.Layer.OSM();
-          map.addLayer( osm );
-        }
-        else if( options.type == "SATELLITE" ) {
+        options.type = options.type || "ROADMAP";
+        if( options.type == "SATELLITE" ) {
           // add NASA WorldWind / LANDSAT map
-          map = new OpenLayers.Map( { div: newdiv, "maxResolution": 0.28125, tileSize: new OpenLayers.Size( 512, 512 ) } );
+          map = new OpenLayers.Map( { div: newdiv, "maxResolution": .28125, tileSize: new OpenLayers.Size( 512, 512 ) } );
           var worldwind = new OpenLayers.Layer.WorldWind( "LANDSAT", "http://worldwind25.arc.nasa.gov/tile/tile.aspx", 2.25, 4, { T: "105" } );
           map.addLayer( worldwind );
           displayProjection = new OpenLayers.Projection( "EPSG:4326" );
@@ -116,7 +108,18 @@ var openmapCallback;
           var relief = new OpenLayers.Layer.WMS( "USGS Terraserver", "http://terraserver-usa.org/ogcmap.ashx?", { layers: 'DRG' } ); 
           map.addLayer( relief );
         }
-        map.div.style.display = "none";
+        else {
+          // add OpenStreetMap layer
+          projection = new OpenLayers.Projection( 'EPSG:900913' );
+          displayProjection = new OpenLayers.Projection( 'EPSG:4326' );
+          centerlonlat = centerlonlat.transform( displayProjection, projection );
+          map = new OpenLayers.Map( { div: newdiv, projection: projection, "displayProjection": displayProjection } );
+          var osm = new OpenLayers.Layer.OSM();
+          map.addLayer( osm );
+        }
+        if( map ) {
+          map.div.style.display = "none";
+        }
       }
     };
     isGeoReady();
index 0df8f2b1992c79c267901b0a445aca5757eefe4f..32e9d0bf87286430aef19e5c074b49ffeb28ff61 100644 (file)
@@ -6,7 +6,7 @@
   <script src="../../test/qunit/qunit.js"></script>
   <!-- 
     do not move - this must be called immediately prior to 
-    popcorn.js
+    popcorn-api-draft.js
   -->
   
   <script src="../../popcorn.js"></script>
 
     <source id='mp4'
       src="../../test/trailer.mp4"
-      type='video/mp4;' codecs="avc1, mp4a"> 
+      type='video/mp4;' codecs="avc1, mp4a"'> 
 
     <source id='ogv'
       src="../../test/trailer.ogv"
-      type='video/ogg;' codecs="theora, vorbis"> 
+      type='video/ogg;' codecs="theora, vorbis"'> 
 
     <p>Your user agent does not support the HTML5 Video element.</p> 
 
@@ -41,5 +41,6 @@
   <div id="map" style="position:relative;float:left;width:300px;height:400px"></div> 
   <div id="map2" style="position:relative;float:left;width:300px;height:400px"></div>
   <div id="map3" style="position:relative;float:left;width:300px;height:400px"></div>
+  <div id="map4" style="position:relative;float:left;width:300px;height:400px"></div>
 </body>
 </html>
index 2be25a2916ef82f222b40cf6396ac8e7c59431cd..ffb93b06bbea67da3a2d0589d9c15b88f204f111 100644 (file)
@@ -1,7 +1,7 @@
 test("Popcorn OpenMap Plugin", function () {
   
   var popped = Popcorn("#video"),
-    expects = 12, 
+    expects = 14, 
     count = 0,
     mapInterval,
     mapInterval2,
@@ -57,6 +57,14 @@ test("Popcorn OpenMap Plugin", function () {
     lng: -78.968525,
     zoom: 14
   } )
+  .openmap( {
+    start: 0,
+    end: 5,
+    target: 'map4',
+    lat: 40.943926,
+    lng: -78.968525,
+    zoom: "14"
+  } )
   .volume(0)
   .play();
 
@@ -89,13 +97,23 @@ test("Popcorn OpenMap Plugin", function () {
       clearInterval( mapInterval3 );
     }
   } );
-  mapInterval4 = popped.exec( 6, function() {
+  mapInterval4 = popped.exec( 4, function() {
+    if( popped.currentTime() > 3 && popped.currentTime() <= 5 ) {
+      ok (document.getElementById('actualmap4'), "Fourth map is on the page" );
+      plus();
+      equals (document.getElementById('actualmap4').offsetParent.id, "map4", "Fourth map is inside the 'map4' div" );
+      plus();
+      clearInterval( mapInterval4 );
+    }
+  } );
+  mapInterval5 = popped.exec( 6, function() {
     if( popped.currentTime() > 5  ) {
       ok (document.getElementById('actualmap2').style.display === "none" && 
           document.getElementById('actualmap3').style.display === "none" && 
+          document.getElementById('actualmap4').style.display === "none" &&
           document.getElementById('actualmap1').style.display === "none", "All three maps are no longer visible" );
       plus();
-      clearInterval( mapInterval4 );
+      clearInterval( mapInterval5 );
     }
   } );
 } );
\ No newline at end of file
diff --git a/plugins/openmap/readme.txt b/plugins/openmap/readme.txt
deleted file mode 100644 (file)
index aaf8ded..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-## What is Popcorn.js? ##
-An open source JavaScript library which connects and synchronizes the <video> tag to other resources, such as these maps.
-
-* Project page: https://wiki.mozilla.org/PopcornOpenVideoAPI
-
-* Source code on Github: https://github.com/annasob/popcorn-js/
-
-## What does the OpenMap plugin add? ##
-You can add clickable markers with custom icons
-
-As an alternative to Google Maps, the OpenMap plugin offers:
-
-* An interactive map using OpenLayers.js - free, open source, and compatible with many mapping formats - http://openlayers.org
-
-* ROADMAP using OpenStreetMap - a free, open data source which is editable by anyone.  Due to its free license, it has received data from many governmental, commercial, and academic sources.  Editors can use Yahoo and Bing Maps to trace information onto the map.  In many parts of the world, OpenStreetMap has better coverage and more up-to-date data than major providers such as Google Maps.  - http://opensteetmap.org
-
-* SATELLITE using NASA Landsat / World Wind - satellite images in the public domain
-
-* TERRAIN using USGS Topographic Maps in the public domain
-
-## Sample code for Popcorn.js ##
-popped.openmap({
-  start: 0,
-  end: 15,
-  type: 'ROADMAP', // OpenStreetMap
-  target: 'map',
-  lat: 43.665429,
-  lng: -79.403323,
-  zoom: 10
-})
-.openmap( {
-  start: 0,
-  end: 30,
-  type: 'SATELLITE', // NASA World Wind / LANDSAT
-  target: 'map2',
-  location: 'Boston, MA',
-  zoom: 9,
-  markers: [
-    {
-      lat: 42.358544,
-      lng: -71.05957,
-      icon: 'http://google-maps-icons.googlecode.com/files/vegetarian.png',
-      text: 'Clickable markers',
-      size: 10
-    }
-  ]
-});
\ No newline at end of file