Ordering Layers - 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

The following clauses move a layer and group layer to a specific location in the layer list.

Syntax

Set Map 
	[ Window window_id ] 
	[ Order layer_id, [ , layer_id ... ] ] 
	[ 
		[ GroupLayers group_layer_id [ , group_layer_id... ] ] 
		[ Layers layer_id [ , layer_id ] ] . . .
		[ DestGroupLayer group_layer_id [ Position position ] ] ]

window_id is the integer window identifier of a Map window.

layer_id is a number identifying a map layer to modify, according to that layer's original position in the map, where 1 (one) is the top-most layer number (the layer which draws last, and therefore always appears on top).

group_layer_id is a number identifying a group layer to modify, according to its original position in the map.

position is 1-based index within the destination group of where to insert the list of layers being moved. The default position is the first position in the group (position = 1).

Description

The Cosmetic layer is a special layer, with a layer number of zero. The Cosmetic layer is always drawn last; thus, a zero should not appear in an Order clause. For example: given a Map window with four layers (not including the Cosmetic layer), the following Set Map statement will reverse the order of the topmost two layers:

Set Map Order 2, 1, 3, 4 

Set Map Order resets the order in which map layers are drawn. It moves layers, such as 3, 2, and 1 in the following example, to the top of the layer list, removing them from whatever group they might have been in.

Set Map Order Layers 3, 2, 1

However, using the GroupLayers and Layers clauses lets you specify moving layers and/or whole groups.

The optional DestGroupLayer specifies the group to insert the list of one or more layers and groups into, and at what position. This clause can also be used with the older syntax to specify the exact location to insert the layers. If missing, it means the groups and/or layers are inserted into the top level list at the first position (as it was assumed with the old syntax). However you can specify the top level list with a group ID = 0.

The position is the 1-based index within the destination group of where to insert the list of layers being moved. If the position is omitted it is assumed to be the first position in the group (position = 1).

If the position given exceeds the number of items in the destination group, the new layers and/or groups will be inserted at the end of the destination group.

Layer and group IDs may be the numeric ID or name. Group IDs range from 0 to the total number of groups in the list.

Once the list is reordered all IDs are renumbered sequentially from the top down.

Thematic layers and their reference base layer must always remain in a contiguous sequence, so Set Map Order will not allow you to insert layers within a set of thematic layers. If the Position specified would insert layers within a set of thematic layers, the layers will instead be inserted above or below the set, which ever is closest to the original Position.