/// <summary> /// create a new circle geometry, which is polygon, depending on the given center and radius /// http://newnaw.com /// </summary> /// <param name="ptCenter">center of the newly created circle.</param> /// <param name="dRadius">radius of the newly created circle, in screen pixel.</param> /// <param name="n">precision, represents how many point does the return polygon have. These points are symmetrily located. /// if n=0, then transfer to default precision which n=32</param> /// <param name="map">the map control, used for converting mappoint to screenpoint and vice versa.</param> /// <returns>a polygon geometry simulate a circle</returns> public static Polygon createCirclePolygon(MapPoint ptCenter, double dRadius, int n,ESRI.ArcGIS.Client.Map map) { PointCollection pc = new PointCollection(); System.Windows.Point ptCenterScreen = map.MapToScreen(ptCenter); n = n <= 0 ? 32 : n; for (int i = 0; i < n; i++) { //ecah point on the circle, counterclockwise double angle = (Math.PI * 2) / n * i; System.Windows.Point p = new System.Windows.Point() { X = ptCenterScreen.X + dRadius * Math.Cos(angle), Y = ptCenterScreen.Y + dRadius * Math.Sin(angle) }; pc.Add(map.ScreenToMap(p)); }; //add the last, which is exact the first, point. pc.Add(map.ScreenToMap(new System.Windows.Point() { X=ptCenterScreen.X+dRadius, Y=ptCenterScreen.Y })); Polygon polyg = new Polygon() { SpatialReference=map.SpatialReference }; polyg.Rings.Add(pc); return polyg; }
What does Map.SpatialReference.WKID return after the map has loaded?This sample app has a radius measure tool that works if your map is in geographic coordinates:http://resources.esri.com/arcgisserver/apis/silverlight/index.cfm?fa=codeGalleryDetails&scriptID=16504
What is the spatial reference of your map?
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.