Label Class Reference

Represents a single label on the map. More...

Collaboration diagram for Label:
Collaboration graph

Properties

int Category [get, set]
 The index of visualization category the label belongs to. More...
 
bool IsDrawn [get]
 Gets a boolean value which indicates whether the label was drawn at the current extents of the map. More...
 
double Rotation [get, set]
 Gets or sets the angle of label rotation in degrees. Positive values set clockwise rotation, negative - counter-clockwise. More...
 
Extents ScreenExtents [get]
 Gets the extents the label occupies on the map (in pixels). More...
 
string Text [get, set]
 Gets or sets the text of the label. More...
 
bool Visible [get, set]
 Gets or sets a boolean value which indicates whether the label is visible. More...
 
double x [get, set]
 Gets or sets the horizontal position of the label in map coordinates. More...
 
double y [get, set]
 Gets or sets the vertical position of the label in map coordinates. More...
 

Detailed Description

Represents a single label on the map.

dot_inline_dotgraph_45.png

Graph description

Multipart shapes can have separate labels for every part. Each of such labels is represented by the instance of Label class. Labels added to the map can be accessed via Labels.get_Label() property. It's not recommended to store instances of this class retrieved from the map after the layer they belong to was removed.



This code demonstrate how to move the label for a shape with a given index.

Shapefile sf = some_shapefile;
int shapeIndex = 10; // the index of shape we want to move
// retrieving label object
Label label = sf.Labels.get_Label(shapeIndex, 0); // 0 - the first part
if (label != null)
{
// is it currently displayed on the screen?
Debug.Print("The label is drawn: " + label.IsDrawn.ToString());
label.x += 10.0; // let's move it to the right by 10 map units
label.y -= 5.0; // let's move it to the bottom by 5 map units
label.Visible = true; // ensure that it's visible
Debug.Print("The text of the label: " + label.Text);
map.Redraw(); // redraw is needed to see the changes of position
}
else {
Debug.Print(string.Format("The chart with index {0} doesn't exists", shapeIndex));
}
New API 4.8:
Added in version 4.8
Examples:
LabelSelection.cs.

Property Documentation

◆ Category

int Label.Category
getset

The index of visualization category the label belongs to.

The value -1 indicates that the label doesn't belong to any visualization category and default drawing options specified in the Labels class will be used for it's drawing.

Examples:
LabelSelection.cs.

◆ IsDrawn

bool Label.IsDrawn
get

Gets a boolean value which indicates whether the label was drawn at the current extents of the map.

◆ Rotation

double Label.Rotation
getset

Gets or sets the angle of label rotation in degrees. Positive values set clockwise rotation, negative - counter-clockwise.

◆ ScreenExtents

Extents Label.ScreenExtents
get

Gets the extents the label occupies on the map (in pixels).

In case the label wasn't drawn on the map, NULL reference will be returned.

◆ Text

string Label.Text
getset

Gets or sets the text of the label.

◆ Visible

bool Label.Visible
getset

Gets or sets a boolean value which indicates whether the label is visible.

Call AxMap.Redraw() to see the effect of this property.

◆ x

double Label.x
getset

Gets or sets the horizontal position of the label in map coordinates.

◆ y

double Label.y
getset

Gets or sets the vertical position of the label in map coordinates.