Features and graphics
In this topic
In the SDK a feature is an abstract geographic feature (AGSFeature) that provides a protocol that defines features that can reside in a local geodatabase (AGSGDBFeature) or in memory (AGSGraphic). Since the geometry and attribute properties are defined on this base class, geodatabase features and graphics, are indistinguishable when displayed on the map. So, what's the difference between geodatabase features and graphics?
The biggest difference is that geodatabase features are stored within a dataset on the device and graphics are stored in memory. So, although geodatabase features may be provided by an online service or a local geodatabase, these features are all physically stored on disk. Graphics, on the other hand, are always stored in memory on the client. They live in a graphics layer, and must be instantiated programmatically at run time.
Although the term "feature" can also refer to a graphic, it is most often used to refer to things like geodatabase features, meaning features stored in a database. Graphics are usually called "graphics", although "graphic feature" would be more precise.
- Have geometry
- Have attributes stored in a table
- Are stored on disk
- Are displayed through an AGSFeatureTableLayer
- Are symbolized according to the renderer defined for the feature service or the feature table layer that contains them
- Can be selected via the feature table layer
- Have geometry
- Have attributes stored in a collection of key/value pairs
- Are stored in memory
- Are displayed through a AGSGraphicsLayer
- Are symbolized individually or according to the renderer applied to the graphics layer that contains them
- Can be selected via the graphics layer
- Some display properties can be defined by the graphic, such as visibility and draw order
When to use geodatabase features
Because geodatabase features are stored in a database, they can be used to display a common set of data to all users of your app and between user sessions. On the other hand, graphics are created in the client app at runtime and therefore can only be used for a single user's session (unless you add logic to persist the graphics between sessions, such as serialization). Geodatabase features can define a geometry type and an attribute schema that is consistent for the data you want to represent.
With these differences in mind, perhaps the most common use of geodatabase features is to share data among several users. After creating a dataset to contain your features, and specifying the geometry type and the attributes to include, you can publish them as part of a feature service. Layers in a feature service can be displayed in a map, symbolized in various ways, and queried using attribute, spatial, or temporal criteria. The rich editing tools available in the Runtime SDK also make it possible to expose editing functionality in your application, including the ability to control the types of edits made and who gets to make them.
When to use graphics
Graphics are created programmatically at runtime and do not need to be physically stored. This makes them ideal for displaying things specific to the current user's session with the application, or anything that only needs to be displayed temporarily.
Graphics are commonly used to perform things such as:
- Show the results of spatial analysis, such as buffer polygons around input features
- Highlight a selection in the map
- Add geometry drawn interactively by the user
- Provide animation for data that changes quickly (such as GPS positions or moving objects)
- Show text on the map
At release 10.2.3 the AGSFeatureLayer uses graphics to display, interact and edit features provided by an online feature service. We recommend that you use the AGSFeatureTableLayer in any new development.