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>
/**
* 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
_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,
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' );
} 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" );
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();
<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>
<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>
test("Popcorn OpenMap Plugin", function () {
var popped = Popcorn("#video"),
- expects = 12,
+ expects = 14,
count = 0,
mapInterval,
mapInterval2,
lng: -78.968525,
zoom: 14
} )
+ .openmap( {
+ start: 0,
+ end: 5,
+ target: 'map4',
+ lat: 40.943926,
+ lng: -78.968525,
+ zoom: "14"
+ } )
.volume(0)
.play();
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
+++ /dev/null
-## 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