Hi David,
That’s because the marker had accept the event and blocked it into map.
Please see this topic which should be helpful: PointMarkerStyle blocks MapClick event?
And as below is my test code:
public class ClickableMarkerOverlay : InMemoryMarkerOverlay
{
public event EventHandler Click;
protected override GeoCollection<Marker> GetMarkersForDrawingCore(RectangleShape boundingBox)
{
var markers = base.GetMarkersForDrawingCore(boundingBox);
foreach (var marker in markers)
{
marker.Click -= Click;
marker.Click += Click;
}
return markers;
}
}
public class DisplayShapeMap : UserControl
{
public DisplayShapeMap()
{
InitializeComponent();
}
private void DisplayMap_Load(object sender, EventArgs e)
{
winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
winformsMap1.CurrentExtent = new RectangleShape(-139.2, 92.4, 120.9, -93.2);
ClickableMarkerOverlay viewLinkMarkerOverlay = new ClickableMarkerOverlay() { Name = "test", MapControl = winformsMap1 };
viewLinkMarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultPointMarkerStyle.Image = Properties.Resources.ThinkGeoLogo;
viewLinkMarkerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
winformsMap1.Overlays.Add(viewLinkMarkerOverlay.Name, viewLinkMarkerOverlay);
Feature vlFeature = new Feature(new PointShape(10, 10));
viewLinkMarkerOverlay.FeatureSource.BeginTransaction();
viewLinkMarkerOverlay.FeatureSource.AddFeature(vlFeature);
viewLinkMarkerOverlay.FeatureSource.CommitTransaction();
winformsMap1.Overlays.MoveToTop(viewLinkMarkerOverlay.Name);
winformsMap1.MapClick += WinformsMap1_MapClick;
winformsMap1.MouseClick += WinformsMap1_MouseClick;
winformsMap1.MouseDown += WinformsMap1_MouseDown;
winformsMap1.MouseUp += WinformsMap1_MouseUp;
winformsMap1.MouseMove += WinformsMap1_MouseMove;
viewLinkMarkerOverlay.Click += ViewLinkMarkerOverlay_Click;
winformsMap1.Refresh();
}
private void ViewLinkMarkerOverlay_Click(object sender, EventArgs e)
{
Debug.WriteLine("Marker clicked!!!!");
}
private void WinformsMap1_MouseMove(object sender, MouseEventArgs e)
{
Debug.WriteLine("MouseMove");
}
private void WinformsMap1_MouseUp(object sender, MouseEventArgs e)
{
Debug.WriteLine("MouseUp");
}
private void WinformsMap1_MouseDown(object sender, MouseEventArgs e)
{
Debug.WriteLine("MouseDown");
}
private void WinformsMap1_MouseClick(object sender, MouseEventArgs e)
{
Debug.WriteLine("MouseClick");
}
private void WinformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e)
{
Debug.WriteLine("MapClick");
}
}
This only implement click event, you should want to implement all other event which you need in the ClickableMarkerOverlay class.
Regards,
Don