Description


Property for accessing existing polygons on the map. Allows you to change/delete polygons on the map.


 Methods and properties

 Описание

 property BackgroundColor: TColor

 The color of the polygon.

 property BackgroundOpacity: Integer

 The opacity of the polygon. (values: 1-100).

 property BorderColor: TColor

 The border color of the polygon.

 property BorderOpacity: Integer

 The border opacity of the polygon. (values: 1-100).

 property BorderWidth: Integer

 The width of the polygon border in pixels.

 property Bounds: TBounds

 Sets the bounds of a polygon when PolygonType is set to ptRectangle.

 property Center: TLocation

 Sets the latitude/longitude of the center point of the circle when PolygonType is set to ptCircle.

 property Clickable: Boolean

 When set to true, enables clicking on the polygon. If the value is False, then the OnPolygonClick event will not be triggered.

 property Editable: Boolean

 When set to true, the polygon can be edited.

 property Geodesic: Boolean

 When set to true, each edge is rendered as a geodesic. When set to false, render each edge as a straight line.

 property HoverBackgroundColor: TColor

 The color of the polygon when hovered.

 property HoverBorderColor: TColor

 The border color of the polygon when hovered.

 property Path: TPath

 The ordered sequence of coordinates of the polygon that forms a closed loop (when PolygonType is set to ptPath). Paths are closed automatically.

 property Path[i]: TPathItem

 Returns the coordinates of a point by its index. Makes sense if the polygon is PolygonType (PolygonType = ptPath).

 property PathBounds: TBounds

 Returns the coordinates of the rectangular area in which this polygon is located.

 property PolygonType: TPolygonType

 Sets the type of polygon to be rendered. Available values: ptCircle, ptRectangle, ptPath

 property Radius: Integer

 The radius of the polygon in meters. (When PolygonType is set to ptCircle)

 property Tag: Integer

 Allows you to assign a number to a component for your own needs.

 property TagString: string

 The text associated with the polygon (optional). The appearance of the hint can be configured with the PolygonLabel properties. If PolygonLabel.Visible is set to true, this value will be displayed as a hint when hovering the polygon on the map.

 property TagObject: TObject

 Allows you to assign an object to a polygon for your own use.

 property Visible: Boolean

 When set to true, the polygon is shown on the map.

 property Zindex: Integer

 The zIndex compared to other elements on the map.





Example


procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
    PolygonItem: TPolygonItem;
begin
    // Circle
    PolygonItem := Form1.Map1.Polygons.Add;
    PolygonItem.Polygon.BackgroundOpacity := 50;
    PolygonItem.Polygon.BorderWidth := 2;
    // Setting up a polygon with the Circle type
    PolygonItem.Polygon.PolygonType := ptCircle;
    PolygonItem.Polygon.Radius := 10000;
    PolygonItem.Polygon.Center.Latitude := 50;
    PolygonItem.Polygon.Center.Longitude := 2;
    Form1.Map1.CreateMapPolygon(PolygonItem.Polygon);


    // Rectangle
    PolygonItem := Form1.Map1.Polygons.Add;
    PolygonItem.Polygon.BackgroundOpacity := 50;
    PolygonItem.Polygon.BorderWidth := 2;
    //Setting up a polygon with Rectangle type
    PolygonItem.Polygon.PolygonType := ptRectangle;
    PolygonItem.Polygon.Bounds.NorthEast.Latitude := 52;
    PolygonItem.Polygon.Bounds.NorthEast.Longitude := 4;
    PolygonItem.Polygon.Bounds.SouthWest.Latitude := 50;
    PolygonItem.Polygon.Bounds.SouthWest.Longitude := 3;
    Form1.Map1.CreateMapPolygon(PolygonItem.Polygon);


    // Polygons are based on a list of longitude and latitude coordinates
    PolygonItem := Form1.Map1.Polygons.Add;
    PolygonItem.Polygon.BackgroundOpacity := 50;
    PolygonItem.Polygon.BorderWidth := 2;
    //Setting up a polygon
    PolygonItem.Polygon.PolygonType := ptPath;
    PolygonItem.Polygon.Path.Add(50, 2);
    PolygonItem.Polygon.Path.Add(52, 4);
    PolygonItem.Polygon.Path.Add(50, 4);
    Form1.Map1.CreateMapPolygon(PolygonItem.Polygon);


    Form1.Map1.MapZoomTo(Form1.Map1.Polygons.Bounds); // Set the map zoom to fit all existing polygons
end;