- globalmapper.SetLayerUserText(GM_LayerHandle_t32 aLayer, str aUserText) GM_Error_t32
-
Sets a text string to associate with the layer. This value can be retrieved by calling GetLayerInfo. This text string will persist through a save to a workspace with SaveWorkspace so if you reload that workspace the same text string will be available. This is useful if you want to tie some text to the layer that persists through a save.
- Parameters:
-
aLayer (GM_LayerHandle_t32) – layer to set user text for
aUserText (str) – text string to set as text for layer
- Returns:
-
Error Code
- Return type:
-
GM_Error_t32
Example
The following is an example of SetLayerUserText.
import os
import globalmapper as gm
import_dir = "Z:/GM-20069/vector_layer_editing_sample_data/"
# Close all layers that may be open
layers_are_open = gm.GetLoadedLayerList()
if layers_are_open:
arr_ptr, arr_size = layers_are_open
initial_layers = gm.GM_LayerHandle_array_frompointer(arr_ptr)
for i in range(arr_size):
gm.CloseLayer(initial_layers[i])
err_LoadLayerList, array_pointer, array_size_param = gm.LoadLayerList(
os.path.join(import_dir, "line.shp"),
gm.GM_LoadFlags_HideAllPrompts,
)
# Get handle for the loaded layers
arr_ptr, arr_size = gm.GetLoadedLayerList()
layers_array = gm.GM_LayerHandle_array_frompointer(arr_ptr)
layers_list = gm.carray_to_list(layers_array, arr_size)
### START SAMPLE
note = "TASK: Overlay this file with wildfire_lidar.laz to determine areas of habitat loss."
err_SetLayerUserText = gm.SetLayerUserText(
layers_list[0], note
)
### END SAMPLE
assert (
gm.GM_Error_None == err_LoadLayerList
), f"LoadLayerList: Expected {gm.GM_Error_None}, got {err_LoadLayerList}"
assert (
gm.GM_Error_None == err_SetLayerUserText
), f"SetLayerUserText: Expected {gm.GM_Error_None}, got {err_SetLayerUserText}"
assert os.path.isdir(import_dir), f"Import directory doesn't exist: {import_dir}"
assert os.path.exists(
os.path.join(import_dir, "line.shp")
), "Sample data doesn't exist"