Changeset 6365
- Timestamp:
- 02/25/08 11:36:01 (11 months ago)
- Files:
-
- sandbox/achipa/openlayers/examples/time-select-control.html (modified) (3 diffs)
- sandbox/achipa/openlayers/lib/OpenLayers/BaseTypes/ExtDate.js (modified) (5 diffs)
- sandbox/achipa/openlayers/lib/OpenLayers/Control/PanTimeBar.js (modified) (1 diff)
- sandbox/achipa/openlayers/tests/list-tests.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/achipa/openlayers/examples/time-select-control.html
r6364 r6365 21 21 map.setCenter(new OpenLayers.LonLat(20.22, 22.05), 9); 22 22 map.addControl(new OpenLayers.Control.LayerSwitcher()); 23 map.addControl(new OpenLayers.Control.PanTimeBar()); 23 timeBar = new OpenLayers.Control.PanTimeBar(); 24 map.addControl(timeBar); 24 25 } 25 26 … … 50 51 51 52 // update the date of the layer from the map property and redraw to keeep up with changes 52 map.events.register("datechanged", lineLayer, lineLayer.setTimeFromMap); 53 map.events.register("datechanged", lineLayer, lineLayer.setTimeFromMap); 54 map.events.register("datechanged", timeBar, timeBar.updateBar); 53 55 map.events.register("datechanged", lineLayer, lineLayer.updateHighlight) 54 56 … … 66 68 // keep markers on top of tracks 67 69 map.raiseLayer(rss, 1); 68 map.getControlsByClass("OpenLayers.Control.PanTimeBar")[0].rangeFromFeatures(lineLayer.features);70 timeBar.rangeFromFeatures(lineLayer.features); 69 71 } 70 72 sandbox/achipa/openlayers/lib/OpenLayers/BaseTypes/ExtDate.js
r6364 r6365 3 3 * Instances of this class represent moments or intervals of time. This allows us to 4 4 * give the spatial data a temporal dimension and act accordingly. The default timezone 5 * is UTC and the precision is in seconds. 5 * is UTC and the precision is in seconds. 6 6 */ 7 7 … … 21 21 */ 22 22 Date.prototype.contains = function(targetdate) { 23 if (targetdate >= this && targetdate.getEndDate() <= this.getEndDate()) 23 if (targetdate >= this && targetdate.getEndDate() <= this.getEndDate()) 24 24 return true; 25 25 … … 62 62 * if it starts after the end of the date object, 1 is returned. 63 63 * 64 * The optional second {bool} parameter defines whether the center of the 64 * The optional second {bool} parameter defines whether the center of the 65 65 * targetdate's interval should be used (default is false). 66 66 * … … 84 84 else 85 85 return (centerdate - this) / this.duration ; 86 86 87 87 }; 88 88 … … 98 98 */ 99 99 Date.prototype.equals = function(targetdate) { 100 if (this == targetdate && this.duration == targetd uration.duration) return true;100 if (this == targetdate && this.duration == targetdate.duration) return true; 101 101 return false; 102 102 }; sandbox/achipa/openlayers/lib/OpenLayers/Control/PanTimeBar.js
r6362 r6365 396 396 if (this.now < 0) this.now = 0; 397 397 else if (this.now >= this.time.length) this.now = this.time.length-1; 398 for (var i=0; i < this.map.layers.length; i++) { 398 this.map.setTime(this.time[this.now]); 399 //alert(DumpObj(this.time[this.now]), 'valami', '-', 8); 400 /*for (var i=0; i < this.map.layers.length; i++) { 399 401 if (this.map.layers[i].isTemporalLayer()) this.map.layers[i].setTime(this.time[this.now]); 400 } 402 }*/ 403 }, 404 405 updateBar: function() { 406 var diff = Math.abs(this.time[0] - this.map.currentDateTime); 407 var best = 0; 408 for (var i=0; i < this.time.length; i++) { 409 if (diff > Math.abs(this.time[i] - this.map.currentDateTime)) { 410 diff = Math.abs(this.time[i] - this.map.currentDateTime); 411 best = i; 412 } 413 } 414 this.now = best; 415 this.moveTimeBar(); 401 416 }, 402 417 sandbox/achipa/openlayers/tests/list-tests.html
r6033 r6365 91 91 <li>Control/test_PanZoom.html</li> 92 92 <li>Control/test_PanZoomBar.html</li> 93 <li>Control/test_PanTimeBar.html</li> 93 94 <li>Control/test_Permalink.html</li> 94 95 <li>Control/test_Scale.html</li>
