I think I have found the solution and wanted to share.

I added the following to the html file. It's triggered every second from a
timer:

var markTime = null;
function drawCurrentTimeLine()
{
    if ( markTime == null ) {
        markTime = new Date();
    }
    else {
        markTime = new Date(markTime.getTime() + 3000);
    }

    for ( var bandindx=0; bandindx < tl._bands.length; bandindx++ )
    {
        var band = tl._bands[bandindx];
        band.removeAllDecorators();

        var newdecorator = new Timeline.PointHighlightDecorator({
                date:
Timeline.DateTime.parseGregorianDateTime(markTime),
                color:      "#D1EC3C",
                width:        5,
                opacity:    30
            });

        band._decorators[0] = newdecorator;
        newdecorator.initialize(band, tl);

        band.layout();
    }
}

I then added the following function to band.js to remove the existing
decorator.

Timeline._Band.prototype.removeAllDecorators = function() {
    for (var i=0,l=this._decorators.length; i < l; i++) {
        this.removeLayerDiv(this._decorators[i]._layerDiv); // this is what
un-draws it.
        this._decorators[i] = null;
    }
}

I've only tested in firefox so far, but it's working exactly as I want it
to.

--Trudy


On Tue, Mar 15, 2011 at 5:09 PM, Trudy Voorhees <[email protected]>wrote:

> Mike,
>
> I do not see a 'remove()' function on the decorator. Is this a custom thing
> you wrote?
>
> --Trudy
>
>
>
> On Tue, Mar 15, 2011 at 2:13 PM, Michael Nosal <[email protected]> wrote:
>
>> You need to call .remove() on the decorator.
>> e.g.
>>
>> Timeline._Band.prototype.removeAllDecorators = function() {
>>        for (var i=0,l=this._decorators.length; i < l; i++) {
>>        this._decorators[0].remove();
>>        this._decorators.splice(0,1);
>>        }
>> }
>>
>> I've done exactly as you describe (add a highlight decorator to show the
>> current time) and I found it more convenient to add this as a "special"
>> decorator to the band itself, so I could remove and re-add just the
>> decorator for the current time without having to worry about the other
>> decorators that might be in the band.
>>
>> --Mike
>>
>>
>> On Mar 15, 2011, at 1:47 PM, Trudy wrote:
>>
>> >
>> > I have a timeline with six bands, and I draw a PointHighlightDecorator
>> > across all of the bands at the current time at startup. What I would
>> > like to do is have this decorator move along with the current time.
>> >
>> > I have set up a timer that fires every second, and then a new
>> > PointHighlightDecorator gets drawn on the timeline. The problem is
>> > that I cannot remove the old one. Here is my code so far (that doesn't
>> > work):
>> >
>> > <code>
>> >       for ( var i=0; i < tl._bands.length; i++ )
>> >       {
>> >               //var numdecorators = tl._bands[i]._decorators.length;
>> >               tl._bands[i]._decorators[0] = null; // memory leak?? Want
>> to erase
>> > the old one.
>> >
>> >               var newdecorator = new Timeline.PointHighlightDecorator({
>> >                               date:
>> Timeline.DateTime.parseGregorianDateTime(date = new
>> > Date()),
>> >                               color:      "#993300",
>> >                               opacity:    50
>> >                       });
>> >
>> >               tl._bands[i]._decorators[0] = newdecorator;
>> >               newdecorator.initialize(tl._bands[i], tl);
>> >
>> >
>> >       }
>> >
>> >       tl.layout();
>> > </code>
>> >
>> > I do not know how to safely remove decorators from a band. Nulling
>> > them out does not remove them from the timeline once they've been
>> > drawn.
>> >
>> > Thanks for any inputs!
>> >
>> > --Trudy
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "SIMILE Widgets" group.
>> > To post to this group, send email to [email protected].
>> > To unsubscribe from this group, send email to
>> [email protected].
>> > For more options, visit this group at
>> http://groups.google.com/group/simile-widgets?hl=en.
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "SIMILE Widgets" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/simile-widgets?hl=en.
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"SIMILE Widgets" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/simile-widgets?hl=en.

Reply via email to