<livemaps> <mapservice label="Map1" visibleLayers="streets,buildings" menu="Navigation" type="dynamic" visible="false" alpha="1" icon="com/esri/solutions/flexviewer/assets/images/icons/i_highway.png">http://arcserver/ArcGis/rest/services/Map1/MapServer</mapservice> <mapservice label="Map2" visibleLayers="population" menu="Resources" type="dynamic" visible="false" alpha="1" icon="com/esri/solutions/flexviewer/assets/images/icons/i_highway.png">http://arcserver/ArcGis/rest/services/Map2/MapServer</mapservice> </livemaps>
<widget label="Live Maps" livemap="Map1" icon="com/esri/solutions/flexviewer/assets/images/icons/i_folder.png" menu="menuMap" config="com/esri/solutions/flexviewer/widgets/LiveMapsWidget.xml">com/esri/solutions/esa/widgets/LiveMapsWidget.swf</widget>
// in init() layerRepeater.dataProvider = getLayers(/* xml attribute livemap */); private function getLayers(livemap:String):Array { var layerArray:Array = new Array(); for(var i:Number = map.layerIds.length -1; i >= 0; i--) { var layer:Layer = map.getLayer(map.layerIds); if(!(layer is GraphicsLayer) && layer.name == livemap) //** added this condition to filter for only livemap layerArray.push(layer); } return layerArray; }
//in init layerRepeater.dataProvider = getLayers(configData.configWidgets[getId()].livemap); private function getLayers(livemap:String):Array { var layerArray:Array = new Array(); for(var i:Number = map.layerIds.length -1; i >= 0; i--) { var layer:Layer = map.getLayer(map.layerIds); if(!(layer is GraphicsLayer) && layer.name == livemap){ //** added this condition to filter for only livemap layerArray.push(layer); toc.includeLayers = livemap; } } return layerArray; }
//================================================= //widgets var configWidgets:Array = []; var wList:XMLList = configXML..widget; for (i = 0; i < wList.length(); i++) { var wLabel:String =wList.@label; var wIcon:String = wList.@icon; var wConfig:String = wList.@config; var wPreload:String = wList.@preload; var wUrl:String = wList; var wLiveMap:String = wList.@livemap; var widget:Object = { id: i, label: wLabel, icon: wIcon, config: wConfig, preload: wPreload, url: wUrl, livemap: wLiveMap } configWidgets.push(widget); } configData.configWidgets = configWidgets;
toc.includeLayers = getLayers(configData.configWidgets[getId()].livemap); layerRepeater.dataProvider = getLayers(configData.configWidgets[getId()].livemap);
/** * Get the widet ID. A widget ID is a internal generate identifier in number. * * @return value the Number id. */ public function getId():Number { return widgetId; }
private function init():void { //_servicesCollection = GetServiceTypes(); toc.map = map; toc.excludeLayers = getBasemaps(); var inclLayers:Array = getLayers(configData.configWidgets[getId()].livemap); for(var i:Number = 0; i < inclLayers.length; i++) { if(inclLayers is ArcGISDynamicMapServiceLayer) { var layer:ArcGISDynamicMapServiceLayer = inclLayers; for(var j:Number = 0; j < layer.layerInfos.length; j++) { layer.layerInfos.defaultVisibility = false; } } } toc.includeLayers = inclLayers; toc.excludeGraphicsLayers = true; layerRepeater.dataProvider = getLayers(configData.configWidgets[getId()].livemap); //wTemplate.addTitlebarButton(ICON_URL + "i_about.png", "AddService", showServices); wTemplate.addTitlebarButton(ICON_URL + "i_options.png", "Layer Options", showStateOptions); wTemplate.addTitlebarButton(ICON_URL + "i_folder.png", "Layer Visibility", showStateVisibility); }