}else if (m_layer is WMSLayer){
Hello Robert,
I'm sure you have covered this, so hopefully it will be easy to respond. When I combine the TOC with the Selection Widget, Once the Selection widget is activated, all the FeatureLayers used in the Selection Widget get added to the TOC, preventing FeatureLayers from being added is an option for me, but I'd figured I'll check with you to see if there is a cleaner solution.
Thanks for your hard work
private function getLegendData(m_layer:*):void { if (_legendDataLoaded) return; _legendDataLoaded = true; if (m_layer.hasOwnProperty("url")){ const url:String = m_layer["url"]; if (url === null) return; }else{ return; } var httpServ:HTTPService = new HTTPService(); httpServ.requestTimeout = lTimeout; var lname:String; var lInfos:Array; if (m_layer is ArcGISTiledMapServiceLayer){ if(m_layer.version >= 10.01){ if(ArcGISTiledMapServiceLayer(m_layer).proxyURL){ //If layer uses proxy (my addition for proxy support) httpServ.url = ArcGISTiledMapServiceLayer(m_layer).proxyURL + "?" + ArcGISTiledMapServiceLayer(m_layer).url + "/legend?f=json"; }else{ //if layer doesn't use proxy (original code) httpServ.url = ArcGISTiledMapServiceLayer(m_layer).url + "/legend?f=json"; } httpServ.resultFormat = "text"; lname = ArcGISTiledMapServiceLayer(m_layer).id; lInfos = ArcGISTiledMapServiceLayer(m_layer).layerInfos; httpServ.addEventListener(ResultEvent.RESULT,function(event:ResultEvent):void{processLegend(event,lname,Number.NaN,lInfos,httpServ.url)}); httpServ.send(); }else{ lname = ArcGISTiledMapServiceLayer(m_layer).id; ArcGISTiledMapServiceLayer(m_layer).addEventListener(DetailsEvent.GET_ALL_DETAILS_COMPLETE,function(event:DetailsEvent):void{getAllDetailsResult(event,lname)}); ArcGISTiledMapServiceLayer(m_layer).addEventListener(FaultEvent.FAULT, function(event:Event):void{FlexGlobals.topLevelApplication.dispatchEvent(new Event("legendDataLoaded$"))}); ArcGISTiledMapServiceLayer(m_layer).getAllDetails(); } }else if (m_layer is ArcGISDynamicMapServiceLayer){ if(m_layer.version >= 10.01){ if(ArcGISDynamicMapServiceLayer(m_layer).proxyURL){ //If layer uses proxy (my addition for proxy support) httpServ.url = ArcGISDynamicMapServiceLayer(m_layer).proxyURL + "?" + ArcGISDynamicMapServiceLayer(m_layer).url + "/legend?f=json"; }else{ //if layer doesn't use proxy (original code) httpServ.url = ArcGISDynamicMapServiceLayer(m_layer).url + "/legend?f=json"; } httpServ.resultFormat = "text"; lname = ArcGISDynamicMapServiceLayer(m_layer).id; lInfos = ArcGISDynamicMapServiceLayer(m_layer).layerInfos httpServ.addEventListener(ResultEvent.RESULT,function(event:ResultEvent):void{processLegend(event,lname,Number.NaN,lInfos,httpServ.url)}); httpServ.send(); }else{ lname = ArcGISDynamicMapServiceLayer(m_layer).id; ArcGISDynamicMapServiceLayer(m_layer).addEventListener(DetailsEvent.GET_ALL_DETAILS_COMPLETE,function(event:DetailsEvent):void{getAllDetailsResult(event,lname)}); ArcGISDynamicMapServiceLayer(m_layer).addEventListener(FaultEvent.FAULT, function(event:Event):void{FlexGlobals.topLevelApplication.dispatchEvent(new Event("legendDataLoaded$"))}); ArcGISDynamicMapServiceLayer(m_layer).getAllDetails(); } }else if (m_layer is KMLLayer) { timeOutVar = setTimeout(getKMLLegend, 100, m_layer); }else if (m_layer is FeatureLayer){ var FeatServId:Number = Number.NaN; var msName:String = FeatureLayer(m_layer).url.replace("FeatureServer","MapServer"); if(msName.substring(msName.length - 9) != "MapServer"){ if(FeatureLayer(m_layer).proxyURL){ //If layer uses proxy (my addition for proxy support) httpServ.url = FeatureLayer(m_layer).proxyURL + "?" + msName.substring(0,msName.lastIndexOf("/")) + "/legend?f=json"; }else{ //if layer doesn't use proxy (original code) httpServ.url = msName.substring(0,msName.lastIndexOf("/")) + "/legend?f=json"; } FeatServId = parseInt(msName.substring(msName.lastIndexOf("/")+ 1)); }else{ if(FeatureLayer(m_layer).proxyURL){ //If layer uses proxy (my addition for proxy support) httpServ.url = FeatureLayer(m_layer).proxyURL + "?" + msName + "/legend?f=json"; }else{ //if layer doesn't use proxy (original code) httpServ.url = msName + "/legend?f=json"; } } if(m_layer.layerDetails.version >= 10.01){ httpServ.resultFormat = "text"; lname = FeatureLayer(m_layer).id; httpServ.addEventListener(ResultEvent.RESULT,function(event:ResultEvent):void{processLegend(event,lname,FeatServId)}); httpServ.send(); } else { lname = FeatureLayer(m_layer).id; getFeatureResult(FeatureLayer(m_layer).layerDetails,lname); } }else{ FlexGlobals.topLevelApplication.dispatchEvent(new Event("legendDataLoaded$")); } }
private function getLegendData(m_layer:*):void { if (_legendDataLoaded) return; _legendDataLoaded = true; if (m_layer.hasOwnProperty("url")){ const url:String = m_layer["url"]; if (url === null) return; }else{ return; } var httpServ:HTTPService = new HTTPService(); httpServ.requestTimeout = lTimeout; var lname:String; var lInfos:Array; var tURL:String; if (m_layer is ArcGISTiledMapServiceLayer){ if(m_layer.version >= 10.01){ tURL = ArcGISTiledMapServiceLayer(m_layer).url; if(tURL.indexOf("?token=") > 0){ httpServ.url = ArcGISTiledMapServiceLayer(m_layer).url.replace("?token=", "/legend?f=json&token="); }else if(ArcGISTiledMapServiceLayer(m_layer).proxyURL){ //If layer uses proxy httpServ.url = ArcGISTiledMapServiceLayer(m_layer).proxyURL + "?" + ArcGISTiledMapServiceLayer(m_layer).url + "/legend?f=json"; }else{ httpServ.url = ArcGISTiledMapServiceLayer(m_layer).url + "/legend?f=json"; } httpServ.resultFormat = "text"; lname = ArcGISTiledMapServiceLayer(m_layer).id; lInfos = ArcGISTiledMapServiceLayer(m_layer).layerInfos; httpServ.addEventListener(ResultEvent.RESULT,function(event:ResultEvent):void{processLegend(event,lname,Number.NaN,lInfos,httpServ.url)}); httpServ.send(); }else{ lname = ArcGISTiledMapServiceLayer(m_layer).id; ArcGISTiledMapServiceLayer(m_layer).addEventListener(DetailsEvent.GET_ALL_DETAILS_COMPLETE,function(event:DetailsEvent):void{getAllDetailsResult(event,lname)}); ArcGISTiledMapServiceLayer(m_layer).addEventListener(FaultEvent.FAULT, function(event:Event):void{FlexGlobals.topLevelApplication.dispatchEvent(new Event("legendDataLoaded$"))}); ArcGISTiledMapServiceLayer(m_layer).getAllDetails(); } }else if (m_layer is ArcGISDynamicMapServiceLayer){ if(m_layer.version >= 10.01){ tURL = ArcGISDynamicMapServiceLayer(m_layer).url; if(tURL.indexOf("?token=") > 0){ httpServ.url = ArcGISDynamicMapServiceLayer(m_layer).url.replace("?token=", "/legend?f=json&token="); }else if(ArcGISDynamicMapServiceLayer(m_layer).proxyURL){ //If layer uses proxy httpServ.url = ArcGISDynamicMapServiceLayer(m_layer).proxyURL + "?" + ArcGISDynamicMapServiceLayer(m_layer).url + "/legend?f=json"; }else{ httpServ.url = ArcGISDynamicMapServiceLayer(m_layer).url + "/legend?f=json"; } httpServ.resultFormat = "text"; lname = ArcGISDynamicMapServiceLayer(m_layer).id; lInfos = ArcGISDynamicMapServiceLayer(m_layer).layerInfos httpServ.addEventListener(ResultEvent.RESULT,function(event:ResultEvent):void{processLegend(event,lname,Number.NaN,lInfos,httpServ.url)}); httpServ.send(); }else{ lname = ArcGISDynamicMapServiceLayer(m_layer).id; ArcGISDynamicMapServiceLayer(m_layer).addEventListener(DetailsEvent.GET_ALL_DETAILS_COMPLETE,function(event:DetailsEvent):void{getAllDetailsResult(event,lname)}); ArcGISDynamicMapServiceLayer(m_layer).addEventListener(FaultEvent.FAULT, function(event:Event):void{FlexGlobals.topLevelApplication.dispatchEvent(new Event("legendDataLoaded$"))}); ArcGISDynamicMapServiceLayer(m_layer).getAllDetails(); } }else if (m_layer is KMLLayer){ timeOutVar = setTimeout(getKMLLegend, 100, m_layer); }else if (m_layer is FeatureLayer){ var FeatServId:Number = Number.NaN; var msName:String = FeatureLayer(m_layer).url.replace("FeatureServer","MapServer"); if(msName.substring(msName.length - 9) != "MapServer"){ tURL = msName.substring(0,msName.lastIndexOf("/")); if(tURL.indexOf("?token=") > 0){ httpServ.url = msName.substring(0,msName.lastIndexOf("/")).replace("?token=", "/legend?f=json&token="); }else if(FeatureLayer(m_layer).proxyURL){ //If layer uses proxy httpServ.url = FeatureLayer(m_layer).proxyURL + "?" + msName.substring(0,msName.lastIndexOf("/")) + "/legend?f=json"; }else{ httpServ.url = msName.substring(0,msName.lastIndexOf("/")) + "/legend?f=json"; } FeatServId = parseInt(msName.substring(msName.lastIndexOf("/")+ 1)); }else{ httpServ.url = msName + "/legend?f=json"; } if(m_layer.layerDetails.version >= 10.01){ httpServ.resultFormat = "text"; lname = FeatureLayer(m_layer).id; httpServ.addEventListener(ResultEvent.RESULT,function(event:ResultEvent):void{processLegend(event,lname,FeatServId)}); httpServ.send(); }else{ lname = FeatureLayer(m_layer).id; getFeatureResult(FeatureLayer(m_layer).layerDetails,lname); } }else{ FlexGlobals.topLevelApplication.dispatchEvent(new Event("legendDataLoaded$")); } }