Skip to main content
All docs
V25.1
  • TdxMapControlAzureMapGeocodeProvider Class

    An Azure Maps Geocode information provider.

    Declaration

    TdxMapControlAzureMapGeocodeProvider = class(
        TdxMapControlAzureMapInformationProvider
    )

    Remarks

    The TdxMapControlAzureMapGeocodeProvider component allows you to use Azure Maps Geocode services to obtain geographical coordinates (longitude and latitude) of a street address or name of a place.

    VCL Map Control: A Location Search Example

    Azure Maps Account

    To use Microsoft Azure Maps® services, you need to create an Azure Maps account and obtain a key. Assign the account key to the AzureKey property to configure the information provider.

    Main API Members

    The list below outlines key members of the TdxMapControlAzureMapGeocodeProvider class. These members allow you to access Azure Maps services and obtain coordinates of a street address or a place.

    AzureKey
    Required. Specifies the account key required to use the Azure geocode provider.
    CancelRequests
    Cancels pending asynchronous queries to Azure Maps servers.
    CreateQueryParams
    Creates an information container required to send a geocode query to an Azure Maps server.
    Execute | ExecuteAsync
    Send a query created by a CreateQueryParams function call.
    OnResponse
    Allows you to receive and process a server response after an asynchronous query.
    Collection
    Provides access to the parent collection.
    DisplayName
    Specifies the information provider’s name displayed in the design-time collection editor dialog.
    Index
    Specifies the information provider’s index in the parent collection.
    ID
    Returns the component’s unique identifier.

    Code Examples

    Create and Configure Azure Maps Information Providers

    The following code example implements a procedure that accepts an Azure Maps account key, and creates and configures all Azure Maps information provider components:

    uses
      dxAzureMapInformationProviders;  // Declares all Azure Maps information provider classes
    // ...
    
    procedure TMyForm.CreateAzureMapsInformationProviders(const AAzureKey: string);
    var
      AProviders: TdxMapControlInformationProviders;
      AProvider: TdxMapControlAzureMapInformationProvider;
      I: Integer;
    begin
      AProviders := dxMapControl1.InformationProviders;
      AProviders.BeginUpdate;  // Initiates the following batch change
      try
        // Create all Azure Maps information providers
        AProviders.Add(TdxMapControlAzureMapGeocodeProvider);
        AProviders.Add(TdxMapControlAzureMapGeolocationProvider);
        AProviders.Add(TdxMapControlAzureMapReverseGeocodeProvider);
        AProviders.Add(TdxMapControlAzureMapRouteProvider);
        for I := 0 to AProviders.Count - 1 do  // Iterates through all created information providers
        begin
          AProvider := AProviders.Items[I] as TdxMapControlAzureMapInformationProvider;
          AProvider.AzureKey := AAzureKey;  // Assigns the same Azure Maps account key to all providers
        end;
      finally
        AProviders.EndUpdate;  // Calls EndUpdate regardless of the batch operation's success
      end;
    end;
    

    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:

    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;
    

    Other Azure Maps Information Providers

    TdxMapControlAzureMapGeolocationProvider
    An Azure Maps Geolocation information provider.
    TdxMapControlAzureMapReverseGeocodeProvider
    An Azure Maps Reverse Geocode information provider.
    TdxMapControlAzureMapRouteProvider
    An Azure Maps Route information provider.

    Indirect TdxMapControlAzureMapGeocodeProvider Class References

    The following public API members reference the TdxMapControlAzureMapGeocodeProvider class as a TdxMapControlInformationProvider object:

    TdxMapControlInformationProviders.Add
    Creates an auxiliary map information provider of the required type and adds the provider to the collection.
    TdxMapControlInformationProviders.Items
    Provides indexed access to stored map information provider components.

    Direct TdxMapControlAzureMapGeocodeProvider Class Reference

    The TdxMapControlInformationProviderClass references the TdxMapControlAzureMapGeocodeProvider class.

    To see Microsoft Azure Map tile and information providers in action, run the Mapping demo in the VCL Demo Center installed with compiled DevExpress demos. When the demo is opened, it downloads tile data and additional information from Azure Map servers to display a map and build routes between specified points.

    Download: Compiled VCL Demos

    Tip

    Compiled DevExpress demos ship with source code installed in the Public Documents folder (%Public%) for all users (default). You can find all project and source code files for the Map Control demo in the following folder:

    %Public%\Documents\DevExpress VCL Demos\MegaDemos\Product Demos\ExpressMapControl

    See Also