View inWPFUWPFormsiOSAndroidView on GitHub
Read a shapefile and display its 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
- Call
ShapefileFeatureTable.OpenAsync("path_to_shapefile")
to create the ShapefileFeatureTable
.
- Get the
ShapefileInfo
from the feature table's Info
property.
- Get the image from
fileInfo.Thumbnail
and display it.
- 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.
credits, description, metadata, package, shape file, shapefile, summary, symbology, tags, visualization
Sample Code
ReadShapefileMetadata.xamlReadShapefileMetadata.xaml.cs
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage 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"
xmlns:mapping="clr-namespace:Esri.ArcGISRuntime.Mapping;assembly=Esri.ArcGISRuntime"
x:Class="ArcGISRuntime.Samples.ReadShapefileMetadata.ReadShapefileMetadata">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<esriUI:MapView x:Name="MyMapView"/>
<Frame x:Name="MetadataFrame"
IsVisible="False"
HorizontalOptions="Center" VerticalOptions="Start"
Margin="30"
BorderColor="DarkGray"
BackgroundColor="LightGray"
WidthRequest="300">
<ScrollView>
<StackLayout x:Name="InfoPanel"
Orientation="Vertical"
Margin="5">
<Label Margin="5"
FontAttributes="Bold" FontSize="Small" TextColor="DarkBlue"
Text="{Binding Path=Credits}"/>
<Label LineBreakMode="WordWrap"
FontSize="Micro" TextColor="Black"
Text="{Binding Summary}"/>
<Image x:Name="ShapefileThumbnailImage"
Margin="10"/>
<StackLayout Orientation="Horizontal">
<Label FontAttributes="Bold" FontSize="Micro" TextColor="Black"
Margin="0,3"
Text="Tags:"/>
<ListView HeightRequest="120" WidthRequest="160" RowHeight="25"
ItemsSource="{Binding Tags}"/>
</StackLayout>
</StackLayout>
</ScrollView>
</Frame>
<Button Grid.Row="1"
Text="Show Metadata"
Clicked="ShowMetadataClicked"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"/>
</Grid>
</ContentPage>