Add this function:
Timeline._Band.prototype.addDecorator = function(decorator) {
this._decorators.push(decorator);
decorator.initialize(this,this._timeline);
decorator.paint();
}
then you can do:
var band = tl.getBand(0);
band.addDecorator(new Timeline.SpanHighlightDecorator({
id:"newDecoraor",
startDate:new Date("Nov 22 1963 15:00:00"),
endDate:new Date("Nov 22 1963 16:00:00"),
startLabel:"begin",
endLabel:"end"})
);
And in case anyone asks:
Timeline._Band.prototype.removeDecorator = function(index) {
this._decorators[index].remove();
this._decorators.splice(index,1);
}
Timeline.SpanHighlightDecorator.prototype.remove = function() {
if (this._layerDiv != null) {
this._band.removeLayerDiv(this._layerDiv);
}
};
--Mike
On Oct 27, 2011, at 12:39 PM, Alvin Cheung wrote:
> I see. Thanks. Then is it possible to dynamically add decorators?
>
> Alvin
>
> On 10/27/2011 12:16 PM, Michael Nosal wrote:
>> Yes, this is possible, and quite easy to do.
>> You do need to add a method to set the times for your decorator and call
>> .paint() on the decorator:
>>
>> Timeline.SpanHighlightDecorator.prototype.setEndDate = function(date) {
>> this._endDate = date;
>> };
>> Timeline.SpanHighlightDecorator.prototype.setStartDate = function(date) {
>> this._startDate = date;
>> };
>> Timeline._Band.prototype.getDecorators = function() {
>> return this._decorators;
>> }
>>
>> Then you can do:
>> var myDecorator = tl.getBand(0).getDecorators()[0];
>> var ns = new Date("Nov 22 1963 13:35:00");
>> var ne = new Date("Nov 22 1963 14:05:00");
>> myDecorator.setStartDate(ns);
>> myDecorator.setEndDate(ne);
>> myDecorator.paint();
>>
>> Try this on the JFK example and you'll see the shot/t.o.d. decorator shift
>> by five minutes without having to rebuild the entire timeline.
>> It is a simple matter to update all your decorators dynamically this way, or
>> to update them with dynamic data from a server.
>>
>> --Mike
>>
>> On Oct 27, 2011, at 8:20 AM, Alvin wrote:
>>
>>> Hello, I am wondering if there is a way to update the highlighted
>>> parts of the timeline dynamically (i.e., update the decorators)? I
>>> got it to work by re-creating the entire timeline but that
>>> unfortunately will also recenter the timeline. Thanks.
>>>
>>> --
>>> 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.