ThinkGeo.com    |     Documentation    |     Premium Support

Showing/Hiding labels

I’m using custom styles for most of my layers. I have a few questions:

How do I go about hiding labels for entire layers, and individual features? I noticed an IsActive property for the styles, but that only works with default styles from what I see.

How do I label shapefilefeaturelayers and personalgeodatabasefeaturelayers based on column data using a custom text style? Would I have to loop through each feature and add a label column, then set it equal to the column value of a different attribute? Or is there a quicker way to do this?

Hi Dan,

You can also call IsActive for customStyles like this: shapeFileLayer.ZoomLevelSet.ZoomLevel01.CustomStyles[0].IsActive

And you can put your label and shape into different layers, when you want to hide the label, you can directly hide the label layer.

        ShapeFileFeatureLayer shapeLayer = new ShapeFileFeatureLayer(@"..\..\AppData\states.shp");
        shapeFileLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = WorldStreetsAreaStyles.Military();
        shapeFileLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

        ShapeFileFeatureLayer labelLayer = new ShapeFileFeatureLayer(@"..\..\AppData\states.shp");
        labelLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.Capital1("Name");
        labelLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

If you want to label feature based on column data, you can try our ValueStyle.

Here is a sample about it: https://github.com/ThinkGeo/DefaultValueStyleSample-ForWpf

Regards,

Ethan