AddLayer()

Summary

Adds a layer from a geographic file to a map.

Syntax

actual_lyr_name = AddLayer(string map_name, string layer_name, string db_name, string db_layer_name [, array options])

Argument Contents
map_name The name of the map to which the layer is added
layer_name The desired name for the layer in the map
db_name The full path and file name of the geographic file that contains the layer
db_layer_name The layer name as defined in the geographic file
Option Type Contents
Read Only Boolean "True" to open read only, "False" (default) otherwise
Shared Boolean "True" to open shared, "False" (default) otherwise; "False" sets the Exclusive mode

Returns

A string indicating the actual name of the layer, which is identical to layer_name unless the layer name is already in use.

Notes

  • The options array is an optional argument.

  • AddLayer() can add both standard and compact geographic files as layers.

  • AddCDFLayer() is equivalent to not passing options to AddLayer().

  • For backward compatibility, AddLayerEx() may be used as an alternate function name.

  • If the map_name is null, AddLayer() adds the layer to the current map.

  • Adding a layer to a map does not set any display characteristics for the layer. In other words, the layer is not visible until display colors and styles are assigned. Default display settings can be made with the New Layer Default Settings Standard Interface Macro.

  • Maptitude tracks geographic files and their layer names across the entire workspace, not just within individual map and dataview windows. While the same geographic file can have identical layer names in different maps, different geographic files cannot share the same layer name, even if they reside in separate maps. When a naming conflict occurs, Maptitude automatically appends a colon and sequence number to the layer name to ensure uniqueness.

Example

// Before running the example, create a map by opening nesouth.cdf
// in the Tutorial folder.
folder = RunMacro("G30 Tutorial Folder")
new_lyr = AddLayer(, "Place", folder + "nes_plc.cdf", "Place", {{"Shared", "True"}})
RunMacro("G30 new layer default settings", new_lyr) text 

Error Codes

Error Type Meaning
Error The map or the specified geographic file does not exist; or the file is not a valid geographic file; or db_layer_name is not found in the file; or the layer is already in the map

See Also

Function Summary
AddMITABLayer() Adds a layer from a compact geographic file to a map
AddSDOLayer() Adds a layer to a workspace without it appearing in a map or dataview
AddShapeLayer() Adds an existing layer in the workspace to a map
DropLayer() Removes a layer from a map
GetLayers() Gets information on layers in the system and the current layer.
AddMITABLayer() Adds a layer from a MapInfo TAB file to a map
AddODBCLayer() Adds an ODBC layer to a map
AddShapeLayer() Adds a layer from an Esri (ArcView) Shapefile to a map
GetMapLayers() Gets a list of the layers in a map