Hello all,
I'm building a dockpane with two datagrids that collect user features from user input in a mapview. I'd like to draw a connection arrow from the selected feature in the origin datagrid to the selected feature in the destination datagrid. I can't understand why sometimes this works, and sometimes it doesn't using the exact same features. The features I'm querying are in an SDE if that matters and I can confirm the Feature is populated when I inspect it. Here's my code for the connection arrow block:
public void drawConnectionArrow()
{
QueuedTask.Run(() =>
{
var mapView = MapView.Active;
Geometry startGeom = SelectedOriginFeature.Feature.GetShape();
Geometry endGeom = SelectedDestinationFeature.Feature.GetShape();
var startPt = MapPointBuilderEx.CreateMapPoint(SelectedOriginFeature.Feature.GetShape().Extent.Center);
var endPt = MapPointBuilderEx.CreateMapPoint(SelectedDestinationFeature.Feature.GetShape().Extent.Center);
List<MapPoint> list = new List<MapPoint>();
list.Add(startPt);
list.Add(endPt);
Polyline polyline = PolylineBuilderEx.CreatePolyline(list, mapView.Map.SpatialReference);
var arrowGraphic = GraphicFactory.Instance.CreateArrowGraphic(polyline, new ArrowInfo());
mapView.AddOverlay(arrowGraphic);
});
}
I added the startGeom/endGeom for testing as it usually fails there to grab the Geometry object from GetShape(). Note sometimes it fails to grab the startGeom, and sometimes it fails to grab the endGeom.
Am I implementing this properly? I've attached a screencap of the error I'm getting back.
Thanks in advance!