FeatureLayer from ShapeFile, change Fill-Color

4417
2
Jump to solution
02-03-2015 08:37 AM
DannyNieruch
New Contributor II

Hi,

I am creating a FeatureLayer from a Shapefile on my map with the following code at application startup :

public async void LoadShapefileAsync(string path)

{

    try

    {

        ShapefileTable shapefile = await ShapefileTable.OpenAsync(path);

        _spatialReference = shapefile.SpatialReference;

        GisMap.SpatialReference = _spatialReference;

        FeatureLayer flayer = new FeatureLayer(shapefile)

        {

            ID = shapefile.Name,

            DisplayName = path,

        };

        GisMap.Layers.Add(flayer);

    }

    catch (Exception ex)

    {

        throw new ArgumentException("Feature-Layer aus Shapedatei konnte nicht erstellt werden: " + ex.Message);

    }

}

The result on my map is a grey filled polygon with a black solid outline.

How can I change the fill color and outline style for the polygon(s) on the FeatureLayer?

Thanks in advance! 🙂

0 Kudos
1 Solution

Accepted Solutions
dotMorten_esri
Esri Notable Contributor

The Shapefile layer will render with this default renderer. You can assign your own renderer to it, either Simple-, Unique- or ClassBreaksRenderer. Example

flayer.Renderer = new SimpleRenderer() { Symbol = new SimpleFillSymbol() { Color = Colors. Red } };

View solution in original post

2 Replies
dotMorten_esri
Esri Notable Contributor

The Shapefile layer will render with this default renderer. You can assign your own renderer to it, either Simple-, Unique- or ClassBreaksRenderer. Example

flayer.Renderer = new SimpleRenderer() { Symbol = new SimpleFillSymbol() { Color = Colors. Red } };

DannyNieruch
New Contributor II

Works like a charm!

Many thanks

0 Kudos