TdxMapControlAzureMapGeocodeProvider.OnResponse Event
Allows you to accept and process responses from an Azure Maps server.
#Declaration
property OnResponse: TdxAzureMapGeocodeProviderOnResponse read; write;
#Remarks
Handle the OnResponse
event to receive and process responses from an Azure Maps server after an ExecuteAsync procedure call.
#Event Occurrence
The OnResponse
event occurs every time an Azure Maps server sends a response after an ExecuteAsync procedure call.
#Event Parameters
The following parameters are available within an OnResponse
event handler:
ASender
- Provides access to the TdxMapControlAzureMapGeocodeProvider component that raised the server response event.
AResponse
- Provides access to a container populated with information returned by a server.
ADestroyResponse
Specifies if the
OnResponse
event handler automatically destroys the information container accessible through theAResponse
parameter.If this parameter value is
True
, the container is destroyed once the application exits the currentOnResponse
event handler. Otherwise, you need to release the container manually.
Refer to the TdxAzureMapGeocodeProviderOnResponse procedural type description for detailed information on all available options.
#Code Example: Obtain Point Coordinates by Address Asynchronously
The code example in this section demonstrates a procedure that sends a query to an Azure Maps Geocode server and an OnResponse
event handler that receives and processes the server response. The event handler uses an existing map layer to draw a pushpin at the obtained point coordinates if the query is successful.
uses
dxAzureMapInformationProviders, // Declares TdxMapControlAzureMapGeocodeProvider
dxMessageDialog; // Declares the dxMessageDlg global function
// ...
procedure TMyForm.SendGeocodeQuery(const AAddress: string);
var
AQueryParams: IdxAzureMapGeocodeQueryParams;
begin
AQueryParams := dxMapControl1AzureMapGeocodeProvider1.CreateQueryParams;
AQueryParams.Query := AAddress;
dxMapControl1AzureMapGeocodeProvider1.ExecuteAsync(AQueryParams);
end;
procedure TMyForm.dxMapControl1AzureMapGeocodeProvider1Response(
ASender: TdxMapControlAzureMapGeocodeProvider;
AResponse: TdxAzureMapGeocodeRequestResponse; var ADestroyResponse: Boolean);
var
APushpin: TdxMapPushpin;
begin
if AResponse <> nil then
begin
if AResponse.IsSuccess then // Creates a pushpin at the obtained position if the query is successful
begin
APushpin := dxMapControl1ItemLayer1.MapItems.Add(TdxMapPushpin) as TdxMapPushpin;
APushpin.Location.GeoPoint.Longitude := AResponse.Features.First.Geometry.Coordinates[0];
APushpin.Location.GeoPoint.Latitude := AResponse.Features.First.Geometry.Coordinates[1];
end
else if Assigned(AResponse.ErrorInfo) then
dxMessageDlg(AResponse.ErrorInfo.Message, TMsgDlgType.mtError, [mbOK], 0);
end;
end;