Feature Layer是一种特殊的Graphics layer(继承自Graphics layer),除了像Graphics layer一样包含和显示Graphic features,还能提供:
Editing——编辑(editing控件包含在ArcGIS Toolkit库中,通过feature service来编辑feature layer)
Definition expressions——通过where子句,条件显示某些feature
Time definitions——通过time-aware layer的时间定义,条件显示某些feature
Selection——通过feature的子集,达到显示、编辑、分析的目的
feature layer的三种服务源:
Feature layer source |
描述 |
ArcGIS Server map service |
Dynamic (non-cached) ArcGIS Server map services能包含多个feature layers,如:http://./ArcGIS/rest/services/./MapServer/8 |
ArcGIS Server feature service |
如:http://. /ArcGIS/rest/services/./FeatureServer/0 当feature layer在ArcSDE geodatabase中时,支持编辑 |
MapIt |
Mapit包含REST-ful Web service,其table可能spatially-enabled。 Mapit layers不支持Editing和time-awareness。 如:http://./SDS/databases/Demo/dbo.USStates_Geographic |
Feature layers的关键成员|属性:(仅Feature layers支持,Graphics layers不支持)
Feature layers成员 |
描述 |
Url |
服务的url |
Where |
Query条件显示。where(“1=1”)显示全部 |
Mode |
定义获取features的方式: Snapshot:获取所有feature,用于较小的datasets或临时data On Demand:返回当前视窗范围内的feature Selection Only:初始不返回任何feature,仅仅在作出selection后才返回 |
OnDemandCacheSize |
当Mode=On Demand时,定义客户端缓存大小,用来缓存当前视窗外的feature |
FeatureSymbol |
定义一个单独symbol,用于rendering一个单独的Graphics时 |
SelectionColor |
定义feature layer中selected graphic features的颜色 |
TimeExtent |
实例化或范围显示feature layer的时间。 该属性为只读,定义于ArcGIS Server map或feature service中。 |
DisableClientCaching |
是否允许客户端缓存。默认为true,不能自动更新客户端显示。 |
Update |
更新客户端显示,用于layer或table contents发生改变时。 |
|
|
Feature layer应用
//添加Symbol命名空间,需要定义Symbol给FeatureSymbol属性
xmlns:esriSymbols="clr-namespace:ESRI.ArcGIS.Client.Symbols;assembly=ESRI.ArcGIS.Client
//定义Symbol
<Grid.Resources>
<esriSymbols:SimpleMarkerSymbol x:Name="MyMarkerSymbol" Color="Green" Style="Diamond" Size="14" />
</Grid.Resources>
//定义FeatureLayer
<esri:Map x:Name="MyMap" Extent="-130,10,-70,60" >
<esri:Map.Layers>
<esri:FeatureLayer ID=""
Url="http://./ArcGIS/rest/services/./MapServer/0"
Where="POP1990 > 75000"
FeatureSymbol="{StaticResource MyMarkerSymbol}" >
</esri:FeatureLayer>
</esri:Map.Layers>
</esri:Map>
效果如下图:各feature叠加在一起,不能有效的反应实际数量。故采用Clustering方式改进(设置ClusterFeatures属性实现):
//添加命名空间
xmlns:esriSymbols="clr-namespace:ESRI.ArcGIS.Client.Symbols;assembly=ESRI.ArcGIS.Client
xmlns:sys="clr-namespace:System;assembly=mscorlib”
//定义Symbol
<Grid.Resources>
<esriSymbols:SimpleMarkerSymbol x:Name="MyMarkerSymbol" Color="Green" Style="Diamond" Size="14" />
</Grid.Resources>
//定义FeatureLayer
<esri:Map x:Name="MyMap" Extent="-130,10,-70,60" >
<esri:Map.Layers>
<esri:FeatureLayer ID="MyFeatureLayer"
Url="http://./ArcGIS/rest/services/Specialty/./MapServer/0"
Where="POP1990 > 75000">
<esri:FeatureLayer.Clusterer>
<esri:FlareClusterer
FlareBackground="#99FF0000"
FlareForeground="White"
MaximumFlareCount="9" />
</esri:FeatureLayer.Clusterer>
<esri:FeatureLayer.OutFields>
<sys:String>CITY_NAME</sys:String>
<sys:String>POP1990</sys:String>
</esri:FeatureLayer.OutFields>
</esri:FeatureLayer>
</esri:Map.Layers>
</esri:Map>
效果如下: