vcl-dxazuremapinformationproviders-dot-tdxmapcontrolazuremapgeocodeprovider-dot-execute-x28-idxazuremapgeocodequeryparams-tdxazuremapgeocoderequestresponse-x29.md
Sends a query to an Azure Maps server and returns the result.
procedure Execute(const AParams: IdxAzureMapGeocodeQueryParams; out AGeocodeResponse: TdxAzureMapGeocodeRequestResponse);
| Name | Type | Description |
|---|---|---|
| AParams | IdxAzureMapGeocodeQueryParams |
Accepts a configured query parameters container.
Call the CreateQueryParams function to create a query parameters container.
| | AGeocodeResponse | TdxAzureMapGeocodeRequestResponse |
Returns a container populated with information returned by a server.
Important
Every Execute procedure call creates a new TdxAzureMapGeocodeRequestResponse class instance.
Call the Free procedure (in Delphi) or use the delete keyword (in C++Builder) to destroy TdxAzureMapGeocodeRequestResponse class instances manually to avoid memory leaks.
|
Call the Execute procedure to send a geocode query to an Azure Maps server and wait for a response returned as the AGeocodeResponse parameter.
The following code example implements a function that uses a configured information provider component to return the point on a map that corresponds to the specified address:
uses
dxAzureMapInformationProviders; // Declares TdxMapControlAzureMapGeocodeProvider
// ...
function TMyForm.GetAddressCoordinates(const AAddress: string): TdxMapControlGeoPoint;
var
AParams: IdxAzureMapGeocodeQueryParams;
AResponse: TdxAzureMapGeocodeRequestResponse;
AGeometry: TGeoJSONGeometry;
begin
AResult := nil;
AParams := dxMapControl1AzureMapGeocodeProvider1.CreateQueryParams;
AParams.Query := AAddress;
dxMapControl1AzureMapGeocodeProvider1.Execute(AParams, AResponse);
if AResponse <> nil then
begin
if AResponse.IsSuccess then
begin
AGeometry := AResponse.Features.First.Geometry;
AResult := TdxMapControlGeoPoint.Create(AGeometry.Coordinates[1], AGeometry.Coordinates[0]);
end;
end;
end;
#include "dxAzureMapInformationProviders.hpp" // Declares TdxMapControlAzureMapGeocodeProvider
// ...
TdxMapControlGeoPoint* __fastcall TMyForm::GetAddressCoordinates(const UnicodeString &AAddress)
{
_di_IdxAzureMapGeocodeQueryParams AParams;
TdxAzureMapGeocodeRequestResponse *AResponse;
TGeoJSONGeometry *AGeometry;
AParams = dxMapControl1AzureMapGeocodeProvider1->CreateQueryParams();
AParams->Query = AAddress;
dxMapControl1AzureMapGeocodeProvider1->Execute(AParams, AResponse);
if(AResponse != nullptr)
{
if(AResponse->IsSuccess)
{
AGeometry = AResponse->Features->First()->Geometry;
return new TdxMapControlGeoPoint(AGeometry->Coordinates[1], AGeometry->Coordinates[0]);
}
}
return nullptr;
}
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
TdxMapControlAzureMapGeocodeProvider Class