ArcGIS For Flex学习之Layers---Use Layer Definitions

这个例子告诉我们,如何在ArcGISDynamicMapServiceLayer运用图层定义来显示我们想要见到的某个特定区域,效果图及具体代码如下:

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
 3                xmlns:s="library://ns.adobe.com/flex/spark"
 4                xmlns:esri="http://www.esri.com/2008/ags"
 5                pageTitle="Example - using layerDefinitions to only show subset of content from specific layers">
 6     <fx:Style>
 7         @namespace s "library://ns.adobe.com/flex/spark";
 8         @namespace esri "http://www.esri.com/2008/ags";
 9         s|Panel
10         {
11             chromeColor: #403F33;
12             backgroundColor: #62696D;
13             backgroundAlpha: 0.8;
14             color: #FFFFFF;
15         }
16     </fx:Style>
17     
18     <s:controlBarContent>
19         <s:RichText width="100%">
20             This sample demonstrates how to apply definition expressions using the layerDefinitions property
21             of the ArcGISDynamicMapServiceLayer class.  Layer definitions are sent to the server where the
22             expression will be applied to the map service and the map service layers will be filtered
23             according to the expression criteria.  In this sample, a series of layerDefinitions are being
24             applied to only show data for one state.
25         </s:RichText>
26     </s:controlBarContent>
27     
28     <esri:Map id="map">
29         <esri:extent>
30             <esri:Extent xmin="-13456111" ymin="4335957" xmax="-11817302" ymax="5194498">
31                 <esri:SpatialReference wkid="102100"/>
32             </esri:Extent>
33         </esri:extent>
34         <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
35         <esri:ArcGISDynamicMapServiceLayer id="censusLayer" name="Census"
36                                            url="http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer">
37             <esri:layerDefinitions>
38                 <!--Utah is FIPS = '49'censusLayer图层共分四层,以下是给每一个图层分别定义-->
39                 <esri:LayerDefinition layerId="0" definition="STATE_FIPS = '49'"/>
40                 <esri:LayerDefinition layerId="1" definition="STATE_FIPS = '49'"/>
41                 <esri:LayerDefinition layerId="2" definition="STATE_FIPS = '49'"/>
42                 <esri:LayerDefinition layerId="3" definition="STATE_FIPS = '49'"/>
43             </esri:layerDefinitions>
44         </esri:ArcGISDynamicMapServiceLayer>
45     </esri:Map>
46     <s:Panel id="legendPanel"
47              height="200"
48              left="20" top="230"
49              title="Legend"
50              visible="{censusLayer.loaded}">  <!--Panel的可见性由censusLayer图层能否正确加载所控制-->
51         <s:layout>
52             <s:VerticalLayout paddingTop="10"/>
53         </s:layout>
54         <esri:Legend height="100%"
55                      layers="{[censusLayer]}"
56                      map="{map}"/>
57     </s:Panel>
58     
59 </s:Application>

 转载出处:https://developers.arcgis.com/flex/sample-code/use-layer-definitions.htm

posted @ 2014-10-22 14:47  Wicked_Fly  阅读(385)  评论(0编辑  收藏  举报