TerritoryInfoAdapter: Object;
The TerritoryInfoAdapter property determines the data source for territory info.
Depending on the required info contents this property needs to be adjusted to the one of the following interfaces:
IMapDataAdapter - returned values are setting only the territory identifier in the territory info.
IMapDynamicDataAdapter - returned values are setting the territory identifier and the territory name in the territory info.
Executing the example requires a form with a button named Button1, the UiMap component named UiMap1 and the MapBox component. The map must be connected to the UiMap1 component.
Var Count: Integer;
Class TerritoryInfoAdapter: 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 TerritoryInfoAdapter;
Class TestForm: Form
Button1: Button;
UiMap1: UiMap;
MapBox1: MapBox;
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
Da: TerritoryInfoAdapter;
MapDa: IMapDynamicDataAdapter;
M: IMap;
TerrI: IMapTerritoryInfo;
mLayer: IMapLayer;
mShapes: IMapTopobaseShapes;
mShape: IMapTopobaseShape;
i: integer;
pc: Integer;
Begin
Da := New TerritoryInfoAdapter.Create;
MapDa := da As IMapDynamicDataAdapter;
M := UiMap1.Map;
TerrI := New DxMapTerritoryInfo.Create;
M.View.TerritoryInfo := TerrI;
TerrI.Layer := M.Layers.FindByName("Regions");
mLayer := M.View.TerritoryInfo.Layer;
mShapes := mLayer.Shapes;
For i := 0 To mShapes.Count - 1 Do
mShape := mShapes.Item(i);
pc := MapDa.PartCount(mShape) - 1;
Debug.WriteLine(MapDa.Data(mShape, pc));
End For;
mLayer.TerritoryInfoAdapter := MapDa;
End Sub Button1OnClick;
End Class TestForm;
After executing the example the data source for the territory info is determined. The territory info elements are displayed in the console window.
See also: