vcl-dxazuremapinformationproviders-60b572eb.md
The procedural type for Azure Maps Geolocation server response events.
TdxAzureMapGeolocationProviderOnResponse = procedure(ASender: TdxMapControlAzureMapGeolocationProvider; AResponse: TdxAzureMapGeolocationRequestResponse; var ADestroyResponse: Boolean) of object;
| Name | Type | Description |
|---|---|---|
| ASender | TdxMapControlAzureMapGeolocationProvider |
Provides access to the Azure Maps Geocode information component that raised the server response event.
| | AResponse | TdxAzureMapGeolocationRequestResponse |
Provides access to a container populated with information returned by a server.
| | ADestroyResponse | Boolean |
Specifies if the response event handler automatically destroys the information container accessible through the AResponse parameter. The event handler creates a new server response information container every time the event occurs.
True Default. The AResponse container is destroyed automatically once the application exits the current event handler. You do not need to manage the response information container manually.False
Use this option if you need to use the returned information container outside the server response event handler.
Important
Call the Free procedure (in Delphi) or use the delete keyword (in C++Builder) to destroy TdxAzureMapGeolocationRequestResponse class instances manualy if you set the ADestroyResponse parameter to False. Otherwise, memory leaks will occur.
|
Response events allow you to receive and process a server response after an asynchronous query.
The code example in this section demonstrates a procedure that sends a query to an Azure Maps Geolocation server and an OnResponse event handler that receives and processes the server response.
uses
dxAzureMapInformationProviders, // Declares TdxMapControlAzureMapGeolocationProvider
dxMessageDialog; // Declares the dxMessageDlg global function
// ...
procedure TMyForm.SendGeolocationQuery(const AIPAddress: string);
var
AQueryParams: IdxAzureMapGeolocationQueryParams;
begin
AQueryParams := dxMapControl1AzureMapGeolocationProvider1.CreateQueryParams;
AQueryParams.IP := AIPAddress;
dxMapControl1AzureMapGeolocationProvider1.ExecuteAsync(AQueryParams);
end;
procedure TMyForm.dxMapControl1AzureMapGeolocationProvider1Response(
ASender: TdxMapControlAzureMapGeolocationProvider;
AResponse: TdxAzureMapGeolocationRequestResponse; var ADestroyResponse: Boolean);
begin
if AResponse <> nil then
begin
if AResponse.IsSuccess then
dxMessageDlg('Country Code: ' + AResponse.CountryRegion.IsoCode, TMsgDlgType.mtInformation, [mbOK], 0);
else if Assigned(AResponse.ErrorInfo) then
dxMessageDlg(AResponse.ErrorInfo.Message, TMsgDlgType.mtError, [mbOK], 0);
end;
end;
#include "dxAzureMapInformationProviders.hpp" // Declares TdxMapControlAzureMapGeolocationProvider
#include "dxMessageDialog.hpp" // Declares the dxMessageDlg global function
// ...
void __fastcall TMyForm::SendGeolocationQuery(const UnicodeString &AIPAddress)
{
_di_IdxAzureMapGeolocationQueryParams AQueryParams;
AQueryParams = dxMapControl1AzureMapGeolocationProvider1->CreateQueryParams();
AQueryParams->IP = AIPAddress;
dxMapControl1AzureMapGeolocationProvider1->ExecuteAsync(AQueryParams);
}
void __fastcall TMyForm::dxMapControl1AzureMapGeolocationProviderResponse(
TdxMapControlAzureMapGeolocationProvider *ASender,
TdxAzureMapGeolocationRequestResponse *AResponse, bool &ADestroyResponse)
{
if(AResponse != nullptr)
{
if(AResponse->IsSuccess)
{
dxMessageDlg("Country Code: " + AResponse->CountryRegion->IsoCode,
TMsgDlgType::mtInformation, TMsgDlgButtons() << mbOK, 0);
}
else if(AResponse->ErrorInfo != nullptr)
{
dxMessageDlg(AResponse->ErrorInfo->Message, TMsgDlgType::mtError, TMsgDlgButtons() << mbOK, 0);
}
}
}
The TdxMapControlAzureMapGeocodeProvider.OnResponse event references the TdxAzureMapGeolocationProviderOnResponse procedural type.
See Also
TdxAzureMapGeocodeProviderOnResponse Procedural Type
TdxAzureMapReverseGeocodeProviderOnResponse Procedural Type