Programatically alter Polylines/Polygons on TTMSFNCMaps

I need to draw a log of polylines on a TTMSFNCMap. Programatically, I then need to be able to modify the properties of the n-th polyline. In particular, I need to adjust the number and value of the points making up the polyline. I'm guessing that I need to execute TTMSFNCMap.Polylines[n].Coordinates.Clear
and then iteratively add to the TTMSFNCMap.Polylines[n].Coordinates, but I'm not sure how.

I then also need to do the same thing with polygons. (I'm assuming there will be some commonality to the polylines answer)


I've partially answered my own question with relation to polygons, where all polygons on the TTMSFNCMap have a fixed number of points.

Iterating through the TTMSFNCMap.Polygons[n].Coordiantes, I can change the .Latitude and .Longitude values, and then set TTMSFNCMap.Polygons[n].Recreate := TRUE to redraw the polygon. This seems to work, and I trust is a suitable method.

However, I am still battling to understand how to I might change the number of Coordinates in the polygon (or polyline).

(This may be because I have not got an understanding of the TTMSFNCMapsCoordinateItem?)


Coordinates is a collection, so you can add/remove/update items as in any collection.

Thanks Pieter

I obviously need to get to grips with TCollection and such-like!

In the meantime, I found that the following also does the trick, given that I have initially added the number of polygons (or polylines) that I need:

    for p := 0 to Length(polyPoints)-1 do
      map.Polygons[n].Coordinates[p].Latitude := polyPoints[p].latitude;
      map.Polygons[n].Coordinates[p].Longitude := polyPoints[p].longitude;
    map.Polygons[n].Recreate := TRUE;
    map.Polygons[n].Visible := TRUE;

Yep, that should indeed do the trick.