Refresh TimeSlider with new data

890
4
Jump to solution
10-14-2022 01:18 AM
quooston
New Contributor III

I have a GeoJSONLayer which I am creating on the client, as a result of data from a webservice at my backend. I am using this layer to create a heatmap, which I am binding to a TimeSlider, so that I can see the heatmap over time. 

The user can change the time frame from which the GeoJSONLayer is created, for example, go from one day to two days. When this happens, I get data from my backend for the new time frame. I re-create the GoeJSONLayer and destroy and recreate the TimeSlider, as it's fullTimeExtent has completely changed. Essentially a complete reset.

But, what is happening is that the TimeSlider is removed from the UI when I reset, and I can't get it back. What is the prefered method of updating the data/layer that the TimeSlider is bound to, so that it can cope with the data changing and start over? 

Here is the workflow I am using: 

Get data from server -> create TimeSlider, supplying existing html container -> create GeoJSONLayer from the data returned from the server -> create heatmap from GeoJSONLayer using HeatMapRenderer -> wait for heatmap to be added to the view -> set TimeSlider fullTimeExtent and timeExtent -> watch timeExtent and filter heatmap layer using definitionExpression -> play TimeSlider.

When I do that the second time, the heatmap is displayed and even plays, but the TimeSlider is not on the UI. 

 

 

 

0 Kudos
1 Solution

Accepted Solutions
quooston
New Contributor III

I can confirm the reason that the timeslider would not be displayed when recreated. 

I was specifying the dom node that I want the timeslider to be rendered in using the `container` property. When the timeslider is destroyed, it removes the dom node... and therefore the next time it is created it exists, but is not displayed, as the dom node specified has been removed. 

I have addressed this by simply not specifying the dom node, and now it works as expected, although I have less control over the dimensions of the timeslider etc. I can of course recreate the node and so on... I will see. 

View solution in original post

0 Kudos
4 Replies
UndralBatsukh
Esri Regular Contributor

Hi there, 

Can you please create a simple repro case? Seems like an app specific issue. You can use this codepen app as a starting point: https://codepen.io/U_B_U/pen/GRdeogw?editors=100

 

0 Kudos
quooston
New Contributor III

If only... my repro works perfectly 😐 

https://gist.github.com/quooston/572810ea6bba9f67a6dd788067e1805b

 

0 Kudos
quooston
New Contributor III

If you'd check out what I'm doing and let me know if that is the prefered method of loading more data dynamcally into the layer and timeslider, that would be appreciated. 

0 Kudos
quooston
New Contributor III

I can confirm the reason that the timeslider would not be displayed when recreated. 

I was specifying the dom node that I want the timeslider to be rendered in using the `container` property. When the timeslider is destroyed, it removes the dom node... and therefore the next time it is created it exists, but is not displayed, as the dom node specified has been removed. 

I have addressed this by simply not specifying the dom node, and now it works as expected, although I have less control over the dimensions of the timeslider etc. I can of course recreate the node and so on... I will see. 

0 Kudos