ThinkGeo.com    |     Documentation    |     Premium Support

Clicked points not showing after move in EditOverlay

I’m using an InMemoryInteractiveOverlay to display points from a collection, and when a user presses an “Edit Mode” button, those points are transferred to an EditInteractiveOverlay. The user then clicks on the map, and a point displays with the custom style I’ve created for that overlay. The problem occurs when I move one of the other points on the map, and go back to adding points via map-click. The point no longer displays. When I click “Edit Mode” once more (which triggers a redraw) all points appear (mainly because they get transferred back to an InMemoryInteractiveOverlay).

I also have guaranteed the new point gets the column name and value associated with the custom style for the overlay.

Any thoughts on why points don’t appear after moving a point?

Thanks!
Jamar

Hi Jamar,

Please put your post under our sub community so we can know which product you are using.

And it looks we don’t have a overlay named: InMemoryInteractiveOverlay

Could you please upload a sample so we can reproduce you problem and looks into it to help you.

Regards,

Ethan

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
    }

Hi Jamar,

Thanks for your code and description, but it looks that not be so helpful.

I still don’t understand what’s the problem, you mentioned you add the clicked point into EditOvelay, then you move the point and click again, the point disappear. I think that’s should because you clear the EditOverlay in some of your code, your pasted code only shows you added the point into EditOverlay.

Please view attached sample, which shows add clicked shape into EditOverlay and you can edit it, when you click again, the new feature added into EditOverlay, the old one keep there.

You can modify the sample to reproduce what’s the issue, and please tell us the detail steps.

8757.zip (99.6 KB)

Regards,

Ethan