AttributeValue(AttributeName: String): Variant;
AttributeName. Name of the attribute, which value should be determined.
The AttributeValue property returns the value of the area attribute by value name.
Executing the example requires a form with the following components: the Button component named Button1, the MapBox component named MapBox1, and the UiMap component named UiMap1. UiMap1 is a data source for MapBox1. The UiMap1 component must have a connected map. Map areas must have attributes set.
The example is a handler of the OnClick event for the Button1 component.
Add links to the ExtCtrls, Forms, and Map system assemblies.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
M: IMap;
Layer: IMapLayer;
Shape: IMapTopobaseShape;
Primitiv: IMapTopobasePrimitives;
v: Variant;
i: Integer;
s: String;
Begin
M := UiMap1.Map;
Layer := M.Layers.FindByName("Regions");
Shape := Layer.Shapes.Item(0);
// Get value of area attribute by its name
v := Shape.AttributeValue("Attribute1");
Debug.WriteLine("Data type of attribute value: " + v.VarType.ToString);
// Determine area identifier
i := Shape.Id;
Debug.WriteLine("Area identifier: " + i.ToString);
// Determine area name
s := Shape.Name;
Debug.WriteLine("Area name: " + s);
// Change area description
Shape.Description := "The greatest area";
// Get the layer, to which the area belongs
s := Shape.Owner.Name;
Debug.WriteLine("Map layer name: " + s);
// Determine the number of primitives, of which the first area consists
Primitiv := Shape.Primitives;
i := Primitiv.Count;
Debug.WriteLine("Number of primitives in the collection: " + i.ToString);
End Sub Button1OnClick;
After executing the example the console displays the following:
Data type of attribute value of the first area.
Area identifier and name.
Map layer name.
Number of primitives in the collection.
The first area description will change for the specified one.
See also: