LayerInfo() function - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Returns information about a layer in a Map window. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

LayerInfo( window_id, layer_number, attribute )

window_id is the integer window identifier of a Map window.

layer_number is the number of a layer in the current Map window (for example, 1 for the top layer); to determine the number of layers in a Map window, call the MapperInfo() function.

attribute is a code indicating the type of information to return; see table below.

Return Value

Return value depends on attribute parameter.

Restrictions

Many of the settings that you can query using LayerInfo() function only apply to conventional map layers (as opposed to Cosmetic map layers, thematic map layers, and map layers representing raster image tables). See example below.

Description

The LayerInfo() function returns information about one layer in an existing Map window. The layer_number must be a valid layer (1 is the topmost table layer, and so on). The attribute parameter must be one of the codes from the following table; codes are defined in MAPBASIC.DEF. From here you can also query the Hotlink options using the LAYER_HOTLINK_* attributes.

Attribute Code ID LayerInfo() Return Value
LAYER_INFO_NAME 1 String indicating the name of the table associated with this map layer. If the specified layer is the map's Cosmetic layer, the string will be a table name such as "Cosmetic1"; this table name can be used with other statements (for example, Select statement).
LAYER_INFO_EDITABLE 2 Logical value, TRUE if the layer is editable.
LAYER_INFO_SELECTABLE 3 Logical value, TRUE if the layer is selectable.
LAYER_INFO_ZOOM_LAYERED 4 Logical, TRUE if zoom-layering is enabled.
LAYER_INFO_ZOOM_MIN 5 Float value, indicating the minimum zoom value (in MapBasic's current distance units) at which the layer displays. (To set MapBasic's distance units, use Set Distance Units statement.)
LAYER_INFO_ZOOM_MAX 6 Float value, indicating the maximum zoom value at which the layer displays.
LAYER_INFO_COSMETIC 7 Logical, TRUE if this is the Cosmetic layer.
LAYER_INFO_PATH 8 String value, representing the full directory path of the table associated with the map layer.
LAYER_INFO_DISPLAY 9 SmallInt, indicating how and whether this layer is displayed; return value will be one of these values:
  • LAYER_INFO_DISPLAY_OFF (0)

    the layer is not displayed
  • LAYER_INFO_DISPLAY_GRAPHIC (1)

    objects in this layer appear in their "default" style-the style saved in the table
  • LAYER_INFO_DISPLAY_GLOBAL (2)

    objects in this layer are displayed with a "style override" specified in Layer Control
  • LAYER_INFO_DISPLAY_VALUE (3)

    objects in this layer appear as thematic shading
LAYER_INFO_OVR_LINE 10 Pen style used for displaying linear objects. If the base set of layer properties includes a stacked style, the pen returned is the first pass of the stacked style.
LAYER_INFO_OVR_PEN 11 Pen style used for displaying the borders of filled objects. If the base set of layer properties includes a stacked style, the pen returned is the first pass of the stacked style.
LAYER_INFO_OVR_BRUSH 12 Brush style used for displaying filled objects. If the base set of layer properties includes a stacked style, the brush returned is the first pass of the stacked style.
LAYER_INFO_OVR_SYMBOL 13 Symbol style used for displaying point objects. If the base set of layer properties includes a stacked style, the symbol returned is the first pass of the stacked style.
LAYER_INFO_OVR_FONT 14 Font style used for displaying text objects. If the base set of layer properties includes a stacked style, the font returned is the first pass of the stacked style.
LAYER_INFO_LBL_EXPR 15 String value, the expression used in labels.
LAYER_INFO_LBL_LT 16 SmallInt value, indicating what type of line, if any, connects a label to its original location after you move the label. The return value will match one of these values:
  • LAYER_INFO_LBL_LT_NONE (0)

    no line
  • LAYER_INFO_LBL_LT_SIMPLE (1)

    simple line
  • LAYER_INFO_LBL_LT_ARROW (2)

    line with an arrowhead
LAYER_INFO_LBL_CURFONT 17 For applications compiled with MapBasic 3.x, this query returns the following values:

Logical value: TRUE if layer is set to use the current font, or FALSE if layer is set to use the custom font (see LAYER_INFO_LBL_FONT).

For applications compiled with MapBasic 4.0 or later, this query always returns FALSE.

LAYER_INFO_LBL_FONT 18 Font style used in labels.
LAYER_INFO_LBL_PARALLEL 19 Logical value, TRUE if layer is set for parallel labels.
LAYER_INFO_LBL_POS 20 SmallInt value, indicating label position. Return value will match one of these values (T=Top, B=Bottom, C=Center, R=Right, L=Left):
  • LAYER_INFO_LBL_POS_TL (1)
  • LAYER_INFO_LBL_POS_TC (2)
  • LAYER_INFO_LBL_POS_TR (3)
  • LAYER_INFO_LBL_POS_CL (4)
  • LAYER_INFO_LBL_POS_CC (0)
  • LAYER_INFO_LBL_POS_CR (5)
  • LAYER_INFO_LBL_POS_BL (6)
  • LAYER_INFO_LBL_POS_BC (7)
  • LAYER_INFO_LBL_POS_BR (8)
LAYER_INFO_ARROWS 21 Logical value, TRUE if layer displays direction arrows on linear objects.
LAYER_INFO_NODES 22 Logical value, TRUE if layer displays object nodes.
LAYER_INFO_CENTROIDS 23 Logical value, TRUE if layer displays object centroids.
LAYER_INFO_TYPE 24 SmallInt value, indicating this layer's file type:
  • LAYER_INFO_TYPE_NORMAL (0)

    for a normal layer
  • LAYER_INFO_TYPE_COSMETIC (1)

    for the Cosmetic layer;
  • LAYER_INFO_TYPE_IMAGE (2)

    for a raster image layer
  • LAYER_INFO_TYPE_THEMATIC (3)

    for a thematic layer
  • LAYER_INFO_TYPE_GRID (4)

    for a grid image layer
  • LAYER_INFO_TYPE_WMS (5)

    for a layer from a Web Service Map
  • LAYER_INFO_TYPE_TILESERVER (6)

    for a layer from a Tile Server
  • LAYER_INFO_TYPE_GRIDLINE (7)

    for gridline layer
LAYER_INFO_LBL_VISIBILITY 25 SmallInt value, indicating whether labels are visible; see the Visibility clause of the Set Map statement. Return value will be one of these values:
  • LAYER_INFO_LBL_VIS_ON (3)

    labels always visible
  • LAYER_INFO_LBL_VIS_OFF (1)

    labels never visible
  • LAYER_INFO_LBL_VIS_ZOOM (2)

    labels visible when in zoom range
LAYER_INFO_LBL_ZOOM_MIN 26 Float value, indicating the minimum zoom distance for this layer's labels.
LAYER_INFO_LBL_ZOOM_MAX 27 Float value, indicating the maximum zoom distance for this layer's labels.
LAYER_INFO_LBL_AUTODISPLAY 28 Logical value, TRUE if this layer is set to display labels automatically. See the Auto clause of the Set Map statement.
LAYER_INFO_LBL_OVERLAP 29 Logical value, TRUE if overlapping labels are allowed.
LAYER_INFO_LBL_DUPLICATES 30 Logical value, TRUE if duplicate labels are allowed.
LAYER_INFO_LBL_OFFSET 31 SmallInt value from 0 to 50, indicating how far the labels are offset from object centroids. The offset value represents a distance, in points.
LAYER_INFO_LBL_MAX 32 Integer value, indicating the maximum number of labels allowed for this layer. If no maximum has been set, return value is 2,147,483,647.
LAYER_INFO_LBL_PARTIALSEGS 33 Logical value, TRUE if the Label Partial Objects check box is checked for this layer.
LAYER_INFO_HOTLINK_EXPR 34 Returns the layer's Hotlink filename expression. Can return empty string ("")
LAYER_INFO_HOTLINK_MODE 35 Returns the layer's Hotlink mode, one of the following predefined values:
  • HOTLINK_MODE_LABEL (0) default
  • HOTLINK_MODE_OBJ (1)
  • HOTLINK_MODE_BOTH (2)
LAYER_INFO_HOTLINK_RELATIVE 36 Returns TRUE if the relative path option is on, FALSE otherwise. FALSE is default.
LAYER_INFO_HOTLINK_COUNT 37 Allows you to query the number of hotlink definitions in a layer.
LAYER_INFO_LBL_ORIENTATION* 38 Smallint value, indicating the setting for the layer's auto label orientation. Return value will be one of these values:
  • LAYER_INFO_LABEL_ORIENT_HORIZONTAL

    labels have angle equal to 0
  • LAYER_INFO_LABEL_ORIENT_PARALLEL

    labels have non-zero angle
  • LAYER_INFO_LABEL_ORIENT_CURVED labels are curved

If LAYER_INFO_LABEL_ORIENT_PARALLEL is returned then LBL_OVR_INFO_PARALLEL returns TRUE.

LAYER_INFO_LAYER_ALPHA 39 SmallInt value, representing the alpha factor for the specified layer.
  • 0=fully transparent.
  • 255=fully opaque.

To set the translucency or alpha for a layer, use the Set Map statement.

LAYER_INFO_LAYER_TRANSLUCENCY 40 SmallInt value, representing the translucency percentage for the specified layer.
  • 100=fully transparent.
  • 0=fully opaque.

To set the translucency or alpha for a layer, use the Set Map statement.

LAYER_INFO_LABEL_ALPHA 41 SmallInt value, representing the alpha factor for the labels of the specified layer.
  • 0=fully transparent.
  • 255=fully opaque.

To set the translucency or alpha for a layer, use the Set Map LABELCLAUSE statement.

LAYER_INFO_LAYERLIST_ID 42 Returns the overall numeric ID of the layer in the current layer list. For example, a layer may be the first group layer from the top down in the map layer list (its group layer ID would be 1), but it may be the 4th layer from the top. Thus its layer list ID would be 4. This ID can be used with the LayerListInfo() function.
LAYER_INFO_PARENT_GROUP_ID 43 Returns the group layer ID of the immediate group containing this layer, returns 0 if layer is in the top level list.
LAYER_INFO_OVR_STYLE_COUNT 44 Smallint value, indicates the number of display style overrides.
LAYER_INFO_OVR_LBL_COUNT 45 Smallint value; indicates the number of label overrides.
LAYER_INFO_OVR_STYLE_CURRENT 46 Smallint value, indicates display style override index in current zoom range, 0 means no override.
LAYER_INFO_OVR_LBL_CURRENT 47 Smallint value, indicates label override index in current zoom range, 0 means no override.
LAYER_INFO_OVR_LINE_COUNT 48 Smallint value, indicates the number of Pen styles defined for displaying linear objects for the layer's base set of properties.
LAYER_INFO_OVR_PEN_COUNT 49 Smallint value, indicates the number of Pen styles defined for displaying borders of filled objects for the layer's base set of properties.
LAYER_INFO_OVR_BRUSH_COUNT 50 Smallint value, indicates the number of brush styles defined for displaying filled objects for the layer's base set of properties.
LAYER_INFO_OVR_SYMBOL_COUNT 51 Smallint value, indicates the number of symbol styles defined for displaying point objects for the layer's base set of properties.
LAYER_INFO_OVR_FONT_COUNT 52 Smallint value, indicates the number of font styles defined for displaying text objects for the layer's base set of properties. This always returns 1, because font style is not supported by stacked styles.
LAYER_INFO_TILE_SERVER_LEVEL 53 Smallint value, representing the tile server level used to display the layer in the current map view. -1 for non-tile server layers.
LAYER_INFO_LBL_AUTO_POSITION 54 Logical value, indicates if the advanced region labeling option for the layer is on or off.
LAYER_INFO_LBL_AUTO_SIZES 55 Logical value, defines the number of font sizes that can be used when attempting to fit labels within regions. The number of fonts can range from 1 to 10. A 0 (zero) value indicates that Default is chosen, so that MapInfo Pro defines the number of fonts to use.
LAYER_INFO_LBL_SUPPRESS_IF_NO_FIT 56 Logical value, indicates if this labeling option is On or Off. If after applying the optional font size step-downs the label still does not fit in the region, then the label is not drawn.
LAYER_INFO_LBL_AUTO_SIZE_STEP 57 Smallint value, defines the overall percentage font size step used for automatically resizing the label font to make a label fit. If the original font size is 24pt and the size step is defined as 66, then the smallest font will be 66% smaller than 24pt (the smallest font will be 8pt).
LAYER_INFO_LBL_CURVED_BEST_POSITION 58 Logical value, indicates if auto positioning for curved labels is on or off.
LAYER_INFO_LBL_CURVED_FALLBACK 59 Logical value, indicates if the option to fallback to create a rotated label is on or off.
LAYER_INFO_LBL_USE_ABBREVIATION 60 Logical value, indicates if use of abbreviations is on or off.
LAYER_INFO_ABBREVIATION_EXPR 61 Returns the field expression used for abbreviated labels.
LAYER_INFO_LBL_AUTO_CALLOUT 62 Logical value, indicates if the advanced region labeling option of rendering a callout for the layer is on or off.
LAYER_INFO_LBL_ORDER 63 Smallint value, a layer's labeling order.
LAYER_INFO_FRIENDLYNAME 64 String value, the friendly name assigned to a layer.
LAYER_INFO_GRIDLINE_COORDSYS 65 String value, containing the coordinate system used to create the gridline. Empty when layer is not a gridline.
LAYER_INFO_GRIDLINE_SPACE_HORIZONTAL 66 Float value, returns the current actual gridline map spacing on screen, not the requested value. If using automatic spacing, this is the horizontal spacing. If lines are closer than the minimum horizontal paper spacing, this returns the horizontal spacing displayed on the map (which should be a larger value than requested). Returns 0.0 when layer is not a gridline.
LAYER_INFO_GRIDLINE_SPACE_VERTICAL 67 Float value, returns the current actual gridline map spacing on screen, not the requested value. If using automatic spacing, this is the vertical spacing. If lines are closer than the minimum vertical paper spacing, this returns the vertical spacing displayed on the map (which should be a larger value than requested). Returns 0.0 when layer is not a gridline.
LAYER_INFO_GRIDLINE_AUTO 68 Logical value, indicates TRUE if the layer is a gridline that is using automatic spacing.
LAYER_INFO_GRIDLINE_MIN_HORIZONTAL 69 Float value, representing minimum paper spacing allowed between horizontal gridlines when using automatic spacing. The value is in the current paper unit (see Set Paper Units statement). Returns 0 when layer is not a gridline.
LAYER_INFO_GRIDLINE_MIN_VERTICAL 70 Float value, representing minimum paper spacing allowed between vertical gridlines when using automatic spacing. The value is in the current paper unit (see Set Paper Units statement). Returns 0 when layer is not a gridline.
LAYER_INFO_GRIDLINE_PAPER_HORIZONTAL 71 Float value, returns the requested paper distance if the spacing is automatic and the actual current paper distance if the spacing is not automatic. The value is in the current paper unit (see Set Paper Units statement). Returns 0 when layer is not a gridline.
LAYER_INFO_GRIDLINE_PAPER_VERTICAL 72 Float value, returns the requested paper distance if the spacing is automatic and the actual current paper distance if the spacing is not automatic. The value is in the current paper unit (see Set Paper Units statement). Returns 0 when layer is not a gridline.
LAYER_INFO_GRIDLINE_OFFSET 73 Float value, representing the current paper unit distance of gridline labels from the edge of the map (inwards). The value is in the current paper unit (see Set Paper Units statement). Returns -1 when layer is not a gridline.
LAYER_INFO_LABEL_POS_RETRY 74 Logical value, TRUE if the label property for Try other positions is set and FALSE otherwise.
LAYER_INFO_GRIDLINE_HORIZONTAL_LABEL_POS 75 Float value, for the current position of labels for horizontal gridlines. Return values are:
  • -1 when the layer is not a gridline.
  • GRIDLINE_HORIZONTAL_LABEL_NONE (0) when there are no horizontal gridline labels.
  • GRIDLINE_HORIZONTAL_LABEL_LEFT (1) when the horizontal gridlines only have labels on the left.
  • GRIDLINE_HORIZONTAL_LABEL_RIGHT (2) when the horizontal gridlines only have labels on the right.
  • GRIDLINE_HORIZONTAL_LABEL_BOTH (3) when the horizontal gridlines have labels on the left and the right.
LAYER_INFO_GRIDLINE_VERTICAL_LABEL_POS 76 Float value, for the current position of labels for vertical gridlines. Return values are:
  • -1 when the layer is not a gridline.
  • GRIDLINE_VERTICAL_LABEL_NONE (0) when there are no vertical gridline labels.
  • GRIDLINE_VERTICAL_LABEL_TOP (1) when vertical gridlines only have labels on the top.
  • GRIDLINE_VERTICAL_LABEL_BOTTOM (2) when the vertical gridlines only have labels on the bottom.
  • GRIDLINE_VERTICAL_LABEL_BOTH (3) when the vertical gridlines have labels on the top and the bottom.
LAYER_INFO_GRIDLINE_LABEL_DIRECTION 77 Float value, for the label direction for gridlines. Return values are:
  • -1 when the layer is not a gridline.
  • GRIDLINE_LABEL_DIRECTION_COMPASS (1) when the gridline coordinate system is Latitude/Longitude and the gridline label has an appended compass direction: N for north, S for south, E for east, or W for west. The number always displays as a positive number.
  • GRIDLINE_LABEL_DIRECTION_PLUSMINUS (0) when the gridline label is either a positive or negative number.
LAYER_INFO_ALIAS 78 String value, for the name of the layer as displayed in the MalpInfo Pro layers list.
LAYER_INFO_LBL_LINE_PEN 79 String value, for the line pen clause for the line used for the label callout. If this is a raster layer that does not support labels, then the session line pen is returned.
LAYER_INFO_RASTER_CONTRAST 80 SmallInt value, representing the contrast of the image as a percentage (0-100%).
LAYER_INFO_RASTER_BRIGHTNESS 81 SmallInt value, representing the brightness as a percentage (0-100%).
LAYER_INFO_RASTER_ALPHA 82 SmallInt value, representing the alpha factor for the translucency of the image (0-100%).
LAYER_INFO_RASTER_GREYSCALE 83 Logical value, representing if the image display should display as greyscale instead of the default image mode.
LAYER_INFO_LABEL_EXPR_TABLE 84 String value, representing the name of the table used for label expression.
LAYER_INFO_LBL_CURVED_PERCENT_OVER 85 Integer value, indicating the percentage value by which a label may extend beyond the end of a line (for example).
LAYER_INFO_LEGEND 86 Logical value: Returns True if the layer supports legend
LAYER_INFO_FILTER_ENABLED 87 Logical Value: True if Filter is enabled on map layer otherwise false.
LAYER_INFO_FILTER_EXPR 88 String Value: Map Layer Filter expression condition string.
LAYER_INFO_FILTER_TABLE_ALIAS 89 String Value: Map Layer hidden filter table alias name.
LAYER_INFO_TIME_BEGIN_TYPE 90

Int:

LAYER_INFO_TIME_TYPE_NONE (0)

LAYER_INFO_TIME_TYPE_DATE ( 1)

LAYER_INFO_TIME_TYPE_DATETIME(2)

LAYER_INFO_TIME_TYPE_TIME(3)

LAYER_INFO_TIME_TYPE_DATEPLUSTIME(4)

LAYER_INFO_TIME_TYPE_DURATION(5)

LAYER_INFO_TIME_BEGIN_EXPR 91 String: date, time, or datetime expression – usually an indexed column.
LAYER_INFO_TIME_BEGIN_EXPR2 92 String: a time expression – usually a column. Only valid if begin_expr is of type date.
LAYER_INFO_TIME_END_TYPE 93

Int:

LAYER_INFO_TIME_TYPE_NONE (0)

LAYER_INFO_TIME_TYPE_DATE ( 1)

LAYER_INFO_TIME_TYPE_DATETIME(2)

LAYER_INFO_TIME_TYPE_TIME(3)

LAYER_INFO_TIME_TYPE_DATEPLUSTIME(4)

LAYER_INFO_TIME_TYPE_DURATION(5)

LAYER_INFO_TIME_END_EXPR 94 String: date, time, or datetime expression – usually an indexed column. Unless it is a duration then it is a numeric expression.
LAYER_INFO_TIME_END_EXPR2 95 String: a time expression – usually a column. Only valid if end_expr is of type date.
LAYER_INFO_TIME_END_DURATION 96

Logical: True if LAYER_INFO_TIME_END_EXPR

Represents a duration

LAYER_INFO_TIME_DURATION_UNIT 97 String: The time unit of the duration
LAYER_INFO_TIME_EXTENT_BEGIN 98 DateTime: The lowest value of the time data in the layer’s table. Usually calculated from min() but can be specified manually
LAYER_INFO_TIME_EXTENT_END 99 DateTime: The largest value of the time data in the layer’s table. Usually calculated from max() but can be specified manually
LAYER_INFO_TIME_INTERVAL 100 Int: Default interval to split the time extents into a series of time periods
LAYER_INFO_TIME_INTERVAL_UNIT 101 String: Time Unit
LAYER_INFO_TIME_IGNORE_NULLS 102 Logical: include/exclude null values from time period query.

Hotlinks

For backwards compatibility, the original set of attributes before version 10.0 still work, and will return the values for the layer's first hotlink definition. If no hotlinks are defined when the function is called, then the following values are returned:

LAYER_INFO_HOTLINK_EXPR - empty string ("")

LAYER_INFO_HOTLINK_MODE - returns default value HOTLINK_MODE_LABEL

LAYER_INFO_HOTLINK_RELATIVE - returns default value FALSE

Examples

Many of the settings that you can query using LayerInfo() only apply to conventional map layers (as opposed to cosmetic map layers, thematic map layers, and map layers representing raster image tables).

To determine whether a map layer is a conventional layer, use the LAYER_INFO_TYPE setting, as shown below:

i_lay_type = LayerInfo( map_id, layer_number, LAYER_INFO_TYPE) 

If i_lay_type = LAYER_INFO_TYPE_NORMAL Then 
	'
	' ... then this is a "normal" layer
	'
End If 

The following example illustrates layer priority. If the label priority order is set as:

Set Map Window FrontWindow() LabelPriority 5, 1, 2, 4, 3

Then the following returns a value of 1, because the default draw order for labels is the same as the draw order for map layers (which is bottom up).

LayerInfo(FrontWindow(), 5, LAYER_INFO_LBL_ORDER)

See Also:

GroupLayerInfo function, LayerListInfo() function, MapperInfo() function, Set Map statement