[OpenLayers-Commits] r12287 - sandbox/mpriour/temporal_map/openlayers/examples

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Tue Aug 30 16:20:10 EDT 2011


Author: mpriour
Date: 2011-08-30 13:20:09 -0700 (Tue, 30 Aug 2011)
New Revision: 12287

Added:
   sandbox/mpriour/temporal_map/openlayers/examples/time-control.html
Log:
An example of using the time-control with a geoserver time enabled layer

Added: sandbox/mpriour/temporal_map/openlayers/examples/time-control.html
===================================================================
--- sandbox/mpriour/temporal_map/openlayers/examples/time-control.html	                        (rev 0)
+++ sandbox/mpriour/temporal_map/openlayers/examples/time-control.html	2011-08-30 20:20:09 UTC (rev 12287)
@@ -0,0 +1,105 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
+    <meta name="apple-mobile-web-app-capable" content="yes">
+    <title>OpenLayers: WMS + Time</title>
+    <link rel="stylesheet" href="../theme/default/style.css" type="text/css">
+    <link rel="stylesheet" href="style.css" type="text/css">
+    <style>
+        .tallmap{
+            width: 700px;
+            height: 500px;
+            border: 1px solid #ccc;
+        }
+    </style>
+    <script src="../lib/OpenLayers.js"></script>
+    <script type="text/javascript">
+        var map, train_wms;
+        function init(){
+            map = new OpenLayers.Map('map');
+
+            var osm = new OpenLayers.Layer.OSM();			
+
+            train_wms = new OpenLayers.Layer.WMS("Train Positions",
+            "http://mapstory.demo.opengeo.org:8080/wms", {
+				layers: "trainpositions",
+				transparent: true,
+				format: 'image/png',
+				time:OpenLayers.Date.toISOString(OpenLayers.Date.parse('2007-05-10T05:00:00Z'))
+			},{
+				timeInterval:[OpenLayers.Date.parse('2007-05-10T05:00:00Z'),OpenLayers.Date.parse('2007-05-10T23:59:00Z')],
+				timeStep:1,
+				timeUnit:OpenLayers.TimeUnit.MINUTES,
+                singleTile:true,
+                ratio:1,
+                transitionEffect:'resize'
+                //buffer:0,
+                //smoothRedraw:true
+			});
+			
+			timeCtl = new OpenLayers.Control.TimeManager({
+				range:train_wms.timeInterval,
+				units:train_wms.timeUnit,
+				step:train_wms.timeStep,
+				layers:[train_wms]
+			});
+			timeCtl.events.on({
+				'tick': update_date,
+				'reset': update_date,
+				'stop':function(evt){if(evt.rangeExceeded)alert('End of time range')},
+				scope: timeCtl
+			});
+
+            map.addLayers([ol_wms, jpl_wms, ia_wms]);
+            map.addControl(new OpenLayers.Control.LayerSwitcher());
+            map.zoomToExtent(new OpenLayers.Bounds(-100.898437,22.148438,-78.398437,39.726563));
+			update_date({
+				object: timeCtl,
+				currentTime: timeCtl.currentTime
+			});
+        }
+        function update_date(evt) {
+            var time = this.currentTime||evt.currentTime;
+			OpenLayers.Util.getElement('year').value = time.getFullYear();
+			OpenLayers.Util.getElement('month').value = time.getMonth();
+            OpenLayers.Util.getElement('day').value = time.getDate();
+            OpenLayers.Util.getElement('hour').value = time.getHours();
+            OpenLayers.Util.getElement('minute').value = time.getMinutes();
+        }
+    </script>
+  </head>
+  <body onload="init()">
+     <h1 id="title"> WMS Time Example</h1>
+        <div id="tags">
+            wmst, wms-t
+        </div>
+        <p id="shortdesc">
+            Shows the use of the TimeManager control with a single simple WMS-T (time) layer<br>
+			Click on the PLAY button to start.
+        </p>
+    <input size="4" type='text' id='year' value="" readonly="true" />-
+	<input size="2" type="text" id="month" value="" readonly="true" />-
+	<input size="2" type="text" id="day" value="" readonly="true" />T
+	<input type="text" size="2" id="hour" value="" readonly="true" />:
+	<input type="text" size="2" id="minute" value=""  readonly="true"/>:00
+	<div>
+		<button type="button" onclick="timeCtl.loop=false;timeCtl.stop()">Stop</button>
+		&nbsp;|&nbsp;<button type="button" onclick="timeCtl.reset()">Reset</button>
+		&nbsp;|&nbsp;<button type="button" onclick="timeCtl.loop=true;timeCtl.play()">Loop</button>
+		&nbsp;|&nbsp;<button type="button" onclick="timeCtl.tick()">Step</button>
+		&nbsp;|&nbsp;<button type="button" onclick="timeCtl.play()">Play</button>
+	</div>
+    <div id="map" class="largemap"></div>
+    <div id="docs">
+        <p>Time Control example: hit PLAY, and the trains position will change along with the<br>
+		time display. Uses the OpenLayers.Control.TimeManager to update the date<br>
+		elements with the time of the animation. Starts at 05:00 UTC and continues until
+        23:59 UTC or until you stop it</p>
+    </div>
+  </body>
+</html>
+
+
+



More information about the Commits mailing list