Purpose
Returns information about a label in a map. LabeIInfo can return a label as text object and the text object returned can be curved or can be returned as rotated straight text. However, if the label is curved, it will be returned as rotated flat text. You can call this function from the MapBasic window in MapInfo Pro.
Syntax
Labelinfo( map_window_id, layer_number, attribute )
map_window_id is an integer window id, identifying a Map window.
layer_number is the number of a layer in the current Map window (for example, 1 for the top layer).
attribute is a code indicating the type of information to return; see table below.
Return Value
Return value depends on attribute.
Description
The Labelinfo() function returns information about a label in a Map window.
Before calling Labelinfo(), you must initialize MapBasic's internal label pointer by calling the LabelFindFirst() function, the LabelFindNext() function, or the LabelFindByID() function. See the example below.
The attribute parameter must be one of the codes from the following table; codes are defined in MAPBASIC.DEF.
attribute code | ID | Labelinfo() Return Value |
---|---|---|
LABEL_INFO_OBJECT | 1 | Text object is returned, which is an approximation of the label. This feature allows you to convert a label into a text object, which you can save in a permanent table.
Note: LABEL_INFO_OBJECT returns a text object, but if the label is curved, it will return a label with a Parallel orientation. MapBasic does not support curved labels as text objects.
|
LABEL_INFO_POSITION | 2 | Integer value between 0 and 8, indicating the label's position relative to its anchor location. The return value will match one of these codes:
For example, if the label is Below and to the Right of the anchor, its position is 8; if the label is Centered horizontally and vertically over its anchor, its position is zero. If the label is being auto positioned, its position is between -1 and 8. |
LABEL_INFO_ANCHORX | 3 | Float value, indicating the x-coordinate of the label's anchor location. |
LABEL_INFO_ANCHORY | 4 | Float value, indicating the y-coordinate of the label's anchor location. |
LABEL_INFO_OFFSET | 5 | Integer value between 0 and 200, indicating the distance (in points) the label is offset from its anchor location. |
LABEL_INFO_ROWID | 6 | Integer value, representing the ID number of the row that owns this label; returns zero if no label exists. |
LABEL_INFO_TABLE | 7 | String value, representing the name of the table that owns this label. Useful if you are using seamless tables and you need to know which member table owns the label. |
LABEL_INFO_EDIT | 8 | Logical value; TRUE if label has been edited. |
LABEL_INFO_EDIT_VISIBILITY | 9 | Logical value; TRUE if label visibility has been set to OFF. |
LABEL_INFO_EDIT_ANCHOR | 10 | Logical value; TRUE if label has been moved. |
LABEL_INFO_EDIT_OFFSET | 11 | Logical value; TRUE if label's offset has been modified. |
LABEL_INFO_EDIT_FONT | 12 | Logical value; TRUE if label's font has been modified. |
LABEL_INFO_EDIT_PEN | 13 | Logical value; TRUE if callout line's Pen style has been modified. |
LABEL_INFO_EDIT_TEXT | 14 | Logical value; TRUE if label's text has been modified. |
LABEL_INFO_EDIT_TEXTARROW | 15 | Logical value; TRUE if label's text arrow setting has been modified. |
LABEL_INFO_EDIT_ANGLE | 16 | Logical value; TRUE if label's rotation angle has been modified. |
LABEL_INFO_EDIT_POSITION | 17 | Logical value; TRUE if label's position (relative to anchor) has been modified. |
LABEL_INFO_EDIT_TEXTLINE | 18 | Logical value; TRUE if callout line has been moved. |
LABEL_INFO_SELECT | 19 | Logical value; TRUE if label is selected. |
LABEL_INFO_DRAWN | 20 | Logical value; TRUE if label is currently visible. |
LABEL_INFO_ORIENTATION | 21 | Returns Smallint value indicating the 'current' label's orientation. The current label is initialized by using one of the following Label functions: LabelFindFirst, LabelFindByID, or LabelFindNext. The Return value will be one of these:
|
Example
The following example shows how to loop through all of the labels for a row, using the Labelinfo() function to query each label.
Dim b_morelabels As Logical
Dim i_mapid, i_layernum As Integer
Dim obj_mytext As Object
' Here, you would assign a Map window's ID to i_mapid,
' and assign a layer number to i_layernum.
b_morelabels = LabelFindFirst(i_mapid, i_layernum, TRUE)
Do While b_morelabels
obj_mytext = LabelInfo(i_mapid, i_layernum, LABEL_INFO_OBJECT)
' At this point, you could save the obj_mytext object
' in a permanent table; or you could query it by
' calling ObjectInfo() or ObjectGeography().
b_morelabels = LabelFindNext(i_mapid, i_layernum)
Loop
See Also:
LabelFindByID() function, LabelFindFirst() function, LabelFindNext() function