The example you gave me it's for customizing the "Large Cluster Symbol".
protected override Graphic OnCreateGraphic(GraphicCollection cluster, MapPoint point, int maxClusterCount) { if (cluster.Count == 1) return cluster[0]; Symbol symbol; if (cluster.Count == 2) symbol = mySymbol2; if (cluster.Count == 3) symbol = mySymbol3; if (cluster.Count == 4) symbol = mySymbol4; ........ else symbol = myLargeSymbol; .........
Thank you for your help...I wait forward to your response.
using System; using System.Windows.Controls; using ESRI.ArcGIS.Client.Symbols; namespace FMH.Shared.XAML.ViewModels.Utilities { internal class ClusterSymbol : MarkerSymbol { //Constructors public ClusterSymbol(int clusterCount) { ControlTemplateFactory factory = new ControlTemplateFactory(); string template = factory.GetClusterControlTemplate(clusterCount); this.ControlTemplate = System.Windows.Markup.XamlReader.Load(template) as ControlTemplate; } public double Size { get; set; } public override double OffsetX { get { return Size / 2; } set { throw new NotSupportedException(); } } public override double OffsetY { get { return Size / 2; } set { throw new NotSupportedException(); } } } }
using System; using System.Windows; using System.Windows.Media; using ESRI.ArcGIS.Client; namespace FMH.Shared.XAML.ViewModels.Utilities { /// <summary> /// Created to customize the FlareClusterer with custom flare out graphics /// </summary> public class ColorClusterer : FlareClusterer { //Constructors public ColorClusterer() { } /// <summary> /// Happens each time clustering changes /// </summary> protected override Graphic OnCreateGraphic(GraphicCollection cluster, ESRI.ArcGIS.Client.Geometry.MapPoint point, int maxClusterCount) { if (cluster.Count == 1) return cluster[0]; //Factory used to get correct Control template for respective number of graphics in cluster, set Hex Colors necessary for each cluster ControlTemplateFactory.Cluster1HexColor = ((Color)Application.Current.Resources[((ClaimStatusColor)(Convert.ToInt32(cluster[0].Attributes["CLM_STAT_ID"]))).ToString()]).ToString(); ControlTemplateFactory.Cluster2HexColor = ((Color)Application.Current.Resources[((ClaimStatusColor)(Convert.ToInt32(cluster[1].Attributes["CLM_STAT_ID"]))).ToString()]).ToString(); if (cluster.Count > 2) ControlTemplateFactory.Cluster3HexColor = ((Color)Application.Current.Resources[((ClaimStatusColor)(Convert.ToInt32(cluster[2].Attributes["CLM_STAT_ID"]))).ToString()]).ToString(); if (cluster.Count > 3) ControlTemplateFactory.Cluster4HexColor = ((Color)Application.Current.Resources[((ClaimStatusColor)(Convert.ToInt32(cluster[3].Attributes["CLM_STAT_ID"]))).ToString()]).ToString(); if (cluster.Count > 4) ControlTemplateFactory.Cluster5HexColor = ((Color)Application.Current.Resources[((ClaimStatusColor)(Convert.ToInt32(cluster[4].Attributes["CLM_STAT_ID"]))).ToString()]).ToString(); if (cluster.Count > 5) ControlTemplateFactory.Cluster6HexColor = ((Color)Application.Current.Resources[((ClaimStatusColor)(Convert.ToInt32(cluster[5].Attributes["CLM_STAT_ID"]))).ToString()]).ToString(); //Internal Class ClusterSymbol overriden to replace Control Template var graphic = new Graphic { Symbol = new ClusterSymbol(cluster.Count), Geometry = point }; graphic.Attributes.Add("Count", cluster.Count); return graphic; } //Enums used to get respective color from Resource Dictionary public enum ClaimStatusColor { ClaimStatusPendingBlueColor = 1, ClaimStatusOpenLightBlueColor = 2, ClaimStatusAdjustedGreenColor = 3, ClaimStatusDeferredYellowColor = 4, ClaimStatusReceivedOrangeColor = 5, ClaimStatusProcessedPurpleColor = 6, ClaimStatusCancelledRedColor = 7, ClaimStatusNODLightPurpleColor = 8 } } }
public void CreateClaimPointsLayer() { _claimsPinLayer = new FeatureLayer(); _claimsPinLayer.Url = "https://" + WebServiceDomain + "/arcgis/rest/services/Claim/myLayer/FeatureLayer/0"; _claimCluster = new ColorClusterer(); _claimsPinLayer.Clusterer = _claimCluster; _claimsPinLayer.ID = "ClaimsPinLayer"; _claimsPinLayer.OutFields.Add("*"); _claimsPinLayer.Visible = true; _claimsPinLayer.InitializationFailed += this.OnClaimsPinLayer_InitializationFailed; _claimsPinLayer.UpdateCompleted += this.OnClaimsPinLayer_UpdateCompleted; _claimsPinLayer.Initialize(); VisibleLayers.Add(_claimsPinLayer); }
I agree with you that might be a built in function but strangly it's the first time I heard about such need.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.