vcl-dxazuremapinformationproviders-dot-tdxmapcontrolazuremapreversegeocodeprovider-dot-execute-x28-idxazuremapreversegeocodequeryparams-tdxazuremapreversegeocoderequestresponse-x29.md
Sends a query to an Azure Maps server and returns the result.
procedure Execute(const AParams: IdxAzureMapReverseGeocodeQueryParams; out AReverseGeocodeResponse: TdxAzureMapReverseGeocodeRequestResponse);
| Name | Type | Description |
|---|---|---|
| AParams | IdxAzureMapReverseGeocodeQueryParams |
Accepts a configured query parameters container.
Call the CreateQueryParams function to create a query parameters container.
| | AReverseGeocodeResponse | TdxAzureMapReverseGeocodeRequestResponse |
Returns a container populated with information returned by a server.
Important
Every Execute procedure call creates a new TdxAzureMapReverseGeocodeRequestResponse class instance.
Call the Free procedure (in Delphi) or use the delete keyword (in C++Builder) to destroy TdxAzureMapReverseGeocodeRequestResponse class instances manually to avoid memory leaks.
|
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.
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;
#include "dxAzureMapInformationProviders.hpp" // Declares TdxMapControlAzureMapReverseGeocodeProvider
// ...
void __fastcall TMyForm::AddPushpin(TdxMapControlGeoPoint *AGeoPoint)
{
TdxMapPushpin *APushpin;
_di_IdxAzureMapReverseGeocodeQueryParams AParams;
TdxAzureMapReverseGeocodeRequestResponse *AResponse;
// Creates a new pushpin on an existing map item layer
APushpin = dynamic_cast<TdxMapPushpin*>(dxMapControl1ItemLayer1->MapItems->Add(__classid(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 != nullptr) // Checks if a server response is received
{
if((AResponse->IsSuccess) && (AResponse->Features->Count > 0)) // Checks if the query is successful
APushpin->Hint = AResponse->Features->First()->Properties->Address->FormattedAddress;
}
}
__finally
{
delete AResponse; // Deletes the query result response regardless of the operation's success
}
}
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.
See Also
TdxMapControlAzureMapReverseGeocodeProvider Class