Hello,
I’m adding my markers to an InMemoryMarkerOverlay, and applying ValueMarkerStyles to define which icon, a red dot or green dot, will represent each marker. So far it’s working fine, but I’d like to cluster these markers in a way that if any marker in the cluster should be represented by a red dot, the cluster marker is also a red dot; otherwise it’s a green dot. This is the code I’m using to generate the markers (based on another thread I found) -
private InMemoryMarkerOverlay getMarkers()
{
//Create a InMemoryMarkerOverlay with one feature column named "ValueColumn"
InMemoryMarkerOverlay markerOverlay = new InMemoryMarkerOverlay("Markers", new FeatureSourceColumn[] { new FeatureSourceColumn("AlertStatus") });
//Style for 'ok' markers
var okStyle = new PointMarkerStyle()
{
WebImage = new WebImage(@"/Content/MapPins/greendot.png"),
};
//Style for 'alert' markers
var alertStyle = new PointMarkerStyle()
{
WebImage = new WebImage(@"/Content/MapPins/reddot.png"),
};
//Add styles to a valueMarkerStyle, assign to the styles to the respective values.
ValueMarkerStyle valueMarkerStyle = new ValueMarkerStyle("AlertStatus");
valueMarkerStyle.ValueItems.Add(new MarkerValueItem("Ok", okStyle));
valueMarkerStyle.ValueItems.Add(new MarkerValueItem("Alert", alertStyle));
//sample 'ok' marker.
var okMarker = new PointShape(-80, 33).ConverToMeter();
var okMarkerColumnValues = new Dictionary<string, string> { { "AlertStatus", "Ok" } };
//sample 'alert' marker
var alertMarker = new PointShape(-80.1, 33).ConverToMeter();
var alertMarkerColumnValues = new Dictionary<string, string> { { "AlertStatus", "Alert" } };
//add the featueres to the marker overlay
markerOverlay.FeatureSource.BeginTransaction();
markerOverlay.FeatureSource.AddFeature(okMarker, okMarkerColumnValues);
markerOverlay.FeatureSource.AddFeature(alertMarker, alertMarkerColumnValues);
markerOverlay.FeatureSource.CommitTransaction();
//Set CustomMarkerStyle for markerOverlay. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
markerOverlay.ZoomLevelSet.ZoomLevel01.CustomMarkerStyle = valueMarkerStyle;
markerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
//return the overlay, add it to map.customoverlays
return markerOverlay;
}
In addition to that, when the user zooms into a cluster, the markers should show their respective icons (red or green dot, regardless of the cluster’s icon.
Hope it makes sense what I’m trying to accomplish. Any assistance would be appreciated.
Thanks.