IMapVisual.DataAdapter

Syntax

DataAdapter: Object;

Description

The DataAdapter property determines an indicator data source.

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 repository should contain a map with the USA identifier. The VisualDataAdapter class implements a dynamic data source.

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

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

Var Count: Integer;

Class VisualDataAdapter: Object, IMapDynamicDataAdapter
    
        Function Get_PartCount(Attribute: Variant; TimePoint: Integer): Integer;
        Begin
            Return Count;
        End Function Get_PartCount;
        
        Function Get_TimePointName(TimePoint: Integer): String;
        Begin
            Return "TimePoint " + TimePoint.ToString;
        End Function Get_TimePointName;
        
        Function Get_TimePointsCount: Integer;
        Begin
            Return 4;
        End Function Get_TimePointsCount;
                
        Function Get_Data(Attribute: Variant; PartvIndex: Integer; TimePoint: Integer): Variant;
        Var t: Integer;
            i: Integer;
        Begin
            t := 1;
            For i := 0 To TimePoint Do
                t := t + 10;
            End For;
            Return Math.Rand * 10 * t;
        End Function Get_Data;

        Function Get_CustomFormat: String;
        Begin
            Return "#0,000";
        End Function Get_CustomFormat;
        
End Class VisualDataAdapter;

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    Map: IMap;
    Layer: IMapLayer;
    BarVisual: IMapBarVisual;
Begin
    UiMap1.Map.Topobase := MetabaseClass.Active.ItemById("USA").Bind As IMapTopobase;
    // Determine a map
    Map := UiMap1.Map;
    // Find layer by name
    Layer := Map.Layers.FindByName("Regions");
    // Add a bar indicator
    BarVisual := Layer.Visuals.AddBarVisual;
    // Stop indicator rendering
    BarVisual.BeginUpdate;
    // Determine indicator data adapter
    BarVisual.DataAdapter := New VisualDataAdapter.Create As IMapDynamicDataAdapter;
    // Set indicator binding attribute name
    BarVisual.AttributeName := "Id";
    // Set indicator name
    BarVisual.Name := "Bar0";
    // Set width of indicator parts
    BarVisual.Width.Value := 4;
    // Resume indicator rendering
    BarVisual.EndUpdate;
End Sub Button1OnClick;

After executing the example the bar indicator named Bar0 is added to the Regions layer. While the indicator is being added its rendering is paused.

See also:

IMapVisual