Modifying Layer Label Overrides - 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

When the add keyword is excluded from the Label Override clause it will modify the properties for an existing multiple label override definition within a layer specified by the integer index (1-based) or the override name.

Set Map [Layer layer_id
	[Label...
		[ MODIFYLABEL_OVERRIDE_CLAUSE ]
		[ MODIFYLABEL_OVERRIDE_CLAUSE ] ... ] ]

Where MODIFYLABEL_OVERRIDE_CLAUSE is:

[ Override { labeloverride_index | labeloverride_name } {
	[ Zoom ( min_vis, max_vis ) [ Units dist_unit ] ]
	[ Enable { On | Off } ]
	[ Line { Simple | Arrow | None } ]
	[ Position [ Center ] [ { Above | Below } ] [ { Left | Right } ] ]
	[ Auto Retry { On | Off } ]
	[ Font...] [ Pen... ]
	[ With label_expr ] [ Parallel { On | Off } ] 
	[ Follow Path [ BestPosition { On | Off } ] [ Percent Over percent ] [ Fallback { On | Off } ] ]
	[ Auto { On | Off } ]
	[ Overlap { On | Off } ]
	[ PartialSegments { On | Off } ]
	[ Duplicates { On | Off } ]
	[ Max [ number_of_labels ] ]
	[ Offset offset_amount ]
	[ LabelAlpha alpha_value ] } 
	[ AutoPosition { On | Off } ]
	[ AutoSizes { number_font_sizes | Default } ]
	[ AutoSizeStep percentage_value ]
	[ SuppressIfNoFit { On | Off } ] 
	[ AutoCallout { On | Off } ] 
	[ Abbreviation { On | Off } Abbreviate with { field_expression } ] ]

window_id is the integer window identifier of a Map window.

layer_id identifies which layer to modify; can be a SmallInt (for example, use 1 to specify the top map layer other than Cosmetic) or a string representing the name of a table displayed in the map.

labeloverride_index is an integer index (1-based) for the override definition within the layer. Each label override is tied to an zoom range and is ordered so that the smallest zoom range value is on top (index 1).

labeloverride_name is the user specified override name.

min_vis, max_vis are numbers specifying the minimum and maximum zoom at which the style override will come into effect.

dist_unit is a string expression, specifying the units for the map (such as "mi" for miles, "m" for meters; see Set Distance Units statement for a list of available unit names). This is an optional parameter. If not present, the distance units from the table's coordinate system are used.

label_expr is the expression to use for creating labels.

percent when curved labels are longer than the geometry they name, this is the amount (expressed as a percentage) of overhang permitted.

number_of_labels is an integer representing the maximum number of labels MapInfo Pro will display for the layer. If you omit the number_of_labels argument, there is no limit.

offset_amount is a number from zero to 200 (representing a distance in points), causing the label to be offset from its anchor point.

alpha_value is an integer value representing the alpha channel value for translucency. Values range from 0-255. 0 is completely transparent. 255 is completely opaque. Values between 0-255 make the labels display translucent.

number_font_sizes is a number from 1 to 10 that represents font size steps to use when fitting labels within regions. If not specified, the default value is 4.

percentage_value is a number from 1 to 99 that represents the smallest percentage decrease of the font size when resizing the label font to make labels fit when resizing the map. The default value is 50.

field_expression is the column name in the table that contains the abbreviations.

Description

Line sets the type of call-out line, if any, that should appear when a label is dragged from its original location. You can specify Line Simple, Line Arrow, or Line None. For example:

Position controls label positions with respect to the positions of object centroids. For example, the following statement sets labels above and to the right of object centroids.

Auto Retry lets users to apply a placement algorithm that will try multiple label positions until a position is found that does not overlap any other label, or until all positions are exhausted.

  • When Writing Workspaces, if the Auto Retry feature is On, we write Auto Retry On to the workspace after the Position clause (but the order isn't important), and increase the workspace version to 9.5 or later. If the feature is Off, we do not write anything to the workspace and do not increase the version number. A version 9.5 or later workspace can have Auto Retry Off in it, but we do not explicitly write it out, to avoid increasing the version unnecessarily.
  • When Reading Workspaces If Auto Retry On or Auto Retry Off is in the workspace, it must be a version 9.5 or later workspace, otherwise a syntax error occurs. If Auto Retry is On, different positions are tried to place the label. If Auto Retry is Off, no retry is attempted―this is the default behavior. Overlap must be Off to enable the Auto Retry feature. If Overlap is On and Auto Retry On/Off are in the same LABELCLAUSE, the Auto Retry mechanism is initialized but ignored, so overlapping labels are allowed.

Font is a valid Font clause to specify a text style used in labels.

Pen is a valid Pen clause to specify the line style to use for call-out lines. Call-out lines only appear if you specify Line Simple or Line Arrow, and if the user drags a label from its original location.

Set Map Layer 1 Label Line Arrow Pen( 2, 1, 255) 

With specifies the expression used to construct the text for the labels. For example, the following statement specifies a labeling expression which uses the Proper$( ) function to control capitalization in the label.

Set Map Layer 1 Label With Proper$(Cityname)

Parallel controls whether labels for line objects are rotated, so that the labels are parallel to the lines. Set to Off for horizontal labels that are not rotated with the line segment, and set to On for labels rotated with the line segment.

Set Map Layer 1 Label Parallel On 

Follow Path is used when creating curved labels. Path is automatically calculated once and then stored until the curved label location is edited.

The BestPosition option attempts to find a more suitable location along a polyline when the polyline bends too sharply to place a label. The best three positions are located. If the label cannot be drawn at one of these positions, then it falls back to the normal curved label location and then to a rotated label if the Fallback option is on. The default value is Off.

Set Map Window 145919584 Layer 1 Label Override 1 Follow Path BestPosition On

Percent Over only applies to curved labels. It applies when curved labels are longer than the geometry they name, this is the amount (expressed as a percentage) of overhang permitted. For example, a sample entry might be:

Set Map Layer 1 Label Override Follow Path Percent Over 40

Fallback only applies to curved labels. When a polyline is very jagged (not smooth or gently curved) it is difficult to place characters along it to create a curved label. Set Fallback to On to create a straight label when a curved label cannot be created. It rotates the straight label to match a segment near to where the curved label would have been placed. MapInfo Pro does not prevent a rotated label from crossing a polyline. Setting this option displays more labels on your map. By default, this option is set to Off. When MapInfo Pro cannot draw a curved label and draws a straight label instead (as a fallback), the overhang percent is ignored.

Auto controls whether automatic labels display. If you specify Auto Off, automatic labels will not display, although user-edited labels will still display.

Overlap controls whether MapInfo Pro draws labels that would overlap existing labels. To prevent overlapping labels, specify Overlap Off.

PartialSegments controls whether MapInfo Pro labels an object when the object's centroid is not in the visible portion of the map. If you specify PartialSegments On (which corresponds to selecting the Label Partial Objects check box in MapInfo Pro), MapInfo Pro labels the visible portion of the object. If you specify PartialSegments Off, an object will only be labeled if its centroid appears in the Map window.

Duplicates controls whether MapInfo Pro allows two or more labels that have the same text. To prevent duplicate labels, specify Duplicates Off.

Max number_of_labels sets the maximum number of labels that MapInfo Pro will display for this layer. If you omit the number_of_labels argument, MapInfo Pro places no limit on the number of labels.

Offset offset_amount specifies an offset distance, so that MapInfo Pro automatically places each label away from the object's centroid. The offset_amount argument is an integer from zero to 50, representing a distance in points. If you specify Offset 0 labels appear immediately adjacent to centroids. If you specify Offset 10 labels appear 10 points away. The offset setting is ignored when the Position clause specifies centered text.

AutoPosition turns on or off the advanced region labeling option. The AutoSizes, AutoSizeStep, and SuppressIfNoFit clauses are active when this is set to On. The default value for this clause is Off.

AutoSizes defines the number of decreasing font sizes that can be used when attempting to fit labels within regions. The value range is 1 to 10, and the default value is 4. Setting this to 1 uses the current font size. Setting a number greater than 1 reduces the font down to the minimum font size calculated using AutoSizeStep. Specifying Default causes MapInfo Pro to define the number of font sizes to use (between 1 and 10).

AutoSizeStep defines a percentage for reducing font size to make labels fit when resizing a map. The value range is 1 to 99. As an example, if the original font size is 24pt and the number_font_sizes is 66, then the smallest font is 66 percent smaller than 24pt, so the smallest font will be 8pt. The default value is 50.

When SuppressIfNoFit is set to On, then only the labels that still fit after resizing the map display. If a label does not fit in a region, then it is not drawn. This clause is set to On by default.

The AutoCallout clause turns on or off the rendering of callouts for advanced region labeling. The default value is Off. The AutoPosition and SuppressIfNoFit options must both be set to On to use the AutoCallout clause.

Abbreviation only applies to labels. When set to On, the abbreviation field expression, field_expression, is used for labels that cannot be drawn, because they overlap other labels or do not fit within a region. When set to On, you must also specify the Abbreviate with clause.

The Abbreviate with clause is used with the Abbreviation clause. This clause specifies the abbreviation field expression, field_expression, to use in the layer table.

Set Map Window 145919584 Layer 1 Label Override 1 Abbreviation On
Set Map Window 145919584 Layer 1 Label Override 1 Abbreviate with ShortName

For more information about style overrides for layers, see Adding Overrides for Layer Labels and Enabling, Disabling, or Removing Overrides for Layer Labels. See also, LabelOverrideInfo( ) function.

Example

The following example modifies style:

Set Map Layer 1 Label Override 3 Zoom (1000, 10000) 
	Line Arrow Pen (2, 1, 255)