vcl-dxazuremapinformationproviders-42ddbe86.md
An Azure Maps Reverse Geocode information provider.
TdxMapControlAzureMapReverseGeocodeProvider = class(
TdxMapControlAzureMapInformationProvider
)
The TdxMapControlAzureMapReverseGeocodeProvider component allows you to use Azure Maps Reverse Geocode servers to obtain information associated with a geographic point on a map (address, postcode, etc.) based on the point’s location on the map (latitude and longitude coordinates).
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.
The list below outlines key members of the TdxMapControlAzureMapReverseGeocodeProvider class. These members allow you to access Azure Maps services and obtain information associated with a point on the map.
AzureKey Required. Specifies the account key required to use the reverse geocode Azure provider.CancelRequestsCancels pending asynchronous queries to Azure Maps Reverse Geocode servers.CreateQueryParamsCreates an information container required to send a query to an Azure Maps Reverse Geocode server.Execute | ExecuteAsyncSend a query created by a CreateQueryParams function call.OnResponseAllows you to receive and process a server response after an asynchronous query.
CollectionProvides access to the parent collection.DisplayNameSpecifies the information provider’s name displayed in the design-time collection editor dialog.IndexSpecifies the information provider’s index in the parent collection.IDReturns the component’s unique identifier.
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;
#include "dxAzureMapInformationProviders.hpp" // Declares all Azure Maps information provider classes
// ...
void __fastcall TMyForm::CreateAzureMapsInformationProviders(const UnicodeString &AAzureKey)
{
TdxMapControlInformationProviders *AProviders;
TdxMapControlAzureMapInformationProvider *AProvider;
AProviders = dxMapControl1->InformationProviders;
AProviders->BeginUpdate(); // Initiates the following batch change
try
{
// Create all Azure Maps information providers
AProviders->Add(__classid(TdxMapControlAzureMapGeocodeProvider));
AProviders->Add(__classid(TdxMapControlAzureMapGeolocationProvider));
AProviders->Add(__classid(TdxMapControlAzureMapReverseGeocodeProvider));
AProviders->Add(__classid(TdxMapControlAzureMapRouteProvider));
for(int i = 0; i < AProviders->Count; i++) // Iterates through all created information providers
{
AProvider = dynamic_cast<TdxMapControlAzureMapInformationProvider*>(AProviders->Items[i]);
AProvider->AzureKey = AAzureKey; // Assigns the same Azure Maps account key to all providers
}
}
__finally
{
AProviders->EndUpdate(); // Calls EndUpdate regardless of the batch operation's success
}
}
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;
#include "dxAzureMapInformationProviders.hpp" // Declares TdxMapControlAzureMapReverseGeocodeProvider
// ...
void __fastcall TMyForm::AddPushpin(TdxMapControlGeoPoint *AGeoPoint)
{
TdxMapPushpin *APushpin;
_di_IdxAzureMapReverseGeocodeQueryParams AParams;
TdxAzureMapReverseGeocodeRequestResponse *AResponse;
// Creates a new pushpin on an existing map item layer
APushpin = dynamic_cast<TdxMapPushpin*>(dxMapControl1ItemLayer1->MapItems->Add(__classid(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 != nullptr) // Checks if a server response is received
{
if((AResponse->IsSuccess) && (AResponse->Features->Count > 0)) // Checks if the query is successful
APushpin->Hint = AResponse->Features->First()->Properties->Address->FormattedAddress;
}
}
__finally
{
delete AResponse; // Deletes the query result response regardless of the operation's success
}
}
TdxMapControlAzureMapGeocodeProviderAn Azure Maps Geocode information provider.TdxMapControlAzureMapGeolocationProviderAn Azure Maps Geolocation information provider.TdxMapControlAzureMapRouteProviderAn Azure Maps Route information provider.
The following public API members reference the TdxMapControlAzureMapReverseGeocodeProvider class as a TdxMapControlInformationProvider object:
TdxMapControlInformationProviders.AddCreates an auxiliary map information provider of the required type and adds the provider to the collection.TdxMapControlInformationProviders.ItemsProvides indexed access to stored map information provider components.
The TdxMapControlInformationProviderClass references the TdxMapControlAzureMapReverseGeocodeProvider 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.
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
TObject TPersistent TComponent TcxCustomComponent TcxComponentCollectionItem TdxMapControlInformationProvider TdxMapControlAzureMapInformationProvider TdxMapControlAzureMapReverseGeocodeProvider
See Also
TdxMapControlAzureMapImageryDataProvider Class