Problem about remove marker

Apr 26, 2010 at 5:38 AM

I use bellow code to add markers and remove markers:

GMapMarker CurrentMarker = null;
GMapOverlay objects = new GMapOverlay(MainMap, "objects");
MainMap.Overlays.Add(objects);

void MainMap_OnMarkerLeave(GMapMarker item)
{
     CurrentMarker = null;
}

void MainMap_OnMarkerEnter(GMapMarker item)
{
    CurrentMarker = item;
}

void MainMap_MouseClick(object sender, MouseEventArgs e)
{
            if (e.Button == MouseButtons.Left)
            {
                GMapMarker newMarker = new GMapMarkerGoogleGreen(MainMap.FromLocalToLatLng(e.X, e.Y));
                newMarker.Size = new System.Drawing.Size(20, 34);
                if (newMarker != null)
                {
                    objects.Markers.Add(newMarker);
                }
            }
            else if (e.Button == MouseButtons.Middle)
            {
                if (CurrentMarker != null)
                {
                    objects.Markers.Remove(CurrentMarker);
		    CurrentMarker = null;
                }
            }
        }

I add one marker in the map, and then use the middle mouse button to remove it. After remove the marker, I use the right mouse button
to drag the map, but it doesn't work now, also the zoom out/zoom in function.

When read the source code, I found the answer: when remove a marker the Map's "IsMouseOverMarke" property doesn't reset to "false".
So Change the code to

else if (e.Button == MouseButtons.Middle)
            {
                if (CurrentMarker != null)
                {
                    objects.Markers.Remove(CurrentMarker);
		    CurrentMarker = null;

                    Cursor = System.Windows.Forms.Cursors.Default;
                    MainMap.IsMouseOverMarker = false;
                }
            }

I didn't find how to add this two line "Cursor = System.Windows.Forms.Cursors.Default; MainMap.IsMouseOverMarker = false;"  to the Source code.
Can you check it?

Sorry for my bad English!  :)

Coordinator
Apr 26, 2010 at 6:57 AM

Great! I've just fixed it, you can check the demo, using delete now you can delete the marker