Back to Devexpress

TdxMapItem.Hint Property

vcl-dxmapitem-dot-tdxmapitem-cd2627c5.md

latest3.8 KB
Original Source

TdxMapItem.Hint Property

Specifies a map item hint message.

Declaration

delphi
property Hint: string read; write;

Property Value

TypeDescription
string

A hint message.

|

Remarks

Use the Hint property to display a simple hint when a user hovers the mouse pointer over the map item. Alternatively, you can use the ScreenTip property to display an advanced ScreenTip.

Code Example: Display a Map Point Address as a Hint

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:

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

Default Value

The Hint property’s default value is an empty string.

See Also

TdxMapItem.ScreenTip Property

TdxMapItem.TitleOptions Property

TdxMapItem Class

TdxMapItem Members

dxMapItem Unit