Hi, following the samples in the downloaded code I wrote some code that lets users add markers.Users can delete the markers by clicking on them. But the code is not working. Click event handler is never entered... The code is shown below...
private void UserControl1_Load(object sender, EventArgs e)
{
winformsMap1.MapClick += new EventHandler<MapClickWinformsMapEventArgs>(winformsMap1_MapClick);
winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
winformsMap1.CurrentExtent = new RectangleShape(-155.733, 95.60, 104.42, -81.9);
WorldMapKitWmsDesktopOverlay worldMapKitOverlay = new WorldMapKitWmsDesktopOverlay();
winformsMap1.Overlays.Add(worldMapKitOverlay);
SimpleMarkerOverlay markerOverlay = new SimpleMarkerOverlay();
markerOverlay.MapControl = winformsMap1;
winformsMap1.Overlays.Add("MarkerOverlay", markerOverlay);
winformsMap1.Refresh();
}
private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e)
{
SimpleMarkerOverlay markerOverlay = (SimpleMarkerOverlay)winformsMap1.Overlays["MarkerOverlay"];
Marker marker = new Marker(e.WorldLocation);
marker.Image = Properties.Resources.AQUA;
marker.Width = 20;
marker.Height = 34;
marker.XOffset = -10;
marker.YOffset = -34;
marker.Click += new EventHandler(marker_Click);
markerOverlay.Markers.Add(marker);
winformsMap1.Refresh();
}
void marker_Click(object sender, EventArgs e)
{
SimpleMarkerOverlay markerOverlay = (SimpleMarkerOverlay)winformsMap1.Overlays["MarkerOverlay"];
markerOverlay.Markers.Remove(sender as Marker);
}