TdxMapControlAzureMapReverseGeocodeProvider.Execute(IdxAzureMapReverseGeocodeQueryParams,TdxAzureMapReverseGeocodeRequestResponse) Method
Sends a query to an Azure Maps server and returns the result.
#Declaration
procedure Execute(const AParams: IdxAzureMapReverseGeocodeQueryParams; out AReverseGeocodeResponse: TdxAzureMapReverseGeocodeRequestResponse);
#Parameters
Name | Type | Description |
---|---|---|
AParams | Idx |
Accepts a configured query parameters container. Call the Create |
AReverse |
Tdx |
Returns a container populated with information returned by a server. Important Every Call the Free procedure (in Delphi) or use the |
#Remarks
Call the Execute
procedure to send a reverse geocode query to an Azure Maps server and wait for a response returned as the AReverseGeocodeResponse
parameter.
#Code Example: Obtain Map Point Address
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;
#Asynchronous Queries and Server Responses
The Execute
procedure runs in the main thread and, therefore, locks the application UI until the corresponding server response or a timeout error.
To keep your UI responsive, you can call the ExecuteAsync procedure instead. Handle the OnResponse event to process a server response when the information provider receives it.