Back to Devexpress

TdxMapControlAzureMapGeolocationProvider.CreateQueryParams Method

vcl-dxazuremapinformationproviders-dot-tdxmapcontrolazuremapgeolocationprovider.md

latest3.6 KB
Original Source

TdxMapControlAzureMapGeolocationProvider.CreateQueryParams Method

Creates an information container required to send a query to an Azure Maps server.

Declaration

delphi
function CreateQueryParams: IdxAzureMapGeolocationQueryParams;

Returns

TypeDescription
IdxAzureMapGeolocationQueryParams

Stores Azure Maps Geolocation query parameters.

|

Remarks

Call the CreateQueryParams function to create and configure server query parameters before an Execute or ExecuteAsync procedure call.

Asynchronous Queries and Server Responses

To receive and process a response from an Azure Maps server after an ExecuteAsync procedure call, handle the OnResponse event.

Code Example: Obtain Country ISO Code by IP Address

The following code example implements a function that uses a configured information provider to return a country ISO code that corresponds to the specified IP address:

delphi
uses
  dxAzureMapInformationProviders; // Declares TdxMapControlAzureMapGeolocationProvider
// ...

function TMyForm.GetCountryISOCode(const AIPAddress: string): string;
var
  AParams: IdxAzureMapGeolocationQueryParams;
  AResponse: TdxAzureMapGeolocationRequestResponse;
begin
  AParams := dxMapControl1AzureMapGeolocationProvider1.CreateQueryParams;
  AParams.IP := AIPAddress;
  dxMapControl1AzureMapGeolocationProvider1.Execute(AParams, AResponse);
  if AResponse <> nil then
  begin
    if AResponse.IsSuccess then
      AResult := AResponse.CountryRegion.IsoCode
  end;
end;
cpp
#include "dxAzureMapInformationProviders.hpp" // Declares TdxMapControlAzureMapGeolocationProvider
// ...

UnicodeString __fastcall TMyForm::GetCountryISOCode(const UnicodeString &AIPAddress)
{
  _di_IdxAzureMapGeolocationQueryParams AParams;
  TdxAzureMapGeolocationRequestResponse *AResponse;
  UnicodeString AResult;

  AParams = dxMapControl1AzureMapGeolocationProvider1->CreateQueryParams();
  AParams->IP = AIPAddress;
  dxMapControl1AzureMapGeolocationProvider1->Execute(AParams, AResponse);
  if(AResponse != nullptr)
  {
    if(AResponse->IsSuccess)
      AResult = AResponse->CountryRegion->IsoCode;
  }
  return AResult;
}

See Also

TdxMapControlAzureMapGeolocationProvider Class

TdxMapControlAzureMapGeolocationProvider Members

dxAzureMapInformationProviders Unit