Creating custom layers



Defining custom layers

The ArcGIS libraries define many different types of layer classes to visually represent different sources of data, for example, FeatureLayer, TinLayer, CadLayer, and CoverageAnnotationLayer. These layers display geographic data stored in datasets, such as shapefiles, computer-aided design (CAD) files, image files, and feature classes, which are stored in a geodatabase.
Review the Carto layer object model diagram (OMD) to find out more about the existing layer classes. You can see that all layer objects are subtypes of the layer abstract class. All layer objects implement the ILayer and IGeoDataset interfaces. Therefore, any custom layer should implement at least these interfaces. The ILayer interface controls the drawing properties and actual drawing of the layer. The IGeoDataset interface defines the extent and spatial reference system for a layer so that it can be projected and georeferenced.
When you further review the Carto layer OMD, you can see that the class hierarchy for layers appears somewhat complex. This is because there are a wide range of different types of layers providing a wide range of functionality. The FeatureLayer class inherits from not only the layer abstract class but also from the DataLayer, DisplayLayer, TableLayer, and AnalysisLayer abstract classes.
The RasterLayer inherits from all these except the AnalysisLayer abstract class because AnalysisLayer contains interfaces that work with a vector-based data model that uses features, for example, IFeatureSelection. A raster layer, of course, does not use a vector data model. Many other classes that derive from these layer abstract classes can be found via the indicated links on the diagrams of other areas of the ArcGIS object model.

About creating custom layers

You might have a custom or unsupported data format that you want to show on a map without having to convert it to a data format supported by ArcGIS. Perhaps you want to extend the way an existing layer class draws. Writing your own layer object enables you to support the drawing of new data formats and to customize how existing data formats display.
A custom layer allows you to display an unsupported data source on a map. You can also change the way an existing layer class draws by using a custom layer.
If you have a custom data format you want to support in ArcGIS, there are a few options you can implement. For more information on the different solutions for integrating custom data sources (in particular, the table summarizing the benefits of each solution), see Plug-in data sources.
Custom layers are often used to accentuate a map so improved spatial analysis and edits can be made to feature datasets already loaded in the map. Like annotation layers, custom layers can be used to display different geometric objects, such as points and lines in a single layer. Custom layers can be used to display dynamic data as well.
If your objective is to map your data by providing a custom visual representation and there are no requirements to provide functionality, such as complex editing and data analysis, then a custom layer object is an excellent solution. Otherwise, consider the option of importing your data into a format supported by ArcGIS so you can take advantage of the many toolsets provided to work with your data.
All layers must implement ILayer. For ArcMap to save a custom layer, the IPersistVariant or IPersistStream interface must be implemented. To work with dynamic display, the custom layer must also implement the ILayerExtensions interface. You can choose what custom layer properties to persist in addition to the ILayer member properties, such as the minimum and maximum scales and the name of the layer and its visible state. For a layer to be included in the ArcMap table of contents (TOC) window, it must implement the ILegendInfo interface. The implementation of the interfaces ILayer, IGeoDataset, IPersistVariant, and ILegendInfo provides a basic level of integration with the ArcGIS framework. When a data source is not valid, the ILayer.get_IsValid property is used to indicate this. The layer in the TOC appears as disabled when the underlying data source is not valid. However, to provide functionality for the red exclamation mark to appear when the data source is disconnected or invalid, an additional interface IDataLayer is needed to be implemented.
On implementing the IDataLayer interface for a custom layer, if no implementation is provided for any of the interface methods or properties, the ArcMap application crashes when the custom layer is loaded, and upon opening the Data Frame properties and clicking the Coordinate System tab, then clicking the Transformation command. To avoid this, implement (at least) the required IDataLayer.DataSourceName property.
To help you create a typical custom layer, see the RSS weather layer sample, which inherits from the layer abstract class and also implements certain other typical layer interfaces. To keep the sample easy to follow and understand, only some of the numerous possible interfaces are implemented in the sample.


See Also:

Sample: RSS weather layer
Plug-in data sources




Development licensing Deployment licensing
ArcGIS for Desktop Basic ArcGIS for Desktop Basic
ArcGIS for Desktop Standard ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced ArcGIS for Desktop Advanced
Engine Developer Kit Engine