Display feature layers from various data sources.
Use case
Feature layers, like all 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
- Set the basemap with a
BasemapStyle
. - Load a feature layer with a URL.
i. Create aServiceFeatureTable
from a URL.
ii. Create aFeatureLayer
with the feature table. - Load a feature layer with a portal item.
i. Create aPortalItem
with the portal and item ID.
ii. Create aFeatureLayer
with the portal item and layer ID. - Load a feature layer with a geodatabase.
i. Instantiate and load aGeodatabase
using the file name.
ii. Get the feature table from the geodatabase with the feature table's name.
iii. Create aFeatureLayer
from the feature table. - Load a feature layer with a geopackage.
i. Instantiate and load a geopackage using its file name.
ii. Get the firstGeoPackageFeatureTable
from thegeoPackageFeatureTables
array.
iii. Create anFeatureLayer
from the feature table. - Load a feature layer with a shapefile.
i. Create aShapefileFeatureTable
using the shapefile name.
ii. Create aFeatureLayer
from the feature table and load it. - Add the feature layer to the map's
OperationalLayers
.
Relevant API
- FeatureLayer
- Geodatabase
- GeoPackageFeatureTable
- 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 licence. Data Copyright Scottish Wildlife Trust (2022).
Tags
feature, geodatabase, geopackage, layers, service, shapefile, table
Sample Code
<ContentPage x:Class="ArcGISRuntimeXamarin.Samples.DisplayFeatureLayers.DisplayFeatureLayers"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<esriUI:MapView x:Name="MyMapView" Grid.Row="0" />
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="400" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackLayout Grid.Column="1"
HorizontalOptions="CenterAndExpand"
Orientation="Horizontal">
<Label Text="Select feature layer source" VerticalOptions="Center" />
<Picker x:Name="FeatureLayerPicker"
FontSize="Small"
SelectedIndexChanged="FeatureLayerPicker_SelectionChanged"
VerticalOptions="Center" />
</StackLayout>
</Grid>
</Grid>
</ContentPage>