OpenLayers OpenLayers

Changeset 6426

Show
Ignore:
Timestamp:
03/01/08 19:27:00 (10 months ago)
Author:
achipa
Message:

continuous option for the time select bar

Files:

Legend:

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

    r6391 r6426  
    2121            map.setCenter(new OpenLayers.LonLat(20.22, 22.05), 9); 
    2222            map.addControl(new OpenLayers.Control.LayerSwitcher()); 
    23             timeBar = new OpenLayers.Control.PanTimeBar(); 
     23            timeBar = new OpenLayers.Control.PanTimeBar( {continuous: true} ); 
    2424            map.addControl(timeBar); 
    2525            timepos = new OpenLayers.Control.TimePosition(); 
     
    5858            // update the date of the layer from the map property and redraw to keeep up with changes 
    5959            map.events.register("datechanged", lineLayer, lineLayer.setTimeFromMap); 
    60             map.events.register("datechanged", timeBar, timeBar.updateBar); 
    6160            map.events.register("datechanged", lineLayer, lineLayer.updateHighlight) 
    6261 
  • sandbox/achipa/openlayers/lib/OpenLayers/Control/PanTimeBar.js

    r6369 r6426  
    3939 
    4040    /** 
    41      * Property: zoomBarDiv 
     41     * Property: timeBarDiv 
    4242     * {DOMElement} 
    4343     */ 
     
    6363 
    6464    /** 
    65     * Ptoperty: now 
     65    * Property: Continuous drag. If true, the control will set fire datechanged events while 
     66    *    being dragged. 
     67    * {bool} 
     68    */ 
     69    continuous: false, 
     70 
     71    /** 
     72    * Property: The current Date of the Control 
    6673    * {int} 
    6774    */ 
     
    9299        this.divEvents = null; 
    93100 
    94         this.map.events.unregister("timeend", this, this.moveTimeBar); 
    95         //this.map.events.unregister("addlayer", this, this.redraw); 
     101        this.map.events.unregister("datechanged", this, this.updateBar); 
    96102 
    97103        OpenLayers.Control.PanTime.prototype.destroy.apply(this, arguments); 
     
    106112    setMap: function(map) { 
    107113        OpenLayers.Control.PanTime.prototype.setMap.apply(this, arguments); 
    108         //this.map.events.register("addlayer", this, this.addLayerEvent); 
    109114    }, 
    110115 
     
    245250        this.div.appendChild(slider); 
    246251 
    247         if (this.time.length) this.map.events.register("timeend", this, this.moveTimeBar); 
     252        if (this.time.length) this.map.events.register("datechanged", this, this.updateBar); 
    248253 
    249254        centered = centered.add(0, this.timeStopHeight * this.time.length+10); 
     
    275280        var top = OpenLayers.Util.pagePosition(evt.object)[1]; 
    276281        var levels = Math.floor((y - top)/this.timeStopHeight); 
    277         //this.map.zoomTo((this.map.getNumZoomLevels() -1) -  levels); 
    278282        OpenLayers.Event.stop(evt); 
    279283    }, 
    280284 
    281285    /* 
    282      * Method: zoomBarDown 
     286     * Method: timeBarDown 
    283287     * event listener for clicks on the slider 
    284288     * 
     
    301305 
    302306    /* 
    303      * Method: zoomBarDrag 
     307     * Method: timeBarDrag 
    304308     * This is what happens when a click has occurred, and the client is 
    305309     * dragging.  Here we must ensure that the slider doesn't go beyond the 
     
    318322                var newTop = parseInt(this.slider.style.top) - deltaY; 
    319323                this.slider.style.top = newTop+"px"; 
     324                if (this.continuous) {  
     325                    this.now += Math.round(deltaY/this.timeStopHeight); 
     326                    if (this.now < 0) this.now = 0; 
     327                    else if (this.now > this.time.length) this.now = this.time.length; 
     328                    this.setMapTime(); 
     329                } 
    320330            } 
    321331            this.mouseDragStart = evt.xy.clone(); 
     
    325335 
    326336    /* 
    327      * Method: zoomBarUp 
     337     * Method: timeBarUp 
    328338     * Perform cleanup when a mouseup event is received -- discover new zoom 
    329339     * level and switch to it. 
     
    341351            this.map.events.unregister("mousemove", this, this.passEventToSlider); 
    342352            var deltaY = (this.timeStart.y+OpenLayers.Control.PanTime.Y-10) - (evt.xy.y+OpenLayers.Control.PanTime.Y-10); 
    343             this.now += Math.round(deltaY/this.timeStopHeight); 
     353            if (!this.continuous) 
     354                this.now += Math.round(deltaY/this.timeStopHeight); 
    344355            if (this.now < 0) this.now = 0; 
    345356            else if (this.now > this.time.length) this.now = this.time.length; 
  • sandbox/achipa/openlayers/lib/OpenLayers/Control/TimePosition.js

    r6369 r6426  
    3232     * Method: destroy 
    3333     */ 
    34     destroy: function() { 
     34    destroy: function() { 
    3535         if (this.map) { 
    3636             this.map.events.unregister('datechanged', this, this.redraw);