Skip to main content
All docs
V25.1
  • TdxAzureMapReverseGeocodeProviderOnResponse Type

    The procedural type for Azure Maps Reverse Geocode server response events.

    Declaration

    TdxAzureMapReverseGeocodeProviderOnResponse = procedure(ASender: TdxMapControlAzureMapReverseGeocodeProvider; AResponse: TdxAzureMapReverseGeocodeRequestResponse; var ADestroyResponse: Boolean) of object;

    Parameters

    Name Type Description
    ASender TdxMapControlAzureMapReverseGeocodeProvider

    Provides access to the Azure Maps Reverse Geocode information component that raised the server response event.

    AResponse TdxAzureMapReverseGeocodeRequestResponse

    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 [TdxAzureMapReverseGeocodeRequestResponse] class instances manually if you set the ADestroyResponse parameter to False. Otherwise, memory leaks will occur.

    Remarks

    Response events allow you to receive and process a server response after an asynchronous query.

    Code Example: Obtain Map Point Address Asynchronously

    The code example in this section demonstrates a procedure that sends a query to an Azure Maps Reverse Geocode server and an OnResponse event handler that receives and processes the server response.

    uses
      dxAzureMapInformationProviders, // Declares TdxMapControlAzureMapReverseGeocodeProvider
      dxMessageDialog;  // Declares the dxMessageDlg global function
    // ...
    
    procedure TMyForm.AddPushpin(AGeoPoint: TdxMapControlGeoPoint): Boolean;
    var
      APushpin: TdxMapPushpin;
      AQueryParams: IdxAzureMapReverseGeocodeQueryParams;
    begin
      // Creates a new pushpin on an existing map item layer
      APushpin := dxMapControl1ItemLayer1.MapItems.Add(TdxMapPushpin) as TdxMapPushpin;
      APushpin.Location.GeoPoint := AGeoPoint;
      AQueryParams := dxMapControl1AzureMapReverseGeocodeProvider1.CreateQueryParams;
      AQueryParams.Coordinates := APushpin.Location.GeoPoint;
      // Uses a configured reverse geocode provider to send a query to an Azure Maps server
      dxMapControl1AzureMapReverseGeocodeProvider1.ExecuteAsync(AQueryParams);
    end;
    
    procedure TMyForm.dxMapControl1AzureMapReverseGeocodeProvider1Response(
      ASender: TdxMapControlAzureMapReverseGeocodeProvider;
      AResponse: TdxAzureMapReverseGeocodeRequestResponse; var ADestroyResponse: Boolean);
    var
      AMapItems: TdxMapItems;
      APushpin: TdxMapPushpin;
    begin
      AMapItems := dxMapControl1ItemLayer1.MapItems;
      if AResponse <> nil then
      begin
        if AResponse.IsSuccess and (AResponse.Features.Count > 0) then // Checks if the query is successful
        begin
          APushpin := AMapItems.Items[AMapItems.Count - 1] as TdxMapPushpin;
          APushpin.Hint := AResponse.Features.First.Properties.Address.FormattedAddress;
        end
        else if Assigned(AResponse.ErrorInfo) then
          dxMessageDlg(AResponse.ErrorInfo.Message, TMsgDlgType.mtError, [mkOK], 0);
      end;
    end;
    

    Direct TdxAzureMapReverseGeocodeProviderOnResponse Type Reference

    The TdxMapControlAzureMapReverseGeocodeProvider.OnResponse event references the TdxAzureMapReverseGeocodeProviderOnResponse procedural type.

    See Also