Using FeatureRenderer (unique values)


Objective: In this lesson, you will learn how to use the FeatureRenderer class to thematically display a layer using unique values.

 

We will highlight the Roads layer using red, blue and green colors based on class of road.

 

1. Add the RenderRoads() method:


Private Sub RenderRoads(ByVal RoadLayer As AspMap.Layer)
        Dim renderer As FeatureRenderer
        Dim feature As Feature

        renderer = RoadLayer.Renderer
        renderer.Field = "CLASS"

        feature = renderer.Add()
        feature.Value = "Interstate"
        feature.Symbol.LineColor = Color.Red
        feature.Symbol.Size = 2

        feature = renderer.Add()
        feature.Value = "US Highway"
        feature.Symbol.LineColor = Color.Blue
        feature.Symbol.Size = 2

        feature = renderer.Add()
        feature.Value = "State Highway"
        feature.Symbol.LineColor = Color.Green
        feature.Symbol.Size = 2
End Sub

2. Add a line of code to the AddMapLayers() method to call the RenderRoads() method:


Private Sub AddMapLayers()
        ...
                        
        ' add Roads layer
        layer = Map1.AddLayer(MapDir & "Roads.shp")

        layer.Symbol.LineColor = Color.Red
        layer.Symbol.Size = 2

        layer.LabelField = "NUMBER"
        layer.ShowLabels = True
        layer.LabelFont.Size = 12

        RenderRoads(layer)

        ...
                        
End Sub

3. Compile and run the application, your map should look similar to the image below:

 

 

 

© 2018 VDS Technologies
Converted from CHM to HTML with chm2web Standard 2.85 (unicode)