Skip to main content
All docs
V25.1
  • TdxMapControlAzureMapReverseGeocodeProvider.Execute(IdxAzureMapReverseGeocodeQueryParams,TdxAzureMapReverseGeocodeRequestResponse) Method

    Sends a query to an Azure Maps server and returns the result.

    Declaration

    procedure Execute(const AParams: IdxAzureMapReverseGeocodeQueryParams; out AReverseGeocodeResponse: TdxAzureMapReverseGeocodeRequestResponse);

    Parameters

    Name Type Description
    AParams IdxAzureMapReverseGeocodeQueryParams

    Accepts a configured query parameters container.

    Call the CreateQueryParams function to create a query parameters container.

    AReverseGeocodeResponse TdxAzureMapReverseGeocodeRequestResponse

    Returns a container populated with information returned by a server.

    Important

    Every Execute procedure call creates a new TdxAzureMapReverseGeocodeRequestResponse class instance.

    Call the Free procedure (in Delphi) or use the delete keyword (in C++Builder) to destroy TdxAzureMapReverseGeocodeRequestResponse class instances manually to avoid memory leaks.

    Remarks

    Call the Execute procedure to send a reverse geocode query to an Azure Maps server and wait for a response returned as the AReverseGeocodeResponse parameter.

    Code Example: Obtain Map Point Address

    The following code example implements a procedure that uses a configured information provider component to create a pushpin at the specified point on the map and assign the point’s address to the pushpin hint:

    uses
      dxAzureMapInformationProviders;  // Declares TdxMapControlAzureMapReverseGeocodeProvider
    // ...
    
    procedure TMyForm.AddPushpin(AGeoPoint: TdxMapControlGeoPoint);
    var
      APushpin: TdxMapPushpin;
      AParams: IdxAzureMapReverseGeocodeQueryParams;
      AResponse: TdxAzureMapReverseGeocodeRequestResponse;
    begin
      // Creates a new pushpin on an existing map item layer
      APushpin := dxMapControl1ItemLayer1.MapItems.Add(TdxMapPushpin) as TdxMapPushpin;
      APushpin.Location.GeoPoint := AGeoPoint;
      AParams := dxMapControl1AzureMapReverseGeocodeProvider1.CreateQueryParams;
      AParams.Coordinates := APushpin.Location.GeoPoint;
      // Uses a configured reverse geocode provider to send a query to an Azure Maps server
      dxMapControl1AzureMapReverseGeocodeProvider1.Execute(AParams, AResponse);
      try
        if AResponse <> nil then  // Checks if a server response is received
        begin
          if AResponse.IsSuccess and (AResponse.Features.Count > 0) then  // Checks if the query is successful
            APushpin.Hint := AResponse.Features.First.Properties.Address.FormattedAddress;
        end;
      finally
        AResponse.Free;  // Deletes the query result regardless of the operation's success 
      end;
    end;
    

    Asynchronous Queries and Server Responses

    The Execute procedure runs in the main thread and, therefore, locks the application UI until the corresponding server response or a timeout error.

    To keep your UI responsive, you can call the ExecuteAsync procedure instead. Handle the OnResponse event to process a server response when the information provider receives it.

    See Also