Exemple #1
0
            //protected override void OnClusterUpdated(ICluster cluster, Marker marker)
            //{
            //    // Same implementation as onBeforeClusterRendered() (to update cached markers)
            //    marker.SetIcon(getClusterIcon(cluster));
            //}

            /**
             * Get a descriptor for multiple people (a cluster) to be used for a marker icon. Note: this
             * method runs on the UI thread. Don't spend too much time in here (like in this example).
             *
             * @param cluster cluster to draw a BitmapDescriptor for
             * @return a BitmapDescriptor representing a cluster
             */
            private BitmapDescriptor getClusterIcon(ICluster cluster)
            {
                List <Drawable> profilePhotos = new List <Drawable>(Math.Min(4, cluster.Size));
                int             width         = mDimension;
                int             height        = mDimension;

                foreach (Person p in cluster.Items)
                {
                    // Draw 4 at most.
                    if (profilePhotos.Count == 4)
                    {
                        break;
                    }
                    Drawable drawable = context.Resources.GetDrawable(p.profilePhoto);
                    drawable.SetBounds(0, 0, width, height);
                    profilePhotos.Add(drawable);
                }
                MultiDrawable multiDrawable = new MultiDrawable(profilePhotos);

                multiDrawable.SetBounds(0, 0, width, height);

                mClusterImageView.SetImageDrawable(multiDrawable);
                Bitmap icon = mClusterIconGenerator.MakeIcon(cluster.Size.ToString());

                return(BitmapDescriptorFactory.FromBitmap(icon));
            }
            protected override void OnBeforeClusterRendered(ICluster p0, MarkerOptions p1)
            {
                List <Drawable> photos = new List <Drawable>(System.Math.Min(4, p0.Size));
                int             width  = dimension;
                int             height = dimension;

                foreach (var person in p0.Items)
                {
                    if (photos.Count == 4)
                    {
                        return;
                    }
                    var      p        = person as Person;
                    Drawable drawable = context.GetDrawable(p.Photo);
                    drawable.SetBounds(0, 0, width, height);
                    photos.Add(drawable);
                }

                MultiDrawable multiDrawable = new MultiDrawable(photos);

                multiDrawable.SetBounds(0, 0, width, height);
                clusterImageView.SetImageDrawable(multiDrawable);
                Bitmap icon = clusterIconGenerator.MakeIcon(p0.Size.ToString());

                p1.SetIcon(BitmapDescriptorFactory.FromBitmap(icon));
            }