]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
changed to follow style format
authorNick Doiron <ndoiron@mapmeld.com>
Sat, 12 Mar 2011 19:21:48 +0000 (14:21 -0500)
committerNick Doiron <ndoiron@mapmeld.com>
Sat, 12 Mar 2011 19:21:48 +0000 (14:21 -0500)
popcorn.openmap.html
popcorn.openmap.js
popcorn.openmap.unit.js

index 8d96c95879ff8f28064cf6b77b4456048e6e2296..ba3b4735f2749ced2f5431daaf5b1dde5c2a6a12 100644 (file)
@@ -5,12 +5,12 @@
   <script src="../../popcorn.js"></script>
   <script src="popcorn.openmap.js"></script>
   <script>
-       this.popped="";
+    this.popped="";
     document.addEventListener('DOMContentLoaded', function () {
       this.popped = Popcorn('#video')
-      .volume(0)
-      .play() 
-      .openmap({
+      .volume( 0 )
+      .play()
+      .openmap( {
         start: 0, // seconds
         end: 20, // seconds
         type: 'ROADMAP',
@@ -19,7 +19,7 @@
         lng: -79.403323,
         zoom: "10"
       } )
-      .openmap({
+      .openmap( {
         start: 0, // seconds
         end: 30, // seconds
         type: 'SATELLITE',
         lat: 42.358544,
         lng: -71.05957,
         zoom: 8,
-               markers: [
-                               {start:0,end:100000000000000,popcorn:this,lat:42.358,lng:-71.0595,icon:"http://google-maps-icons.googlecode.com/files/palace.png"}
-                       ]
-               });
+        markers: [
+          {
+            start: 0,
+            end: 100000000000000,
+            popcorn: this,
+            lat: 42.358,
+            lng: -71.0595,
+            icon: "http://google-maps-icons.googlecode.com/files/palace.png"
+          }
+        ]
+      } );
     }, false);
   </script>
 </head>
 <body>
   <h1 id="qunit-header">Popcorn Open Map Plug-in Demo</h1>
   <p> An OpenLayers + OpenStreetMap Map displaying Toronto, Ontario will appear at 0 seconds and disappear at 20 seconds.</p>
-  <p> An OpenLayers + NASA LandSat Map displaying Boston will appear at 0 seconds and disappear at 30 seconds.</p>
+  <p> An OpenLayers + NASA LandSat Map displaying Boston and a map marker will appear at 0 seconds and disappear at 30 seconds.</p>
   <div>
     <video id='video' 
       controls 
index 096353ac11e5f576ea0fa1e7de4cac241f0c396b..45c10cb4f4d0bcab56868c9439b5ec41192873bb 100644 (file)
@@ -5,12 +5,12 @@ var openlayersCallback;
   /**
    * openmap popcorn plug-in 
    * Adds an OpenLayers + OpenStreetMap map to the target div centered on the location specified by the user
-   * Based on the googlemap popcorn plug-in, location option not available
+   * Based on the googlemap popcorn plug-in, except location option not available
    * 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 LandSat)... Coming Soon: TERRAIN (USGS), HYBRID
+   * -Type [optional] either: ROADMAP (OpenStreetMap), SATELLITE (NASA WorldWind / LandSat)... Coming Soon: TERRAIN (USGS)
    * -Zoom [optional] defaults to 2
    * -Lat and Lng: the coordinates of the map must be present if location is not specified.
    * -Markers: array of marker objects to be added to the map at given times
@@ -19,7 +19,7 @@ var openlayersCallback;
    * @param {Object} options
    * 
    * Example:
-     var p = Popcorn('#video')
+     var p = Popcorn( '#video' )
         .googlemap({
           start: 5, // seconds
           end: 15, // seconds
@@ -73,9 +73,9 @@ var openlayersCallback;
           var head = document.getElementsByTagName('head')[0];
           var script = document.createElement('script');
           script.src = "http://openlayers.org/api/OpenLayers.js";
-                 script.onload = function() {
-                               _mapLoaded    = true;
-                       };
+          script.onload = function() {
+                   _mapLoaded    = true;
+          };
           script.type = "text/javascript";
           head.insertBefore( script, head.firstChild ); 
                  /*Popcorn.getScript("http://openlayers.org/api/OpenLayers.js",
@@ -84,36 +84,33 @@ var openlayersCallback;
                        }); */
         }
         // callback function fires when the script is run
-        // geolocation is not possible, only give lat and lng properties
+        // geolocation to be added through Yahoo Maps JSONP
         var isGeoReady = function() {
           if ( !_mapLoaded ) {
-            setTimeout(function () {
+            setTimeout( function () {
               isGeoReady();
             }, 5);
           } else {
 
-                 options._location = new OpenLayers.LonLat(options.lng, options.lat);
-
-                       if(options.type == "ROADMAP"){
-                               // add OpenStreetMap layer
-                               options._projection = new OpenLayers.Projection('EPSG:900913');
-                               options._displayProjection = new OpenLayers.Projection('EPSG:4326');
-                               options._location = options._location.transform(options._displayProjection, options._projection);
-                               options._map = new OpenLayers.Map({div: options._newdiv, projection: options._projection, 'displayProjection': options._displayProjection});
-                               var osm = new OpenLayers.Layer.OSM();
-                               options._map.addLayer(osm);
-                       }
-                       else if(options.type == "SATELLITE"){
-                               // add NASA WorldWind / LANDSAT map
-                               var ww2 = new OpenLayers.Layer.WorldWind( "LANDSAT",
-                "http://worldwind25.arc.nasa.gov/tile/tile.aspx", 2.25, 4,
-                {T:"105"});
-                               options._map = new OpenLayers.Map({div: options._newdiv, 'maxResolution': .28125, tileSize: new OpenLayers.Size(512, 512)});
-                               options._map.addLayer(ww2);
-                               options._displayProjection = new OpenLayers.Projection('EPSG:4326');
-                               options._projection = new OpenLayers.Projection('EPSG:4326');
-                       }
-                       options._map.div.style.display = 'none';
+            options._location = new OpenLayers.LonLat( options.lng, options.lat );
+            if( options.type == "ROADMAP" ) {
+              // add OpenStreetMap layer
+              options._projection = new OpenLayers.Projection( 'EPSG:900913' );
+              options._displayProjection = new OpenLayers.Projection( 'EPSG:4326' );
+              options._location = options._location.transform( options._displayProjection, options._projection );
+              options._map = new OpenLayers.Map( { div: options._newdiv, projection: options._projection, 'displayProjection': options._displayProjection } );
+              var osm = new OpenLayers.Layer.OSM();
+              options._map.addLayer( osm );
+            }
+            else if( options.type == "SATELLITE" ) {
+              // add NASA WorldWind / LANDSAT map
+              options._map = new OpenLayers.Map( { div: options._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" } );
+              options._map.addLayer( worldwind );
+              options._displayProjection = new OpenLayers.Projection( 'EPSG:4326' );
+              options._projection = new OpenLayers.Projection( 'EPSG:4326' );
+            }
+            options._map.div.style.display = 'none';
           }
         };
         isGeoReady();
@@ -124,7 +121,7 @@ var openlayersCallback;
        * of the video  reaches the start time provided by the 
        * options variable
        */
-      start: function(event, options){
+      start: function( event, options ) {
         // wait until OpenLayers is loaded, then check repeatedly if markers need to be added/removed
                
         var isReady = function () {    
@@ -141,39 +138,39 @@ var openlayersCallback;
             options.zoom = options.zoom || 2; // default to 2
 
             // reset the location and zoom just in case the user played with the map
-            options._map.setCenter(options._location, options.zoom);
-                       if(options.markers){
-                               setInterval(function() {
-                                       for(var m=0;m<options.markers.length;m++){
-                                               var myMarker=options.markers[m];
-                                               if(myMarker.isOn){
-                                                       //check if marker should be removed
-                                                       if((myMarker.popcorn.popped.currentTime() < myMarker.start)||(myMarker.popcorn.popped.currentTime() > myMarker.end)){
-                                                               options._pointLayer.removeFeatures([myMarker.isOn]);
-                                                               myMarker.isOn=false;
-                                                       }
-                                               }
-                                               else{
-                                                       //check if marker should be added
-                                                       if((myMarker.popcorn.popped.currentTime() > myMarker.start)&&(myMarker.popcorn.popped.currentTime() < myMarker.end)){
-                                                               var layerStyle = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
-                                                               if(!options._pointLayer){
-                                                                       options._pointLayer = new OpenLayers.Layer.Vector("Point Layer",{style: layerStyle});
-                                                                       options._map.addLayer(options._pointLayer);
-                                                               }
-                                                               var myPoint = new OpenLayers.Geometry.Point(myMarker.lng,myMarker.lat).transform( options._displayProjection,options._projection);
-                                                               var myPointStyle = OpenLayers.Util.extend({},layerStyle);
-                                                                       myPointStyle.pointRadius = 18;
-                                                                       myPointStyle.graphicOpacity = 1;
-                                                                       myPointStyle.externalGraphic = myMarker.icon;
-                                                               var myPointFeature = new OpenLayers.Feature.Vector(myPoint,null,myPointStyle);
-                                                               options._pointLayer.addFeatures([myPointFeature]);
-                                                               myMarker.isOn=myPointFeature;
-                                                       }
-                                               }
-                                       }
-                               }, 300);
-                       }
+            options._map.setCenter( options._location, options.zoom );
+            if( options.markers ){
+              setInterval( function() {
+                for( var m=0; m<options.markers.length; m++ ) {
+                  var myMarker = options.markers[ m ];
+                  if( myMarker.isOn ) {
+                    //marker is shown; check if marker should be removed
+                    if( ( myMarker.popcorn.popped.currentTime() < myMarker.start ) || ( myMarker.popcorn.popped.currentTime() > myMarker.end ) ){
+                      options._pointLayer.removeFeatures( [ myMarker.isOn ] );
+                      myMarker.isOn = false;
+                    }
+                  }
+                  else {
+                    //marker is hidden; check if marker should be added
+                    if( ( myMarker.popcorn.popped.currentTime() > myMarker.start ) && ( myMarker.popcorn.popped.currentTime() < myMarker.end ) ) {
+                      var layerStyle = OpenLayers.Util.extend( {} , OpenLayers.Feature.Vector.style[ 'default' ] );
+                      if( !options._pointLayer ) {
+                        options._pointLayer = new OpenLayers.Layer.Vector( "Point Layer", { style: layerStyle } );
+                        options._map.addLayer( options._pointLayer );
+                      }
+                      var myPoint = new OpenLayers.Geometry.Point( myMarker.lng, myMarker.lat ).transform( options._displayProjection, options._projection );
+                      var myPointStyle = OpenLayers.Util.extend( {}, layerStyle );
+                      myPointStyle.pointRadius = 18;
+                      myPointStyle.graphicOpacity = 1;
+                      myPointStyle.externalGraphic = myMarker.icon;
+                      var myPointFeature = new OpenLayers.Feature.Vector( myPoint, null, myPointStyle );
+                      options._pointLayer.addFeatures( [ myPointFeature ] );
+                      myMarker.isOn = myPointFeature;
+                    }
+                  }
+                }
+              }, 300);
+            }
           }
         };
         
@@ -182,17 +179,17 @@ var openlayersCallback;
       /**
        * @member openmap
        * The end function will be executed when the currentTime 
-       * of the video  reaches the end time provided by the 
+       * of the video reaches the end time provided by the 
        * options variable
        */
-      end: function(event, options){
+      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 (options._map) {
           options._map.div.style.display = 'none';          
         }
       }
-      
+
     };
     
   })());
index 90200dbd358751fb41007178298e274f9ce680cf..c0990690d4cc01f4be5c702bfc24eadf2e527c9c 100644 (file)
@@ -1,12 +1,12 @@
 test("Popcorn Open Map Plugin", function () {
   
   var popped = Popcorn("#video"),
-      expects = 10, 
-      count = 0,
-      mapInterval,
-      mapInterval2,
-      mapInterval3,
-      mapInterval4;
+    expects = 10, 
+    count = 0,
+    mapInterval,
+    mapInterval2,
+    mapInterval3,
+    mapInterval4;
   
   expect(expects);
   
@@ -28,27 +28,26 @@ test("Popcorn Open Map Plugin", function () {
   plus();
   
   popped.openmap({
-        start: 0, // seconds
-        end: 5, // seconds
-        type: 'ROADMAP',
-        target: 'map',
-        lat: 43.665429,
-        lng: -79.403323,
-        zoom: 10
-      } )
-      .googlemap({
-        start: 0, // seconds
-        end: 5, // seconds
-        type: 'SATELLITE',
-        target: 'map2',
-        lat: 0,
-        lng: 0,
-        zoom: 4
-      } )
-    .volume(0)
-    .play();
-  
-  
+    start: 0, // seconds
+    end: 5, // seconds
+    type: 'ROADMAP',
+    target: 'map',
+    lat: 43.665429,
+    lng: -79.403323,
+    zoom: 10
+  } )
+  .googlemap({
+    start: 0, // seconds
+    end: 5, // seconds
+    type: 'SATELLITE',
+    target: 'map2',
+    lat: 0,
+    lng: 0,
+    zoom: 4
+  } )
+  .volume(0)
+  .play();
+
   mapInterval = setInterval( function() {
     if( popped.currentTime() > 3 && popped.currentTime() <= 5 ) {
       ok(OpenLayers, "OpenLayers is available");
@@ -78,4 +77,4 @@ test("Popcorn Open Map Plugin", function () {
     }
   }, 1000);
   
-});
+});
\ No newline at end of file