ThinkGeo.com    |     Documentation    |     Premium Support

Accessing features on the trackoverlay

Hi,


 


I wish to create various shapes as a layer on my map, i've seen the example TrackAndEditShapes where shapes are added to the trackoverlay, what i now wish to do is access the shapes that that have been drawn.


I tried to loop through the WinformsMap1.TrackOverlay.TrackShapeLayer.InternalFeatures but couldn't figure out which object is being referencing in the loop?


I effectively want to access each object, get it's area value and then store this in a database so i can re-plot is again.


is this possible?


Can anyone help with this please?


Thanks


Aaron



Aaron,


Thanks for your post.
 
Following code snippet shows you how to get the area for the tracked area type shapes.

foreach (Feature feature in winformsMap1.TrackOverlay.TrackShapeLayer.InternalFeatures)
{
    BaseShape baseshape = feature.GetShape();
    if (baseshape is AreaBaseShape)
    {
        double area = ((AreaBaseShape)(baseshape)).GetArea(GeographyUnit.DecimalDegree, AreaUnit.SquareKilometers);
    }
 
    winformsMap1.EditOverlay.EditShapesLayer.InternalFeatures.Add(feature);
}

 
If you want to store those features in to SQL or shape file, you have to create a table (or shape file) first and edit it by adding those features in.
 
Any more questions just feel free to let me know.
 
Thanks.
 
Yale