AddLayerToWorkspace()

Summary

Adds a layer to an application without it appearing in a map or dataview.

Syntax

actual_name = AddLayerToWorkspace(string layer_name, string db_name, string db_layer_name [, array options])

Argument Contents
layer_name The desired name for the new layer
db_name Path and file name of the geographic file that contains the layer
db_layer_name The name of the layer 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.

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

  • Selection functions that do geographic searching on a layer require that the layer be in a map, not just in the workspace.

  • 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

lyr = AddLayerToWorkspace("Counties", "cccntyl.cdf", "County (Low Res)" ,
{{"Shared", "True"}})
nrecs = GetRecordCount(lyr, )
DropLayerFromWorkspace(lyr)
ShowMessage("There are " + String(nrecs) + " counties.")

Error Codes

Error Type Meaning
Error The db_name file is not a valid geographic file
NotFound The specified path and name do not exist

See Also

Function Summary
AddCDFLayer() Adds a layer from a compact geographic file to a map
AddImageLayer() Adds an image layer to a map
AddLayer() Adds a layer from a geographic file to a map
AddExistingLayer() 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.
DropLayerFromWorkspace() Removes a layer from an application
GetMapLayers() Gets a list of the layers in a map