Select to view content in your preferred language

Can I add a feature layer to the flex viewer?

2426
4
05-23-2011 07:46 AM
MikeCliffton
Emerging Contributor
I would like to add a feature layer to the flex viewer so that I can see the layer with a highlighted color.  It is not a widget, basically just adding a layer, a feature layer.   For example,

<esri:FeatureLayer id="fLayer"         definitionExpression="STATE_NAME='North Carolina'"   
mode="snapshot"   
outFields="[MALES,FEMALES,NAME,MED_AGE,CNTY_FIPS]"       symbol="{countySymbol}" 
url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3"/>

 

I put this code in the index.mxml, tried inserting the code inside the <viewer:ViewerContainer> or outside of it, but it never show up on the map.  Should I go to config.xml, but how to add a feature layer in config file? Million thanks!
Tags (2)
0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus
0 Kudos
MikeCliffton
Emerging Contributor
Thanks a lot! It seems I can not change layer's background or outline, the only way to change that is when I creating map server?

I would like to add a feature layer to the flex viewer so that I can see the layer with a highlighted color.  It is not a widget, basically just adding a layer, a feature layer.   For example,

<esri:FeatureLayer id="fLayer"         definitionExpression="STATE_NAME='North Carolina'"   
mode="snapshot"   
outFields="[MALES,FEMALES,NAME,MED_AGE,CNTY_FIPS]"       symbol="{countySymbol}" 
url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3"/>

 

I put this code in the index.mxml, tried inserting the code inside the <viewer:ViewerContainer> or outside of it, but it never show up on the map.  Should I go to config.xml, but how to add a feature layer in config file? Million thanks!
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Mike,

   OK, that make more sense. You need to add it in the MapManager.mxml than. Try adding it to the very bottom of the map_loadHandler function.

    var myFL:FeatureLayer = new FeatureLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3");
    myFL.definitionExpression = "STATE_NAME='North Carolina'";
    myFL.mode = "snapshot";
    myFL.outFields= [MALES,FEMALES,NAME,MED_AGE,CNTY_FIPS];
    myFL.symbol = countySymbol;
    map.addLayer(myFL);
0 Kudos
MikeCliffton
Emerging Contributor
I added the code, but nothing showed up. 

But it works when I added to the function addLayerToMap() at the bottom. Thanks a lot!


Thanks a lot! It seems I can not change layer's background or outline, the only way to change that is when I creating map server?
0 Kudos