Hi Uma Harano,
I've pretty much got this working, but the one thing that is causing me problems is the removal of the graphics when I select a new row in my table to add new points. Only the most recently added overlay point gets removed. I'm basically using the same code as from the Geocode sample to do this. Here is my OverlayUtils code:
namespace SAWS_Sewer_Connections
{
class OverlayUtils
{
private static System.IDisposable _overlayObject = null;
public static void RemoveFromMapOverlay(MapView mapView)
{
if (_overlayObject != null)
{
_overlayObject.Dispose();
_overlayObject = null;
}
}
public static void UpdateMapOverlay(ArcGIS.Core.Geometry.MapPoint point, MapView mapView)
{
AddToMapOverlay(point, mapView);
}
public static async void AddToMapOverlay(ArcGIS.Core.Geometry.MapPoint point, MapView mapView)
{
ArcGIS.Core.CIM.CIMPointSymbol symbol = null;
await QueuedTask.Run(() =>
{
symbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB, 5, SimpleMarkerStyle.Square);
});
CIMSymbolReference symbolReference = symbol.MakeSymbolReference();
await QueuedTask.Run(() =>
{
_overlayObject = mapView.AddOverlay(point, symbolReference);
});
}
}
}
And here is the code I run when the selection in my ListView changes:
foreach (var oid in selectedOIDs)
{
var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector();
insp.Load(gsFLayer, oid);
var pointCollection = ((ArcGIS.Core.Geometry.Multipart)insp.Shape).Points;
if (currentSurvey.direction == "U")
{
fromPoint = pointCollection[pointCollection.Count - 1];
}
else
{
fromPoint = pointCollection[0];
}
MapView mapview = MapView.Active;
OverlayUtils.RemoveFromMapOverlay(mapview);
ArcGIS.Core.Geometry.MapPoint connPoint = null;
double theLength = ((ArcGIS.Core.Geometry.Multipart)insp.Shape).Length;
foreach (var currentDetail in lstDetails.Items.OfType<detailItems>())
{
if (currentSurvey.direction == "U")
{
connPoint = ArcGIS.Core.Geometry.GeometryEngine.Instance.QueryPoint((ArcGIS.Core.Geometry.Multipart)insp.Shape, ArcGIS.Core.Geometry.SegmentExtension.NoExtension, theLength - (double)currentDetail.distance, ArcGIS.Core.Geometry.AsRatioOrLength.AsLength);
}
else
{
connPoint = ArcGIS.Core.Geometry.GeometryEngine.Instance.QueryPoint((ArcGIS.Core.Geometry.Multipart)insp.Shape, ArcGIS.Core.Geometry.SegmentExtension.NoExtension, (double)currentDetail.distance, ArcGIS.Core.Geometry.AsRatioOrLength.AsLength);
}
OverlayUtils.UpdateMapOverlay(connPoint, mapview);
}
}
I guess they are all individual objecsts, but is there a way to get RemoveFromMapOverlay to remove everything, not just the last one created??