Display feature layers from various data sources.

Use case
Feature layers, like all other layers, are visual representations of data and are used on a map or scene. In the case of feature layers, the underlying data is held in a feature table or feature service.
Feature services are useful for sharing vector GIS data with clients so that individual features can be queried, displayed, and edited. There are various online and offline methods to load feature services.
How to use the sample
Tap the button on the toolbar to add feature layers, from different sources, to the map. Pan and zoom the map to view the feature layers.
How it works
- Create a
Mapinstance with a topographic basemap style. - Load a feature layer with a feature table.
i. Create aServiceFeatureTableinstance from a URL.
ii. Create aFeatureLayerinstance with the feature table. - Load a feature layer with a portal item.
i. Create aFeatureLayerinstance with a portal item. - Load a feature layer with a geodatabase.
i. Instantiate and load aGeodatabaseusing the file name.
ii. Get the feature table from the geodatabase with the feature table’s name by using thegetGeodatabaseFeatureTable(tableName:)geodatabase method.
iii. Create aFeatureLayerinstance from the feature table. - Load a feature layer with a GeoPackage.
i. Instantiate and load a GeoPackage using its file name.
ii. Get the firstGeoPackageFeatureTablefrom thegeoPackageFeatureTablesarray.
iii. Create aFeatureLayerinstance from the feature table. - Load a feature layer with a shapefile.
i. Create aShapefileFeatureTableinstance using the shapefile name.
ii. Create aFeatureLayerinstance from the feature table. - Add the feature layer to the map’s operational layers.
- Create a
MapViewinstance with the map.
Relevant API
- FeatureLayer
- Geodatabase
- GeoPackage
- PortalItem
- ServiceFeatureTable
- ShapefileFeatureTable
About the data
This sample uses the Naperville damage assessment service, Trees of Portland portal item, Los Angeles Trailheads geodatabase, Aurora, Colorado GeoPackage, and Scottish Wildlife Trust Reserves Shapefile.
The Scottish Wildlife Trust shapefile data is provided from Scottish Wildlife Trust under CC-BY license. Data © Scottish Wildlife Trust (2022).
Tags
feature, geodatabase, geopackage, layers, service, shapefile, table