Using FeatureRenderer (interval values)


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

 

We will use the States layer to depict four intervals of populations with different colors: states with 0 persons to 999999 drawn as light yellow, 1000000 persons to 4999999 drawn as yellow, 5000000 persons to 9999999 drawn as pink, 10000000 persons and more drawn as red.

 

1. Add the RenderStates() method:


Private Sub RenderStates(ByVal StateLayer As AspMap.Layer)
        Dim renderer As FeatureRenderer
        Dim feature As Feature

        renderer = StateLayer.Renderer

        feature = renderer.Add()
        feature.Expression = "POPULATION < 1000000"
        feature.Symbol.FillColor = Color.LightYellow

        feature = renderer.Add()
        feature.Expression = "POPULATION < 5000000"
        feature.Symbol.FillColor = Color.Yellow

        feature = renderer.Add()
        feature.Expression = "POPULATION < 10000000"
        feature.Symbol.FillColor = Color.Pink

        feature = renderer.Add()
        feature.Expression = "POPULATION >= 10000000"
        feature.Symbol.FillColor = Color.Red
End Sub

2. Add a line of code to the AddMapLayers() procedure to call the
RenderStates() procedure:


Private Sub AddMapLayers()
        Dim layer As AspMap.Layer
        Dim MapDir As String = MapPath("MAPS/USA/")

        ' add States layer
        layer = Map1.AddLayer(MapDir & "States.shp")

        layer.LabelField = "STATE_ABBR"
        layer.ShowLabels = True
        layer.LabelFont.Name = "Verdana"
        layer.LabelFont.Size = 12
        layer.LabelFont.Bold = True
        layer.LabelStyle = LabelStyle.PolygonCenter

        RenderStates(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)