MapWinGIS:AxMap AddLabelEx
From MapWindow GIS
AddLabelEx
Adds an extended label to the map, allowing for rotated labels.
See also tkHJustification
VB.NET Usage
Sub AddLabelEx(LayerHandle As Integer, Text As String, Color As System.UInt32, x As Double, y As Double,
hJustification As MapWinGIS.tkHJustification, Rotation As Double)
Parameters
|
LayerHandle | The handle of the layer where the label will be added to. |
| Text | The text to be used for the label. |
| Color | The color of the added label. This is a UInt32 representation of an RGB color. |
| x | The x coordinate in projected map units which determines where the label will be added on the map. |
| y | The y coordinate in projected map units which determines where the label will be added on the map |
| hJustification | Specifies whether to justify the label's text right, left, or center. |
| Rotation | The number of degrees to rotate the label. Positive angles rotate the text counter-clockwise, and negative angles rotate the text clockwise. |
Sample Code
Private Sub AddLabel()
Dim hndl As Integer, field As Integer, i As Integer
Dim sf As MapWinGIS.Shapefile
Dim text As String
Dim x As Double, y As Double
Dim col As UInt32
'Get handle for layer 0 which must contain a shapefile
hndl = Map1.get_LayerHandle(0)
'Get the shapefile contained in layer 0
sf = Map1.get_GetObject(hndl)
'Set shapefile field to use when labeling layer as field 0
field = 0
'Set the color for the labels to be black
col = System.Convert.ToUInt32(RGB(0, 0, 0))
'Label every shape in the shapefile
For i = 0 To sf.NumShapes - 1
'Set the text for this shape
text = sf.CellValue(field, i)
'Set the x and y coordinates for this label to be the min x and y coordinates of this shape
x = sf.Shape(i).Extents.xMin
y = sf.Shape(i).Extents.yMin
'Add the label to the layer by the shape centering the text and rotating it 45 degrees
Map1.AddLabelEx(hndl, text, col, x, y, MapWinGIS.tkHJustification.hjCenter, 45)
Next
End Sub
VB 6 Usage
Sub AddLabelEx(LayerHandle As Long, Text As String, Color As OLE_COLOR, x As Double, y As Double,
hJustification As tkHJustification, Rotation As Double)
Parameters
|
LayerHandle | The handle of the layer where the label will be added to. |
| Text | The text to be used for the label. |
| Color | The color of the added label. This is a UInt32 representation of an RGB color. |
| x | The x coordinate in projected map units which determines where the label will be added on the map. |
| y | The y coordinate in projected map units which determines where the label will be added on the map |
| hJustification | Specifies whether to justify the label's text right, left, or center. |
| Rotation | The number of degrees to rotate the label. Positive angles rotate the text counter-clockwise, and negative angles rotate the text clockwise. |
Sample Code
Private Sub AddLabel()
Dim hndl As Long
Dim field As Integer, i As Integer
Dim sf As MapWinGIS.Shapefile
Dim text As String
Dim x As Double, y As Double
Dim col As OLE_COLOR
'Get handle for layer 0 which must contain a shapefile
hndl = Map1.LayerHandle(0)
'Get the shapefile contained in layer 0
sf = Map1.GetObject(hndl)
'Set shapefile field to use when labeling layer as field 0
field = 0
'Set the color for the labels to be black
col = RGB(0, 0, 0)
'Label every shape in the shapefile
For i = 0 To sf.NumShapes - 1
'Set the text for this shape
text = sf.CellValue(field, i)
'Set the x and y coordinates for this label to be the min x and y coordinates of this shape
x = sf.Shape(i).extents.xMin
y = sf.Shape(i).extents.yMin
'Add the label to the layer by the shape centering the text and rotating it 45 degrees
Map1.AddLabelEx(hndl, text, col, x, y, tkHJustification.hjCenter, 45)
Next
End Sub
















