OnMarkerClick fires multiple times with 1 click on marker

Hi,
Im using GMap.NET.Core version 2.1.7 with the openstreetmap provider in a WIndows Forms application.

In the app I have added several markers to the map.

When I click a marker and fire the method below it fires multiple times and not just one time.
The number of fires is equal to the number of markers I have added.

What can be wrong? Why is it firing multiple times?

Here is the methods:

private void Import_Poi1_Click(object sender, EventArgs e)
        {        
            var list = new List();
            string name = "Poi1.txt";
            using (var reader = new StreamReader(name))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    line = line.Replace("*",",");

                    string[] str = line.Split(',');

                    var marker = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(
                        new GMap.NET.PointLatLng(Convert.ToDouble(str[1]), Convert.ToDouble(str[2])),
                        GMap.NET.WindowsForms.Markers.GMarkerGoogleType.red_small);
                    marker.ToolTipText = str[0];
                    marker.ToolTip.Fill = Brushes.Blue;
                    marker.ToolTip.Foreground = Brushes.White;
                
                    markersOverlay.Markers.Add(marker);
                    gmap.Overlays.Add(markersOverlay);
                    
                }
            }
            gmap.Update();
            gmap.Refresh();

        }
 private void gMapControl1_OnMarkerClick(GMapMarker item, MouseEventArgs e)
        {

                if (e.Button == MouseButtons.Left && item.IsMouseOver)
                {
                  
                    MessageBox.Show(item.ToolTipText );
                }

            }


3 posts - 2 participants

Read full topic


Ce sujet de discussion accompagne la publication sur https://community.openstreetmap.org/t/onmarkerclick-fires-multiple-times-with-1-click-on-marker/98523