public override void Clusterize(MapVectorItemCollection sourceItems, MapViewport viewport, bool sourceChanged)
 {
     if (sourceChanged)
     {
         currentItems = ClusterizeImpl(sourceItems);
         Adapter.OnClustered();
     }
 }
        MapVectorItemCollection ClusterizeImpl(MapVectorItemCollection sourceItems)
        {
            // Separate localizable and non localizable items.
            List <MapItem> nonLocalizableItems = new List <MapItem>();
            List <Cluster> clusters            = new List <Cluster>();

            foreach (MapItem item in sourceItems)
            {
                ISupportCoordLocation localizableItem = item as ISupportCoordLocation;
                if (localizableItem != null)
                {
                    clusters.Add(Cluster.Initialize(localizableItem));
                }
                else
                {
                    nonLocalizableItems.Add(item);
                }
            }

            // Arrange initial clusters in increasing order of distance to a closest cluster.
            clusters = Arrange(clusters);

            // Aggregate localizable items.
            while (clusters.Count > ClusterCount)
            {
                MergeCloserstClusters(ref clusters);
            }

            // Convert internal cluster helpers to Map items.
            MapVectorItemCollection clusterRepresentatives = CreateItemsCollection();

            for (int i = 0; i < clusters.Count; ++i)
            {
                Cluster cluster        = clusters[i];
                MapDot  representative = new MapDot()
                {
                    Location = new GeoPoint(cluster.CenterPoint.Y, cluster.CenterPoint.X), Size = 100
                };
                for (int j = 0; j < cluster.Items.Count; ++j)
                {
                    representative.ClusteredItems.Add(cluster.Items[j] as MapItem);
                }
                clusterRepresentatives.Add(representative);
            }
            for (int i = 0; i < nonLocalizableItems.Count; ++i)
            {
                clusterRepresentatives.Add(nonLocalizableItems[i]);
            }
            return(clusterRepresentatives);
        }