Hello Vicky,
We have two ways to deal with large numbers of markers.
One way is add the markers to high zoomlevel to prevent load all markers at the beginning. For example, zoomlevel1-10, show your inmemoryfeaturelayer, and zoomlevel 11-20 show your markers, just make sure at the first time of map load, doesn't load the zoomlevel of your markers exist.
Here is some code you can see:
InMemoryMarkerOverlay markerOverlay = new InMemoryMarkerOverlay();
Marker marker = new Marker(-118, 30);
marker.WebImage = new WebImage("../../theme/default/samplepic/circle.png");
markerOverlay.Features.Add("Feature1", new Feature(-118, 30));
markerOverlay.ZoomLevelSet.ZoomLevel11.DefaultMarkerStyle.WebImage.ImageWidth = 21;
markerOverlay.ZoomLevelSet.ZoomLevel11.DefaultMarkerStyle.WebImage.ImageHeight = 25;
markerOverlay.ZoomLevelSet.ZoomLevel11.DefaultMarkerStyle.WebImage.ImageOffsetX = -10.5f;
markerOverlay.ZoomLevelSet.ZoomLevel11.DefaultMarkerStyle.WebImage.ImageOffsetY = -25f;
markerOverlay.ZoomLevelSet.ZoomLevel11.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
Then you just need to make sure your Map.CurrentExtent is not in the zoomlevel 11-20, otherwise ,improve your zoomlevel to 15-20 etc.
Another way is use the Inmemoryfeaturelayer simulate the marker, use InmemoryFeatureLayer + Click event to make this.
First create the InMemoryFeatureLayer and set it's default pointshape style as same as your marker image.
private void DisplayMap_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);
InMemoryFeatureLayer inmemoryFeatureLayer = new InMemoryFeatureLayer();
inmemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(new GeoImage(Properties.Resources.AQUA));
inmemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
LayerOverlay markerOverlay = new LayerOverlay();
markerOverlay.Layers.Add(inmemoryFeatureLayer);
winformsMap1.Overlays.Add("MarkerOverlay", markerOverlay);
winformsMap1.Refresh();
}
Then, the Click event to help you find the marker and do something.
private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e)
{
LayerOverlay markerOverlay = (LayerOverlay)winformsMap1.Overlays["MarkerOverlay"];
InMemoryFeatureLayer inmemoryFeatureLayer = markerOverlay.Layers[0] as InMemoryFeatureLayer;
inmemoryFeatureLayer.InternalFeatures.Clear();
MultipolygonShape buffer = e.WorldLocation.Buffer(350, GeographyUnit.DecimalDegree, DistanceUnit.Kilometer);
Collection<Feature> clickedMarker = inmemoryFeatureLayer.QueryTools.GetFeaturesWithin(buffer, ReturningColumnsType.NoColumns);
if (clickedMarker.Count > 0)
{
Collection<Feature> features = winformsMap1.FindFeatureLayer("WorldLayer").FeatureSource.GetFeaturesNearestTo(new PointShape(e.WorldLocation.X, e.WorldLocation.Y), GeographyUnit.DecimalDegree, 10, ReturningColumnsType.AllColumns);
//do anything you want to do, like hight it, change the color, show some tooltip.
}
winformsMap1.Refresh();
}
I hope this can help you.
Regards,
Gary