Hi
I'm looking for an example where layerDefinition can be changed by user.
I'm showing a map with timeslider and filter next to the map. The map displays regions.
There are some filter options, which can be changed, like age and year.
When I change the age or year, I want to make the map (including the timeslider) to accept the selected filter option.
I have a solution, but I want to be sure, that it is the right way how to do it.
So...I create ArcGISDynamicMapServiceLayer layer. It contains 7 layers, where each layer contains data for one specific year. Only one layer can be displayed at a time. I set the visible layer: someLayer.setVisibleLayers([array of layers]), set the layerDefinitions (containing some initial filter options) for the visible layer and then add the layers to the map (map.addLayers([array of layers])).
TimeSlider init goes after that.
What is the correct way to change the layer definitions when a filter option changes ?
I do it like this.
When the 'Age' filter option changes, I get the selected age and change the layerDefinitions for the visible layer by setting the layerDefinitions like this: someLayer.setLayerDefinitions(layerDefinitions), where layerDefinitions contains the new definition string.
When the 'Year' filter option changes, I do the same as when changing the age, but in this case I have to change the visible layer (someLayer.setVisibleLayers([array of layers])) and the timeslider has to be updated too. After setting the changed layerDefinition to the visible layer I finally update timeslider by changing its timestops using the changed TimeExtent (changed year means new timeextent). After that I start the timeslider and everything looks to be ok.
All I ask is: Is this solution OK or is there a better/cleaner solution fos this ?
Thank you
g