Hi Robert - again thankyou for a great widget.
I am experiencing an error which a few others have reported, in that I am getting a blank table of contents on first load. When this occurs all other widgets in the viewer cease to function as well. The problem reappears when the viewer is first opened or straight after the browser cache has been cleared. Once the page is refreshed it works fine.
I have done some testing with different services etc and have found that the problem occurs with as few as two dynamic services which have 7 layers each if there are popups configured for each sublayer. When no popups are specified the toc works fine with a large number of dynamic services. It also seems to work fine with tiled services regardless of number of services and popups.
Specifying a large legend timeout time in the config doesn't seem to fix the problem. The normal layer list widget configured for the same services etc works ok.
Cheers,
Ben
private function createChildren():void
{
children = null;
var layerInfos:Array; // of LayerInfo
var visibleLayers:Array;
var li:LayerInfo;
if (layer is ArcGISTiledMapServiceLayer){
layerInfos = ArcGISTiledMapServiceLayer(layer).layerInfos;
}else if (layer is ArcGISDynamicMapServiceLayer){
var arcGISDynamicMapServiceLayer:ArcGISDynamicMapServiceLayer = ArcGISDynamicMapServiceLayer(layer);
if (arcGISDynamicMapServiceLayer.visibleLayers == null) { //Added if check for bugfix
trace("found null");
}
else {
arcGISDynamicMapServiceLayer.visibleLayers.addEventListener(CollectionEvent.COLLECTION_CHANGE, visibleLayersChangeHandler);
}
_visibleLayersChangeWatcher = ChangeWatcher.watch(arcGISDynamicMapServiceLayer, "visibleLayers", visibleLayersChange);
_dynamicMapServiceLayerInfos = arcGISDynamicMapServiceLayer.dynamicLayerInfos ? arcGISDynamicMapServiceLayer.dynamicLayerInfos : arcGISDynamicMapServiceLayer.layerInfos; //Added per commit on GH
if (_isVisibleLayersSet){
....all code is the same for the rest of the createChildren function
Ben,
Thanks for narrowing down the issue to DLs with popups configured for sublayers. It is likely that I will be retiring this widget in lieu of an enhanced LayerListWidget soon as I have added most of the TOCWidget features to esris LayerListWidget and it has better response time for rendering and does not require some of the work arounds in code that I had to do for the TOC Widget. I will let the community know one way or another.
Ben,
Thanks for narrowing down the issue to DLs with popups configured for sublayers. It is likely that I will be retiring this widget in lieu of an enhanced LayerListWidget soon as I have added most of the TOCWidget features to esris LayerListWidget and it has better response time for rendering and does not require some of the work arounds in code that I had to do for the TOC Widget. I will let the community know one way or another.
Patrick,
If you need everything expanded at startup then you need to set the expand tag to true and its everything attribute to true as well.