Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TdxMapPushpin Class

A map pushpin.

#Declaration

Delphi
TdxMapPushpin = class(
    TdxMapPointer
)

#Remarks

A map pushpin marks a point on a map. Map pushpins can display a label, image, and hint.

VCL Map Control: An Address Hint Example

#Main API Members

The list below outlines key members of the TdxMapPushpin class. These members allow you to position a pushpin on a map item layer.

#Appearance Settings

Style | StyleHot | StyleSelected
Specify map pushpin appearance settings in different states.

#Content Settings

Hint | ScreenTip
Allow you to assign a hint or ScreenTip to the map pushpin.
Image | ImageOrigin
Allow you to load and position an image within the map pushpin.
Location
Specifies the pushpin position on the map.
Text
Specifies the pushpin caption.

#General-Purpose API Members

Attributes
Allows you to associate the pushpin with custom values.
Selected
Specifies if the map pushpin is selected.
Visible
Specifies if the map pushpin is visible.

#Map Pushpin Creation

To create a map pushpin, you can call one of the following functions of a map item layer and pass a reference to the TdxMapPushpin class as a parameter:

AddItem
Creates a map item of a specified type and appends it to the layer’s MapItems collection.
MapItems.Add
Creates a map item of the required type and adds the item to the collection.

#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:

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;
See Also