private void GetCoordonnatesPolygonGraphics(Graphic graphic)
{
// Here ????
}
private void AddPolygonGraphics()
{
string coordinateString1 = "130,5.59 118.42,3.92 117.3,23.3 143.2,22.9 130,5.59";
GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
PointCollectionConverter pointConverter = new PointCollectionConverter();
ESRI.ArcGIS.Client.Geometry.PointCollection pointCollection1 =
pointConverter.ConvertFromString(coordinateString1) as ESRI.ArcGIS.Client.Geometry.PointCollection;
ESRI.ArcGIS.Client.Geometry.Polygon polygon1 = new ESRI.ArcGIS.Client.Geometry.Polygon();
polygon1.Rings.Add(pointCollection1);
Graphic graphic = new Graphic()
{
Geometry = mercator.FromGeographic(polygon1),
Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol
};
graphicsLayer.Graphics.Add(graphic);
}
looks like the docs are deprecated
private static ESRI.ArcGIS.Client.Projection.WebMercator mercator = new ESRI.ArcGIS.Client.Projection.WebMercator();
void ShowPolyCoords(Graphic graphic)
{
listBox1.Items.Clear();
var polygon = graphic.Geometry as Polygon;
if (polygon == null) return;
PointCollection points = polygon.Rings[0];
foreach (var point in points)
{
MapPoint pMapPointGeog = (MapPoint)mercator.ToGeographic(point);
listBox1.Items.Add(String.Format("{0:0.00} | {1:0.00}", pMapPointGeog.X, pMapPointGeog.Y));
}
}