MapWinGIS:AxMap ApplyLegendColors
From MapWindow GIS
ApplyLegendColors
Applies the coloring scheme to a layer (the layer handle is specified in the coloring scheme object).
VB.NET Usage
Function ApplyLegendColors(Legend As Object) As Boolean
Parameters
|
Legend | The coloring scheme to apply. |
|
Return Value | Boolean value indicating the successful application when true, unsuccessful application when false. |
Sample Code
Private Sub LegendColors()
'open a shape file
Dim sf As New MapWinGIS.Shapefile()
sf.Open("C:\CITIES.SHP", Me)
Dim handle As Long, i As Long, fieldIndex As Long
Dim colorScheme As New MapWinGIS.ShapefileColorScheme()
Dim break As MapWinGIS.ShapefileColorBreak
'add the shapefile to the map
handle = Map1.AddLayer(sf, True)
'get the field index to color by
fieldIndex = 0
'find the max and min values for that field
Dim min As Double, max As Double
min = getMinValueForField(sf, fieldIndex)
max = getMaxValueForField(sf, fieldIndex)
With colorScheme
.LayerHandle = handle
'the field value to color by
colorScheme.FieldIndex = fieldIndex
'create a new break object
break = New MapWinGIS.ShapefileColorBreak()
break.Caption = "test"
break.StartColor = System.Convert.ToUInt32(RGB(255, 0, 0))
break.EndColor = System.Convert.ToUInt32(RGB(0, 0, 255))
break.StartValue = min
break.EndValue = max
'add the break
colorScheme.Add(break)
End With
'apply the coloring scheme for this layer
Map1.ApplyLegendColors(colorScheme)
End Sub
VB 6 Usage
Function ApplyLegendColors(Legend As Object) As Boolean
Parameters
|
Legend | The coloring scheme to apply. |
|
Return Value | Boolean value indicating the successful application when true, unsuccessful application when false. |
Sample Code
Private Sub LegendColors()
'open a shape file
Dim success As Boolean
Dim sf As New MapWinGIS.Shapefile
success = sf.Open("C:\CITIES.SHP", Me)
Dim handle As Long, i As Long, fieldIndex As Long
Dim colorScheme As New MapWinGIS.ShapefileColorScheme
Dim break As MapWinGIS.ShapefileColorBreak
'add the shapefile to the map
handle = Map1.AddLayer(sf, True)
'get the field index to color by
fieldIndex = 0
'find the max and min values for that field
Dim min As Double, max As Double
min = getMinValueForField(sf, fieldIndex)
max = getMaxValueForField(sf, fieldIndex)
With colorScheme
.LayerHandle = handle
'the field value to color by
colorScheme.fieldIndex = fieldIndex
'create a new break object
break = New MapWinGIS.ShapefileColorBreak
break.Caption = "test"
break.StartColor = RGB(255, 0, 0)
break.EndColor = RGB(0, 0, 255)
break.StartValue = min
break.EndValue = max
'add the break
colorScheme.Add (break)
End With
'apply the coloring scheme for this layer
Map1.ApplyLegendColors (colorScheme)
End Sub
















