How to get the coordinate of a specific MapPoint from a collectionPoint ?

451
1
08-08-2017 08:42 AM
ManelKEDDAR
New Contributor III

Hi,

I need to get the coordinate the first MapPoint of my collectionPoint , i found collectionPoint.GetPoint(int index , out double x , out double y) but i don't how to use this method ?any one can show me how to do that please !

thanks

0 Kudos
1 Reply
MatveiStefarov
Esri Contributor

PointCollection.GetPoint(…) uses out parameters to return multiple values at the same time. Here's how you can use it:

double x, y;
myPointCollection.GetPoint(0, out x, out y);

// Now "x" and "y" hold your coordinates:
Debug.WriteLine("X=" + x);
Debug.WriteLine("Y=" + y);

If your geometry uses geographic coordinates, then x is longitude and y is latitude.

Alternatively you can get coordinate as a MapPoint, similarly to how you access items in an array:

MapPoint myPoint = myPointCollection[0];

// Now myPoint holds a copy of the coordinate
Debug.WriteLine("X=" + myPoint.X);
Debug.WriteLine("Y=" + myPoint.Y);

Note that if you are working with a large number of points, GetPoint(…) will perform better than the second approach.

0 Kudos