Back to Devexpress

TdxMapControlAzureMapGeocodeProvider.CreateQueryParams Method

vcl-dxazuremapinformationproviders-dot-tdxmapcontrolazuremapgeocodeprovider.md

latest4.0 KB
Original Source

TdxMapControlAzureMapGeocodeProvider.CreateQueryParams Method

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

Declaration

delphi
function CreateQueryParams: IdxAzureMapGeocodeQueryParams;

Returns

TypeDescription
IdxAzureMapGeocodeQueryParams

Stores Azure Maps Geocode query parameters.

|

Remarks

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

Asynchronous Queries and Server Responses

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

Code Example: Obtain Point Coordinates by Address

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:

delphi
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;
cpp
#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;
}

See Also

TdxMapControlAzureMapReverseGeocodeProvider.CreateQueryParams Function

TdxMapControlAzureMapGeocodeProvider Class

TdxMapControlAzureMapGeocodeProvider Members

dxAzureMapInformationProviders Unit