Is there any way to move the center (centroid) of a circle/polygon to a new X/Y on the map, such as the current mouse location in C# using the ArcGIS Pro SDK?
I have a solution that I found that builds a buffer polygon using GeometryEngine.Instance.GeodesicBuffer
. It takes a point, a radius, and linear units and outputs a polygon. The results are exactly what I need, but unfortunately I have to call it on every mouse move. This causes too much overhead, because the method is very slow and the polygon drags behind the mouse. I should be able to create the geodesic buffer (polygon) once on an initial button click and then just move that buffer (polygon) at its centroid to a new location on the mouse move. However, I still cannot do this.
The following is some code that I am using to create the buffer. I just need to plug in a moue point on the buffer to center it.
System.Drawing.Point currentLoc = System.Windows.Forms.Control.MousePosition;
MapPoint mapPt = MapView.Active.ScreenToMap(new Point(currentLoc.X, currentLoc.Y));
ArcGIS.Core.Geometry.Geometry buffer = GeometryEngine.Instance.GeodesicBuffer(mapPt, _graphics[i].Radius, GetLinearUnits(_graphics[i].Units));
if (_graphics[i].Graphic == null)
{
_graphics[i].Graphic = MapView.Active.AddOverlay(buffer, _graphics[i].Symbol);
}
else
{
MapView.Active.UpdateOverlay(_graphics[i].Graphic, buffer, _graphics[i].Symbol);
}