IMapLayerVisuals.Add

Syntax

Add(Visual: IMapVisual): Integer;

Parameters

Visual - indicator, which index should be obtained.

Description

The Add method returns the index of the specified collection indicator.

Example

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. A map should be connected to the UiMap1 component. The VisualDataAdapter class that creates a dynamic data source should also be implemented. The class example is contained in the IMapVisual.DataAdapter property description.

The example is a handler of the OnClick event for the Button1 component.

Add links to the Drawing, ExtCtrls, Forms, and Map system assemblies.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    Map: IMap;
    MapVisual: IMapVisual;
    Layer: IMapLayer;
    VisualName: String;
    Index: Integer;
Begin
    Map := UiMap1.Map;
    VisualName := "Regions";
    MapVisual := Map.FindVisual(VisualName);
    Layer := Map.Layers.FindByName(VisualName);
    // Get index of the specified indicator in the collection 
    Index := Layer.Visuals.Add(MapVisual);
    Debug.WriteLine("Index of the Regions indicator: " + Index.ToString);
End Sub Button1OnClick;

After executing the example the console displays index of the indicator in the collection of layer indicators.

See also:

IMapLayerVisuals