OpenLayers OpenLayers

Changeset 6365

Show
Ignore:
Timestamp:
02/25/08 11:36:01 (11 months ago)
Author:
achipa
Message:

time-select-control fix

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/achipa/openlayers/examples/time-select-control.html

    r6364 r6365  
    2121            map.setCenter(new OpenLayers.LonLat(20.22, 22.05), 9); 
    2222            map.addControl(new OpenLayers.Control.LayerSwitcher()); 
    23             map.addControl(new OpenLayers.Control.PanTimeBar()); 
     23            timeBar = new OpenLayers.Control.PanTimeBar(); 
     24            map.addControl(timeBar); 
    2425        } 
    2526 
     
    5051 
    5152            // 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); 
    5355            map.events.register("datechanged", lineLayer, lineLayer.updateHighlight) 
    5456 
     
    6668            // keep markers on top of tracks 
    6769            map.raiseLayer(rss, 1); 
    68             map.getControlsByClass("OpenLayers.Control.PanTimeBar")[0].rangeFromFeatures(lineLayer.features); 
     70            timeBar.rangeFromFeatures(lineLayer.features); 
    6971        } 
    7072 
  • sandbox/achipa/openlayers/lib/OpenLayers/BaseTypes/ExtDate.js

    r6364 r6365  
    33 * Instances of this class represent moments or intervals of time. This allows us to 
    44 * 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. 
    66 */ 
    77 
     
    2121 */ 
    2222Date.prototype.contains = function(targetdate) { 
    23     if (targetdate >= this && targetdate.getEndDate() <= this.getEndDate())  
     23    if (targetdate >= this && targetdate.getEndDate() <= this.getEndDate()) 
    2424            return true; 
    2525 
     
    6262 * if it starts after the end of the date object, 1 is returned. 
    6363 * 
    64  * The optional second {bool} parameter defines whether the center of the  
     64 * The optional second {bool} parameter defines whether the center of the 
    6565 * targetdate's interval should be used (default is false). 
    6666 * 
     
    8484    else 
    8585        return (centerdate - this) / this.duration ; 
    86      
     86 
    8787}; 
    8888 
     
    9898 */ 
    9999Date.prototype.equals = function(targetdate) { 
    100     if (this == targetdate && this.duration == targetduration.duration) return true; 
     100    if (this == targetdate && this.duration == targetdate.duration) return true; 
    101101    return false; 
    102102}; 
  • sandbox/achipa/openlayers/lib/OpenLayers/Control/PanTimeBar.js

    r6362 r6365  
    396396        if (this.now < 0) this.now = 0; 
    397397        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++) { 
    399401            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(); 
    401416    }, 
    402417 
  • sandbox/achipa/openlayers/tests/list-tests.html

    r6033 r6365  
    9191    <li>Control/test_PanZoom.html</li> 
    9292    <li>Control/test_PanZoomBar.html</li> 
     93    <li>Control/test_PanTimeBar.html</li> 
    9394    <li>Control/test_Permalink.html</li> 
    9495    <li>Control/test_Scale.html</li>