IMapDataAdapter.Data

Syntax

Data(Attribute: Variant): Variant;

Parameters

Attribute. The parameter determines, which data must be returned by an adapter.

Description

The Data property returns adapter data.

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.

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 data adapter for the label of the Regions map layer is determined. The labels of all the layer areas are displayed in the console window.

See also:

IMapDataAdapter