Sorry Ethan, my message was a bit cryptic, and I’ve change the implementation a bit. I’m posting the code below. It’s function I call from a click handler for the mapcontrol. It essentially 1. determines the data source to add the clicked point to, 2. adds the point to the EditOverlay for the mapcontrol, and 3. refreshes the map. This code works when you only click on the map: a point appears where you clicked. However, if you move a point and return to clicking on the map, you no longer see points where you clicked.
Let me know if there’s more you need.
Thanks!
private void AddPointClickToSource(double screenX, double screenY)
{
PointSource pointSource = null;
LineSource lineSource = null;
string sourcePrefix = null;
PointShape clickedPointShape = ExtentHelper.ToWorldCoordinate(m_mapControl.CurrentExtent, (float)screenX, (float)screenY,
m_mapControl.Width, m_mapControl.Height);
m_lockMap = true;
switch (MapFeatureType)
{
case (MapFeatureType.POINT_SET):
pointSource = PointSets.FirstOrDefault();
if (pointSource == null) return;
pointSource.AddPointToPointSource(clickedPointShape.X, clickedPointShape.Y, clickedPointShape.Id);
sourcePrefix = POINT_SOURCE_PREFIX;
case (MapFeatureType.LINES):
lineSource = LineSets.FirstOrDefault();
IMapLine line = lineSource?.Lines.FirstOrDefault();
if (line == null) return;
line.AddPointToLineSource(clickedPointShape.X, clickedPointShape.Y, clickedPointShape.Id);
sourcePrefix = POINTS_IN_LINE_SOURCE_PREFIX;
default:
break;
}
IMapFeature source;
if (pointSource == null)
source = lineSource;
else
source = pointSource;
string overlayKey = GetUniqueId(source, sourcePrefix);
Feature pointFeature = new Feature(clickedPointShape);
pointFeature.ColumnValues["Type0"] = overlayKey; // There is a column value "Type0" already present in the EditOverlay.EditShapesLayer
m_mapControl.EditOverlay.EditShapesLayer.InternalFeatures.Add(DateTime.Now.Ticks.ToString(), pointFeature);
m_lockMap = false;
AddPointsAndLinesToDisplay(); // It's like a refresh operation
}