Select to view content in your preferred language

Excluding layerIds for different widgets.

631
0
04-20-2010 09:45 AM
VenkatM
Emerging Contributor
Hi Folks,

First, I am apologies on my bad 'English'.

I am new to ArcGIS technology.
I was trying to divide the dynamic mapservices of config.xml,
and loading them from individual configruation xml file associated with
each newly created widgets instead of from config.xml,i.e mapservices are loaded
from individual widget's configuation file not from config.xml. Like 'LiveMapService' widget,
this widget loads the mapservices from config.xml. But the newly created widgets will load
mapservices from there individual configuration file not like 'LiveMapService' widget.

I have created couple of such widgets with couple various services in each widgets, say,

widget 'A' consists of services a1, a2, a3, etc. which are of type 'ArcGISDynamicMapServiceLayer', and
widget 'B' consists of services b1, b2, b3, etc. which are of type 'ArcGISDynamicMapServiceLayer'.
widget 'C' consists of services c1, c2, c3, etc. which are of type 'ArcGISDynamicMapServiceLayer' and so on.

these widgets A, B, C etc loads the mapservices from there individual configuration file like A.xml, B.xml, C.xml etc and
not from the config.xml, but the widget declration will be in config.xml only.

And these widgets are invoked from the shortcut menu from one of the main menu's.

I have written a seperate single 'WidgetConfigManager.as', which parses the A.xml, B.xml, etc. similar
to 'ConfigManager.as' for config.xml and store them in temperorly created  'ConfigData' array
variable in 'ConfigData.as' , and single 'WidgetMapManager.mxml' file that calls the
rest based webservices with the url on 'ArcGISDynamicMapServiceLayer' and adds these layer on top
to the 'map' object as layer, like the similar to the one we have in the flexviewer, i.e 'MapManager'.

I may be wrong that..
I guess here we have only single and only single 'map' object. On which I am loading the different
dynamic mapservices (a1,a2,a3, b1,b2,b3,c1,c2,c3,etc) layers through various newly created widgets.

==========
Problem:..
==========

When ever I click the widget from the shortcut menu to invoke, say the first widget clicked,
say widget 'A' is clicked, shows up the services.. a1,a2,a3.. correctely. But when I clicked another
widget say widget 'B' to invoke, this widget 'B' shows up the services.. b1, b2, b3.. correctely,
and problem is widget 'A' is also showing the services of widget 'B' as soon as I invoked the
widget 'B' from the menu. i.e widget 'A'  shows up the services a1,a2,a3,b1,b2,b3. for which I don't
want, even if I invoke the couple of widgets at time, they should show their individual services
in there widgets, not the other widgets services..
Can somebody help me on this.. would be appreciated.

I may be wrong.. but I figured out the issue is with the 'layerIds'. when ever we invoke the
any widget having services a1,a2,a3.. they all added on to the same single 'map' object, ie.
services from the widget 'A' are added to 'map' object while invoking, causing an array of 'layerIds'
for a1,a2,a3 in 'map' object. Again, invoking another widget 'B'.. leads adding additional 'layerIds'
for servicess b1,b2,b3.

Since 'layerIds' is an read only object, we can not control or manipulate that object, to seperate
the service labels in 'layerIds'. the only way is to 'exclude' the not required services in a
particular widget. thats what code in 'LiveMapServices' widget does..

i.e the following code,'getBasemaps()', should do more smart work on this,I guess... may be I am wrong..


private function init():void
{
if (configXML)
{
  //labels
  visibilityLabel = configXML.labels.visibilitylabel || "Layer Visibility";
  transparencyLabel = configXML.labels.transparencylabel || "Layer Transparency";

  //set the expanded state of the toc
  expanded = (configXML.tocSettings.expanded == "true")?true:false;
}
toc.map = map;
toc.excludeLayers = getBasemaps();
toc.excludeGraphicsLayers = true;
layerRepeater.dataProvider = getLayers();

wTemplate.addTitlebarButton(ICON_URL + "i_options.png", transparencyLabel, showStateOptions);
wTemplate.addTitlebarButton(ICON_URL + "i_folder.png", visibilityLabel, showStateVisibility);
}

private function getBasemaps():ArrayCollection
{
var baseMaps:ArrayCollection = new ArrayCollection();
for (var i:Number = 0; i < configData.configBasemaps.length; i++)
        {
         baseMaps.addItem(configData.configBasemaps.label);
        }
return baseMaps;
}  

I am struck here since from long time.. Please somebody help me on this..
I am providing my one of the sample widget's code below.. which I wrote..
Many thanks in advance.. provide me the 'getBasemaps()' method code, which does the smart thing to
exclude the not required services for corresponding widgets during the multiple widgets
invocation at runtime...

[Bindable]
private var mapLayerIds:Array;  //VM added code.
private var wdgMpMgr:WidgetMapManager;//VM added code
private var wdgCfgMgr:WidgetConfigManager;//VM added code
private var cnfgDat:Array;//VM added code
[Bindable]//VM added code
private var widgetLabel:String;//VM added code
     

private function init():void
{
if (configXML)
{
  //labels.....
    
  wdgCfgMgr = new WidgetConfigManager();
  cnfgDat = wdgCfgMgr.configLoad(configXML);
  configData.configTempMap=null;
  configData.configTempMap=cnfgDat;
  cboLayerGraphical.dataProvider=cnfgDat;
  CboLayers.dataProvider=cnfgDat;
  //getLayerInfo(configData);
  wdgMpMgr = new WidgetMapManager();
  wdgMpMgr.getLayerInfo(configData, map);

  //set the expanded state of the toc
  expanded = (configXML.tocSettings.expanded == "true")?true:false;
}
toc.map = map;
mapLayerIds=map.layerIds;
toc.excludeLayers = getBasemaps();
toc.excludeGraphicsLayers = true;
layerRepeater.dataProvider = getLayers();

wTemplate.addTitlebarButton(ICON_URL + "i_info.png", titleLabel, showStateQueryAttributes);
wTemplate.addTitlebarButton(ICON_URL + "i_searchgraphical.png", graphicalsearchLabel, showStateGraphicalSearch);
wTemplate.addTitlebarButton(ICON_URL + "i_options.png", transparencyLabel, showStateOptions);
wTemplate.addTitlebarButton(ICON_URL + "", visibilityLabel, showStateVisibility);
}

private function getBasemaps():ArrayCollection
{
var lyrObj:Object = null;
var otherMaps:ArrayCollection = new ArrayCollection();
        for (var i:Number = 0; i < map.layerIds.length; i++)
        {
         lyrObj = commonSearch(map.layerIds);
         otherMaps.addItem(lyrObj);
        }
return otherMaps;
}
  
private function commonSearch(lyr:Object):Object
{
var tempLyr:Object = null;
for(var j:Number = 0; j < cnfgDat.length; j++)
        {
         if(lyr == cnfgDat.label)
         {
          return null;
         }
         tempLyr = lyr;
}
return tempLyr;

  
private function getLayers():Array
{
var cnfgMpCnt:Number = map.layerIds.length;
var layerArray:Array = [];
   
for(var i:Number=0; i < map.layerIds.length; i++)
{
  
  for(var j:Number=0; j < cnfgDat.length; j++)
  {
   if(map.layerIds == cnfgDat.label)
   {
    var layer:Layer = map.getLayer(map.layerIds);
    if(!(layer is GraphicsLayer))
    {
     layerArray.push(layer);
    }
   }
  }
}
return layerArray;
}

Thanks & Regards.
-VM
Tags (2)
0 Kudos
0 Replies