TdxMapItems.Add(TdxMapItemClass) Method
In This Article
Creates a map item of the required type and adds the item to the collection.
#Declaration
Delphi
function Add(AMapItemClass: TdxMapItemClass): TdxMapItem;
#Parameters
Name | Type | Description |
---|---|---|
AMap |
Tdx |
The reference to the required map item class. |
#Returns
Type | Description |
---|---|
Tdx |
The created map item. To access all public API members of the created map item, cast the returned object to the corresponding terminal Tdx |
#Remarks
Call the Add
function to create any supported map item and add it to the collection. All created map items are accessible through the Items property.
#Code Example: Display a Map Point Address as a Hint
The following code example implements a procedure that uses a configured information provider component to create a pushpin at the specified point on the map and assign the point’s address to the pushpin hint:
uses
dxAzureMapInformationProviders; // Declares TdxMapControlAzureMapReverseGeocodeProvider
// ...
procedure TMyForm.AddPushpin(AGeoPoint: TdxMapControlGeoPoint);
var
APushpin: TdxMapPushpin;
AParams: IdxAzureMapReverseGeocodeQueryParams;
AResponse: TdxAzureMapReverseGeocodeRequestResponse;
begin
// Creates a new pushpin on an existing map item layer
APushpin := dxMapControl1ItemLayer1.MapItems.Add(TdxMapPushpin) as TdxMapPushpin;
APushpin.Location.GeoPoint := AGeoPoint;
AParams := dxMapControl1AzureMapReverseGeocodeProvider1.CreateQueryParams;
AParams.Coordinates := APushpin.Location.GeoPoint;
// Uses a configured reverse geocode provider to send a query to an Azure Maps server
dxMapControl1AzureMapReverseGeocodeProvider1.Execute(AParams, AResponse);
try
if AResponse <> nil then // Checks if a server response is received
begin
if AResponse.IsSuccess and (AResponse.Features.Count > 0) then // Checks if the query is successful
APushpin.Hint := AResponse.Features.First.Properties.Address.FormattedAddress;
end;
finally
AResponse.Free; // Deletes the query result regardless of the operation's success
end;
end;
See Also