How to get Top most visible layer in current extent?

360
1
08-02-2012 09:56 PM
AtifBashir
New Contributor
Hi,

I want get top most visible layer in current map extent.Can any body have solution for this problem please reply .

Thanks
Tags (2)
0 Kudos
1 Reply
IvanBespalov
Occasional Contributor III
Hi,
1)
Map has set of Layers to be viewed.
layers property  
layers:Object 
This property lets you use either an Array, an ArrayCollection, or a single Layer...

Layer index in this collection is the layer location. Layer with greater index is on top of layer with smaller index.
Example:
Layer index=0, name='Topo'
Layer index=1, name='Imagery'
Layer index=2, name='Street' (the only visible to client)
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
      xmlns:s="library://ns.adobe.com/flex/spark" 
      xmlns:mx="library://ns.adobe.com/flex/mx"
      xmlns:esri="http://www.esri.com/2008/ags">
 <esri:Map>  
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer"
           name="Topo"/>
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"
           name="Imagery"/>
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
           name="Street"/>
 </esri:Map>
</s:Application>

2)
Note that all layers extend UIComponent and thus include basic mouse events, such as: click, mouseOut, mouseOver, and mouseDown, as well as other events like show and hide, and general properties, such as   alpha and   visible.

Example:
Layer index=0, name='Topo', visible=true
Layer index=1, name='Imagery', visible=true (the only visible to client)
Layer index=2, name='Street', visible=false
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
      xmlns:s="library://ns.adobe.com/flex/spark" 
      xmlns:mx="library://ns.adobe.com/flex/mx"
      xmlns:esri="http://www.esri.com/2008/ags">
 <esri:Map>  
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer"
           name="Topo"/>
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"
           name="Imagery"/>
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
           name="Street"
           visible="false"/>
 </esri:Map>
</s:Application>

3)
Also layer has such property as isInScaleRange.
...Returns true if the current scale of the map is between the maximum and minimum scale of the layer...


[/HR]

U must collect layer information (alpha, visible, index in map layer collection ...), and compare it.
The same logic when U need to find top most visible sublayer in a layer. Sample with sources.
0 Kudos