Display a shapefile with custom symbology.
Feature layers created from shapefiles do not possess any rendering information, and will be assigned with a default symbology. You can apply custom styling to ensure that the content is visible and usable in the context of a specific map. For example, you could use this to visually differentiate between features originating from two different shapefiles, by applying a blue color to one, and a red color to the other.
Tap the button to apply a new symbology renderer to the feature layer created from the shapefile.
- Create a
ShapefileFeatureTable, providing the path to a shapefile.
- Create a
FeatureLayerand associate it with the
- Create a
SimpleRendererto override the default symbology. The simple renderer takes a symbol and applies that to all features in a layer.
- Apply the renderer to the
FeatureLayerby setting the renderer.
This sample downloads the following items from ArcGIS Online automatically:
- AuroraCOshp.zip - Shapefiles that cover Aurora Colorado: Public art (points), Bike trails (lines), and Subdivisions (polygons).
This sample displays a shapefile containing subdivisions in Aurora, CO.
While shapefiles contain no rendering information, other data sources such as Service Feature Tables or Geodatabase Feature Tables can contain such information. As a result, the rendering properties of the other data sources can be pre-defined by the author.
package, shape file, shapefile, symbology, visualization
<?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.SymbolizeShapefile.SymbolizeShapefile"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="50" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Button Text="Change Renderer" Clicked="Button_Clicked" x:Name="MyRendererButton" IsEnabled="False" Grid.Row="0" /> <esriUI:MapView x:Name="MyMapView" Grid.Row="1" /> </Grid> </ContentPage>