I have two sets of locations that I want to mark in different color. I want to be able to switch show/hide of the sets independently. I place markers on two overlays. But it only shows the marker on the overlay added the last. Does my code miss anything or is it not the right approach?
private void Form2_Load(object sender, EventArgs e)
{
winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
winformsMap1.CurrentExtent = new RectangleShape(-155.733, 95.60, 104.42, -81.9);
WorldMapKitWmsDesktopOverlay worldMapKitOverlay = new WorldMapKitWmsDesktopOverlay();
winformsMap1.Overlays.Add(worldMapKitOverlay);
Feature feature;
feature = new Feature(-95.2806, 38.9554);
feature.ColumnValues.Add("Name", "A");
AddMarkerOverlay(feature, 0);
feature = new Feature(0, 0);
feature.ColumnValues.Add("Name", "B");
AddMarkerOverlay(feature, 1);
winformsMap1.Refresh();
}
private void AddMarkerOverlay(Feature newFeature, int image)
{
InMemoryMarkerOverlay markerOverlay = new InMemoryMarkerOverlay();
markerOverlay.MapControl = winformsMap1;
markerOverlay.Columns.Add(new FeatureSourceColumn("Name"));
if (image == 1)
{
markerOverlay.ZoomLevelSet.ZoomLevel01.DefaultPointMarkerStyle.Image = Properties.Resources.ORANGE;
}
else
{
markerOverlay.ZoomLevelSet.ZoomLevel01.DefaultPointMarkerStyle.Image = Properties.Resources.AQUA;
}
markerOverlay.ZoomLevelSet.ZoomLevel01.DefaultPointMarkerStyle.Width = 20;
markerOverlay.ZoomLevelSet.ZoomLevel01.DefaultPointMarkerStyle.Height = 34;
markerOverlay.ZoomLevelSet.ZoomLevel01.DefaultPointMarkerStyle.YOffset = -17;
markerOverlay.ZoomLevelSet.ZoomLevel01.DefaultPointMarkerStyle.ToolTipText = "This is [#Name#].";
markerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
winformsMap1.Overlays.Add(newFeature.ColumnValues["Name"].ToString(), markerOverlay);
markerOverlay.FeatureSource.BeginTransaction();
markerOverlay.FeatureSource.AddFeature(newFeature);
markerOverlay.FeatureSource.CommitTransaction();
}
Thanks
Yi