I would like to remove a polygon from polygon collection. Can I use DeleteAt method to do that? Do I need to call dispose() first before I delete the polygon?
If I delete a polygon by its index, is the polygon collection size automatically changed and all remaining polygon index will be re-caculated?
The same question applied to coordinates. I am using C++ builder and would like to find the efficient and safe way to delete polygons and coordiantes.
Thanks!
Hi,
You can use both Delete
or Destroy
to remove Polygons
from the map and from the Polygons collection
.
Example:
TMSFNCMaps1.Polylines[Index].Destroy;
//or
TMSFNCMaps1.Polylines.Delete(Index);
To remove specific coordinates from a Polygon
, you can use the Destroy
call in combination with Recreate
and BeginUpdate/EndUpdate
.
Example:
TMSFNCMaps1.BeginUpdate;
TMSFNCMaps1.Polylines[Index].Coordinates[Index].Destroy;
TMSFNCMaps1.Polylines[Index].Recreate := True;
TMSFNCMaps1.EndUpdate;
Hi,
Thanks for the quick reply!
When I use destroy or delete method to remove a polygon from a polygon collection, does that method free memory for me?
After the polygon/coordinate is removed, will the index of remaining polygon/coordinates re-calculated since the collection size reduces?
Thanks again!
Utilizing the Destroy
method will remove the Polygon
/Coordinate
from the collection, and the indexes will be updated accordingly. This process should also free up the associated memory.
This doesn't seem to work. I had to use Delete(index) instead of using Destroy.