Kirti, Try this //Add this import at the top with the others import mx.binding.utils.ChangeWatcher; //replace your existing function with this one private function showStateLegend(event:MouseEvent):void { WidgetEffects.flipWidget(this, viewStack, "selectedIndex", 1, 400); //This is where we determine if this is the first call to make //the legend or do we just need to update it if (legendRepeater.dataProvider != null){ updateLegend(); } else { showMessage("Please be patient while the Legend is generated...", true); var liveLayers:Array = getLayers(); var url:String; for (var i:int = 0; i < liveLayers.length;i++) { if (liveLayers is ArcGISDynamicMapServiceLayer) { if (ArcGISDynamicMapServiceLayer(liveLayers).id != "Aerial Photography") { requestCount++; url = ArcGISDynamicMapServiceLayer(liveLayers).url.replace("rest/", ""); webService.generateLegends.send(url, 96, 20, 20, ArcGISDynamicMapServiceLayer(liveLayers).id); ChangeWatcher.watch(ArcGISDynamicMapServiceLayer(liveLayers), "visibleLayers", updateLegend2); } } else if (liveLayers is ArcGISTiledMapServiceLayer) { requestCount++; url = ArcGISTiledMapServiceLayer(liveLayers).url.replace("rest/", ""); webService.generateLegends.send(url, 96, 20, 20, ArcGISTiledMapServiceLayer(liveLayers).id); ChangeWatcher.watch(ArcGISTiledMapServiceLayer(liveLayers), "visibleLayers", updateLegend2); } } } }
//Add this import at the top with the others import mx.binding.utils.ChangeWatcher; //replace your existing function with this one private function showStateLegend(event:MouseEvent):void { WidgetEffects.flipWidget(this, viewStack, "selectedIndex", 1, 400); //This is where we determine if this is the first call to make //the legend or do we just need to update it if (legendRepeater.dataProvider != null){ updateLegend(); } else { showMessage("Please be patient while the Legend is generated...", true); var liveLayers:Array = getLayers(); var url:String; for (var i:int = 0; i < liveLayers.length;i++) { if (liveLayers is ArcGISDynamicMapServiceLayer) { if (ArcGISDynamicMapServiceLayer(liveLayers).id != "Aerial Photography") { requestCount++; url = ArcGISDynamicMapServiceLayer(liveLayers).url.replace("rest/", ""); webService.generateLegends.send(url, 96, 20, 20, ArcGISDynamicMapServiceLayer(liveLayers).id); ChangeWatcher.watch(ArcGISDynamicMapServiceLayer(liveLayers), "visibleLayers", updateLegend2); } } else if (liveLayers is ArcGISTiledMapServiceLayer) { requestCount++; url = ArcGISTiledMapServiceLayer(liveLayers).url.replace("rest/", ""); webService.generateLegends.send(url, 96, 20, 20, ArcGISTiledMapServiceLayer(liveLayers).id); ChangeWatcher.watch(ArcGISTiledMapServiceLayer(liveLayers), "visibleLayers", updateLegend2); } } } }
Kirti, You didn't miss this part did you?This version is COMPLETELY dependent on 2 things 1. ArcGIS Server 10 map services 2. Flex Viewer 2.0 and obviously Flex API 2.0It sound like you are trying to use the Sample Flex Viewer 1.x.
All, I am happy to announce the first community developed (and shared on the code gallery) widget for the Flexviewer 2.0. I have finalized my Dynamic Legend Widget for the 2.0 FlexViewer and shared it for all to use.This version is COMPLETELY dependent on 2 things ArcGIS Server 10 map servicesFlex Viewer 2.0 and obviously Flex API 2.0I have made it XML configurable this time so that you can specify that certain map services or certain layers in a map service are not to be displayed in the widget.It is called dynamic because the legend will only draw map services and layer that are visible in your map. It respects scale dependency of layers and if the layer is checked in the TOC or operational layer TOC. The legend automatically redraws when layers have been checked/unchecked and when zooming in or out and a layer scale dependency has been meet.I hope you enjoy it and I HOPE that you read and understand that it will not work with mapservices that are not served from a ArcGIS 10 Server.http://www.arcgis.com/home/item.html?id=f60406b9f52340d59eb557bf64136af6PS. don't forget to rate the code.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.