IMapLayer.TextDataAdapter

Syntax

TextDataAdapter: Object;

Description

The TextDataAdapter property determines the data source for map layer labels.

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. The map must be connected to the UiMap1 component.

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

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

Class TextDataAdapter: Object, IMapDataAdapter
Public Str: String;
    Function Get_Data(Attribute: Variant): Variant;
    Var
        shape: IMapTopobaseShape;
    Begin
        shape := Attribute As IMapTopobaseShape;
        Return Str + shape.Name;
    End Function Get_Data;
End Class TextDataAdapter;

Class TestForm: Form
    UiMap1: UiMap;
    MapBox1: MapBox;
    Button1: Button;
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    Da: TextDataAdapter;
    MapDa: IMapDataAdapter;
    M: IMap;
    mLayers: IMapLayers;
    mLayer: IMapLayer;
    mShapes: IMapTopobaseShapes;
    mShape: IMapTopobaseShape;
    i: integer;
Begin
    Da := New TextDataAdapter.Create;
    Da.Str := "This ";
    MapDa := Da As IMapDataAdapter;
    M := UiMap1.Map;
    mLayers := M.Layers;
    mLayer := mLayers.FindByName("Regions");
    mShapes := mLayer.Shapes;
    For i := 0 To mShapes.Count - 1 Do
        mShape := mShapes.Item(i);
        Debug.WriteLine(MapDa.Data(mShape));
    End For;
    mLayer.TextDataAdapter := MapDa;
    mLayer.TextVisible := True;
End Sub Button1OnClick;
End Class TestForm;

After executing the example the labels source is determined for the Regions map layer. The labels of all the layer areas are displayed in the console window.

See also:

IMapLayer