vcl-dxazuremapinformationproviders-dot-tdxmapcontrolazuremapgeolocationprovider-3f435ca8.md
Allows you to accept and process responses from an Azure Maps server.
property OnResponse: TdxAzureMapGeolocationProviderOnResponse read; write;
Handle the OnResponse event to receive and process responses from an Azure Maps server after an ExecuteAsync procedure call.
The OnResponse event occurs every time an Azure Maps server sends a response after an ExecuteAsync procedure call.
The following parameters are available within an OnResponse event handler:
ASenderProvides access to the TdxMapControlAzureMapGeolocationProvider component that raised the server response event.AResponseProvides 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 the AResponse parameter.
If this parameter value is True, the container is destroyed once the application exits the current OnResponse event handler. Otherwise, you need to release the container manually.
Refer to the TdxAzureMapGeolocationProviderOnResponse procedural type description for detailed information on all available options.
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);
}
}
}
See Also
TdxMapControlAzureMapGeolocationProvider.Execute Procedure
TdxMapControlAzureMapGeolocationProvider Class