Adding Style Overrides to a Layer - 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

The Override Add clause creates a new style override definition for a layer if none exists, or appends to the existing list of style override definitions. A style override allows you to change map styles based on the current zoom level of the map.

Syntax

Set Map 
	[ Window window_id ] 
	[ Layer layer_id 
		[ Zoom ( min_zoom, max_zoom ) [ Units unit_dist ] ]
		[ Display { Off | Graphic | Global } ]
		[ Global Pen...[ , Pen...]...]
		[ Global Line...[ , Line...]...]
		[ Global Symbol...[ , Symbol...]...]
		[ Global Brush...[ , Brush...]...]
		[ Global Font...]
		[ { Alpha alpha_value }| { Translucency translucency_percent } ]
		[ STYLEOVERRIDE_CLAUSE ] ... ]

Where STYLEOVERRIDE_CLAUSE is:

[ [ Style ] Override Add [override_name] { 
	[ Using [ Window window_id  ] Layer layer_id { 
		All | Override { override_index | override_name } } 
	] | 
	Zoom ( min_zoom, max_zoom ) 
	[ Units dist_unit ]
	[ { Alpha alpha_value } | { Translucency translucency_percent } ]
	[ Enable { On | Off } ]
	[ Arrows { On | Off } ]
	[ Centroids { On | Off } ]
	[ Nodes { On | Off } ]
	[ Line...] [ , Line... ] 
	[ Pen...] [ , Pen... ] ...
	[ Symbol... ] [ , Symbol... ] ...
	[ Brush... ] [ , Brush... ] ...
	[ Font... ] [ , Font... ] ... } ]

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.

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

override_name is the user specified override name.

min_zoom is a numeric expression, identifying the minimum zoom at which the style override will come into effect

max_zoom is a numeric expression, identifying the 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.

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 image layer display translucent.

translucency_percent is an integer value representing the percentage of translucency for a vector, raster, or grid image layer. Values range between 0-100. 0 is completely opaque. 100 is completely transparent.

Note: Specify either Alpha or Translucency but not both, since they are different ways of specifying the same result. If you specify multiple keywords, the last value will be used.

Description

The display style zoom range lets you set up display style overrides that only apply within a limited range of zoom levels. There can be multiple display style zoom ranges per layer. To have the line styles change when zooming in on the map, set up multiple display style zoom ranges and assign a different style override to each of them.

The layer zoom range turns off the layer altogether if you zoom in or out too far. There can only be one of these per layer.

Arrows turns the display of direction arrows on or off.

Centroids turns the display of centroids on or off.

Nodes turns the display of nodes on or off.

Line specifies the style used to display line and polyline objects. A Line clause is identical to a Pen clause, except for the use of the keyword Line instead of Pen.

Pen is a valid Pen clause that specifies the style used to display the borders of filled objects.

Symbol is a valid Symbol clause that specifies the style used to display point objects.

Brush is a valid Brush clause that specifies the style used to display filled objects.

Font is a valid Font clause that specifies the font used to display text objects.

Using is for a one-time copy (only the overridden properties get copied) to set the initial property value of an layer override. The source and target layer do not maintain a connection.

Each vector layer supports more than one style override and more than one label override. Every style override has its own zoom range that is not allowed to overlap with any other style override for the same layer. Every label override also has its own zoom range that is not allowed to overlap any other label override for the same layer. However, style and label overrides can share or have overlapping zoom ranges between each other.

When an override comes into view (when the map's zoom range is within an override zoom range) then the map styles or labels are displayed using the override properties rather than the layers base set of style and label properties.

Style overrides do not display beyond the limits of the layer display zoom range regardless of what bounds the style override zoom range defines. Likewise, label overrides do not display beyond the limits of the layer's label zoom range, or the layer's display zoom range, regardless of what bounds the label override defines.

For more information about style overrides for layers, see Modifying Style Overrides for a Layer and Enabling, Disabling, or Removing Overrides for a Layer. See also, LayerStyleInfo( ) function and StyleOverrideInfo( ) function.

Examples

The following statement adds an override to a layer:

Set Map Layer 1 
	Style Override Add Zoom (0, 10000) Units "mi" Line (2, 193, 16711680)

The following statement adds multiple style overrides to a layer:

Set Map Layer 1 Display Global 
	Zoom (1, 10000) Units "mi"
	Global Line (1, 193, 16711680) 
	Style Override Add Zoom (1, 1000) Units "mi" Line (4, 193, 16711680), 
		Line (2, 193, 16711680)
	Style Override Add Zoom (1000, 10000) Units "mi" 
		Line (2, 193, 16711680)

Example: copy a style from one map to another map

To copy a style from one map to another map:

Set Map Layer 1 Style Override Add Using Window 81132792 Layer 1 All

Examples: adding styles from another layer

The following statement adds an override for layer 2 using style named layer1_style2 from layer 1:

Set Map Layer 2 
	Style Override Add Using Layer 1 layer1_style1

The following statement adds an override for layer 2 using style 3 from layer 1:

Set Map Layer 2 
	Style Override Add layer2_style2 Using Layer 1 Override 3

The following statement copies over all the overrides information from layer 2 to layer 3:

Set Map Layer 3 Display Global
	Global Line (1, 193, 16711680)
	Style Override Add Using Layer 2 All