Description


Property for working with polygons on the map. Allows you to create/modify/delete polygons on the map.



 Methods and properties

 Description

 function Add: TPolygonItem

 Creates a new polygon object.

 procedure Bounds: TBounds

 Contains the coordinates of the rectangular area in which all polygons are located.

 procedure Clear

 Removes all polygons from the collection. The polygons from the map will not be removed. Use ClearPolygons method to remove polygons simultaneously from the map and TPolygons collection.

 property Count: Integer

 Returns the number of polygons in the collection (TPolygons).

 procedure Delete(Index: Integer)

 Removes the specified polygon from the collection (TPolygons). At that, the polygon will not be deleted from the map. To remove a polygon from the map, use DeleteMapPolygon method.

 property Items[i]: TPolygonItem

 Returns the specified polygon.





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;