Hello Marcus,
Sorry you can't get the Marker Id directly by Context menu, the menu is hooked with InMemoryMarkerOverlay not each markers.
Here I wrote a workaround for you, when the menu click event raise, find the nearest marker where your mouse click, then get that marker's id.
Please check the code below:
ContextMenu menu = new ContextMenu();
ContextMenuItem item = new ContextMenuItem("Click me!");
item.Click += new EventHandler<ContextMenuItemClickEventArgs>(item_Click);
menu.MenuItems.Add(item);
void item_Click(object sender, ContextMenuItemClickEventArgs e)
{
InMemoryMarkerOverlay markerOverlay = (InMemoryMarkerOverlay)Map1.CustomOverlays["markers"];
markerOverlay.FeatureSource.Open();
Collection<Feature> clickedMarker = markerOverlay.FeatureSource.GetFeaturesWithinDistanceOf(e.Location, GeographyUnit.Meter, DistanceUnit.Kilometer, 10, ReturningColumnsType.AllColumns);
markerOverlay.FeatureSource.Close();
if (clickedMarker.Count > 0)
{
var id = clickedMarker[0].Id;
}
}
Regards,
Gary