Adding an event listener to a layer

1108
4
Jump to solution
06-06-2012 05:40 PM
AlaeddineSaadaoui
Regular Contributor
Hi all,
I am new to ArcGis viewer for flex and I would like to know the difference between a layer and an operational layer. And in case I add a layer in the xml configuration file, how can I add an event listener to this layer?
Thank you in advance.
Alaeddine Saadaoui.
Rahall Transportation Institute.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
Alaeddine,

   In the MapManager.mxml there is a function called addLayerToMap there is where the layers are added to the map. You would look for this line:

case "feature":
and add a code block like this:

                        if (label == "highwayLayer"){                             featureLayer.addEventListener(LayerEvent.LOAD, doHighwaysSearch);                         }



Don't forget to click the top arrow (promote).
Follow the steps as shown in the below graphic:

View solution in original post

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus
Alaeddine,

   In the Viewer there are Basemap Layers and Operational Layers. Just like their names suggest a Basemap layer is a reference type layer such as Aerials or Street maps and operational layers that are turned on when needed and controlled by the LayerList or MapSwitcher widget. Basemaps in the Viewer are setup as toggle type visibility, (meaning you can only have one visible at a time). As far as adding event listeners depending on the level of customization you are attempting you will have to add listeners to the layers in the MapManger.mxml when the layer is added to the map.

Don't forget to click the Mark as answer check on this post and to click the top arrow (promote).
Follow the steps as shown in the below graphic:
0 Kudos
AlaeddineSaadaoui
Regular Contributor
Hi rscheitlin,
I have this layer that I have added the xml configuration file:
  <esri:FeatureLayer id="highwayLayer" url="http://t20dohb05l27506/ArcGIS/rest/services/WVAdMap/OutdoorAdvertisingMap/FeatureServer/1"
         load="{doHighwaysSearch()}"
         updateStart.mapState="{layer_updateStartHandler(event)}"
         updateEnd.mapState="{layer_updateEndHandler(event)}"/>
I am wondering where I can add the event listener load="{doHighwaysSearch()}" to the MapManager file.
Thank you again for your help.
Alaeddine Saadaoui.
Rahall Transportation Institute.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Alaeddine,

   In the MapManager.mxml there is a function called addLayerToMap there is where the layers are added to the map. You would look for this line:

case "feature":
and add a code block like this:

                        if (label == "highwayLayer"){                             featureLayer.addEventListener(LayerEvent.LOAD, doHighwaysSearch);                         }



Don't forget to click the top arrow (promote).
Follow the steps as shown in the below graphic:
0 Kudos
AlaeddineSaadaoui
Regular Contributor
Hi rscheitlin,
Thank you again 🙂 You are of great help!!
0 Kudos