What is a feature layer?
Feature layers are a special type of graphics layer that allow you to display features in a layer hosted by an ArcGIS for Server map service, an ArcGIS for Server feature service, or in a table served by the Spatial Data Service. Like graphics layers, feature layers contain and display graphic features, which consist of geometry and attributes. In addition, feature layers can also provide solutions in the following areas:
- Editing—Feature layers are the key to editing features. The editing controls included in the ArcGIS Toolkit library are designed to work with feature layers. You can only perform editing on feature layers that reference a feature service. See the Editing Introduction topic to learn more about this requirement, how to create a feature service, and more.
- Definition expressions—There may be times when you want to work with features that satisfy certain attribute criteria and disregard the rest. In this type of situation, you can set a where clause on the feature layer to retrieve just the features you need. In addition, ArcGIS for Server feature layers have a default definition expression, which comes from the definition query set in the source map document. You cannot request features outside of any definition expressions in the map document.
- Time definitions—You can use a feature layer to isolate features that meet a certain temporal criteria. For example, you may want to show only houses that were constructed before 1930. If your house layer is time aware, you can set a time definition on the feature layer to show only houses whose construction dates were before 1930.
- Selection—Feature layers support selection, which represents a subset of features that the user has chosen to isolate for viewing, editing, or analytical purposes. Users can add or remove features from the selection based on spatial or attribute criteria. The feature layer makes it easy to draw the selection set with a different type of symbol to differentiate them from other features. A selection set can be used as input for statistical calculations, geoprocessing tools, and graphing, opening the possibility for interactive geographic information system (GIS) analysis and exploration. For example, selections could allow a user to draw a polygon around a set of buildings, then click a button to calculate the solar potential of those buildings. Selections also play an important role in some editing workflows where the feature currently undergoing edits is displayed as selected. To make your selection, either call the Select() method on individual graphic features or use the Editor's Select command. Tip:
You cannot request features outside of any definition expressions set in the map document or on the feature layer.
The following table highlights feature layer sources supported in this application programming interface (API):
Feature layer source | Description |
---|---|
ArcGIS for Server map service |
Dynamic (non-cached) ArcGIS for Server map services can contain feature layers. Each layer is represented by an explicit URL that references the map service name and layer ID assigned by the map service. The URL is usually retrieved using ArcGIS Services Directory. For example: http://serverapps.esri.com/ArcGIS/rest/services/California/MapServer/8 The California map service contains a layer with county features assigned the unique id 8. |
ArcGIS for Server feature service |
ArcGIS for Server feature services reference individual feature layers. Each layer is represented by an explicit URL that references the feature service name and layer ID assigned by the service. The URL is usually retrieved using ArcGIS Services Directory. For example: http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSFields/FeatureServer/0 This sample service represents oil and gas fields in the State of Kansas. The Petroleum feature service contains a feature layer with current Kansas field production features assigned the unique ID 0. ArcGIS for Server feature services support editing when the feature layer is hosted in an ArcSDE geodatabase. Use a feature service to take advantage of symbols and feature templates from the service's source map document. |
Spatial Data Service |
A spatial data service includes a REST-ful Web service termed the Spatial Data Service. It provides access to tables in databases hosted by a database instance, such as SQL Server. A table can be spatially enabled, which means it has a column that contains geometry. For example: http://serverapps.esri.com/SDS/databases/Demo/dbo.USStates_Geographic. The Demo database contains a spatially-enabled table dbo.USStates_Geographic. Editing and time awareness are not supported with Spatial Data Service layers at this time. |
Feature layers have several properties that enable functionality that is not available with graphics layers. The following table highlights some of the key members included with FeatureLayer:
FeatureLayer member | Description |
---|---|
Url property |
Address of a layer in an ArcGIS for Server map service or table hosted by a Spatial Data Service spatial data service (see the previous table for examples). Feature layers are automatically populated with features from the source. |
Where property |
Query that defines which features in the specified layer are displayed. If not specified, all features will be retrieved ("1=1"). |
Mode property |
Defines the technique for retrieving features from a service.
|
OnDemandCacheSize property |
Defines the number of features outside the current map extent to store in client-side cache when Mode = OnDemand. If a feature has been retrieved and resides in cache, it will not be requested again unless it's removed from the cache (number of features in the cache is surpassed). The cache is not maintained across sessions. |
FeatureSymbol property |
References a single symbol to use when rendering individual graphics in the layer. |
SelectionColor property |
Defines a color or visual brush to display selected graphic features in a feature layer. Note, each graphic feature maintains a Selected property. And the SelectedGraphics and SelectionCount properties (implemented on GraphicsLayer) return information on selected graphics. |
TimeExtent property |
References the time instance or range represented within the feature layer. This property is defined by an ArcGIS for Server map or feature service and is read-only. |
DisableClientCaching property |
By default, a feature layer uses browser caching to improve performance. If the data underlying your feature layer changes (that is, the table hosted by Spatial Data Service's spatial data service is being updated with new content) and you want to see the changes immediately, set this property to true. |
Update method |
This method re-queries the data underlying your feature layer. If the layer or table contents have changed on the server, you can call this method to see changes in the feature layer on the client. Note, you may need to disable client caching. |