View in MAUI WPF WinUI View on GitHub

Read a shapefile and display its metadata.

Image of read shapefile metadata

Use case

You can display information about the shapefile your user is viewing, like tags, credits, and summary.

How to use the sample

The shapefile’s metadata will be displayed when you open the sample.

How it works

  1. Call ShapefileFeatureTable.OpenAsync("path_to_shapefile") to create the ShapefileFeatureTable.
  2. Get the ShapefileInfo from the feature table’s Info property.
  3. Get the image from fileInfo.Thumbnail and display it.
  4. Display the Summary, Credits, and Tags properties from the shapefile info.

Relevant API

  • ShapefileFeatureTable
  • ShapefileFeatureTable.Info
  • ShapefileFeatureTable.OpenAsync
  • ShapefileInfo
  • ShapefileInfo.Credits
  • ShapefileInfo.Summary
  • ShapefileInfo.Tags
  • ShapefileInfo.Thumbnail

Offline data

Aurora Colorado Shapefiles is available as an item hosted on ArcGIS Online].

About the data

This sample uses a shapefile showing bike trails in Aurora, CO. The Aurora Colorado Shapefiles are available as an item on ArcGIS Online.

Tags

credits, description, metadata, package, shape file, shapefile, summary, symbology, tags, visualization

Sample Code

ReadShapefileMetadata.xaml ReadShapefileMetadata.xaml ReadShapefileMetadata.xaml.cs
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="ArcGIS.Samples.ReadShapefileMetadata.ReadShapefileMetadata"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:converters="clr-namespace:ArcGIS.Converters"
xmlns:controls="clr-namespace:Microsoft.Maui.Controls;assembly=Microsoft.Maui.Controls"
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Maui;assembly=Esri.ArcGISRuntime.Maui">
<ContentPage.Resources>
<converters:RuntimeImageToImageSourceConverter x:Key="RuntimeImageToImageSource" />
</ContentPage.Resources>
<Grid Style="{DynamicResource EsriSampleContainer}">
<esriUI:MapView x:Name="MyMapView" Style="{DynamicResource EsriSampleGeoView}" />
<Border x:Name="ControlPanel" Style="{DynamicResource EsriSampleControlPanel}">
<ScrollView x:DataType="controls:Border"
MaximumHeightRequest="{OnIdiom Desktop=500, Default={Binding Height, Source=ControlPanel}}"
Orientation="{OnPlatform iOS=Both, Default=Vertical}">
<StackLayout x:Name="InfoList"
x:DataType="esri:ShapefileInfo"
Spacing="5">
<Label FontAttributes="Bold"
FontSize="Large"
HorizontalOptions="Start"
LineBreakMode="WordWrap"
MaximumWidthRequest="400"
Text="{Binding Path=Credits}" />
<Label HorizontalOptions="Start"
LineBreakMode="WordWrap"
MaximumWidthRequest="400"
Text="{Binding Summary}" />
<Image HorizontalOptions="Start"
Source="{Binding Thumbnail, Converter={StaticResource RuntimeImageToImageSource}}" />
<Label FontAttributes="Bold"
FontSize="Medium"
HorizontalOptions="Start"
Text="Tags:" />
<ListView HorizontalOptions="Start"
ItemsSource="{Binding Tags}"
MaximumWidthRequest="400"
RowHeight="25"
VerticalScrollBarVisibility="Never" />
</StackLayout>
</ScrollView>
</Border>
</Grid>
</ContentPage>