Symbolizing Map Layers


Objective: In this lesson, you will symbolize the map layers with color and style of your choice and add text labels to the layers.

 

1. Using AspMap, it is easy to control color and style of each layer. Depending on geometry type or the layer, you'll need to set a Symbol's properties accordingly. The following table summarizes the main symbol properties you can work with for your layer geometry type.

 

 

PointStyle

LineColor

LineStyle

FillColor

FillStyle

InnerColor

Size

Point

point style

line color

line style

fill color

fill style

-

point size

Line

-

line color

line style

-

-

inner line color

line width

Polygon

-

outline color

outline style

fill color

fill style

inner outline color

outline width

 

By replacing the AddMapLayers() code as follows, you can display layers exactly the way you want (new code is in RED).

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

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

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

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

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

        layer.Symbol.PointStyle = PointStyle.CircleWithLargeCenter
        layer.Symbol.Size = 10
        layer.Symbol.FillColor = Color.FromArgb(255, 255, 0)
End Sub

2. Replace the AddMapLayers() code as follows to add text labels (new code is in RED).

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

        ' 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

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

        layer.Symbol.PointStyle = PointStyle.CircleWithLargeCenter
        layer.Symbol.Size = 10
        layer.Symbol.FillColor = Color.FromArgb(255, 255, 0)

        layer.LabelField = "CITY_NAME"
        layer.ShowLabels = True
        layer.LabelFont.Name = "Arial"
        layer.LabelFont.Bold = True
        layer.LabelFont.Size = 14
        layer.LabelFont.Outline = True
        layer.LabelFont.OutlineColor = Color.FromArgb(255, 255, 0)
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)