2

I am using MapCustomClustering to show images on the map. The Cluster Icon also shows the number of items in the cluster but it doesn't show in mine. I am loading data from Parse cloud. The example one renders cluster.getSize() but in mine it doesn't work.

  @Override
    protected void onBeforeClusterRendered(final Cluster<MapPosts> cluster, final MarkerOptions markerOptions) {
        // Draw multiple people.
        // Note: this method runs on the UI thread. Don't spend too much time in here (like in this example).
        final List<Drawable> profilePhotos = new ArrayList<>(Math.min(4, cluster.getSize()));
        final int width = mDimension;
        final int height = mDimension;
        int i = 0;
        for (MapPosts p : cluster.getItems()) {
            // Draw 4 at most.
            i++;
            Picasso.with(getApplicationContext())
                    .load(String.valueOf(p.profilePhoto))
                    .into(new Target() {
                        @Override
                        public void onBitmapLoaded(final Bitmap bitmap, Picasso.LoadedFrom from) {
                            Drawable drawable = new BitmapDrawable(getResources(), bitmap);
                            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(String.valueOf(cluster.getSize()));
                            markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon));
                        }

                        @Override
                        public void onBitmapFailed(Drawable errorDrawable) {
                        }

                        @Override
                        public void onPrepareLoad(Drawable placeHolderDrawable) {

                        }
                    });
            if (profilePhotos.size() == 4) break;
        }

    }

Example

Mine

Savita
  • 747
  • 1
  • 7
  • 16

1 Answers1

1

I found the answear :-) -> Make sure you have some TextView like this in your icon style! The IMPORTANT POINT is you name it "text" !!!

    <TextView
    **android:id="@id/text"**
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/holo_green_dark"
    android:paddingLeft="@dimen/custom_profile_padding"
    android:paddingRight="@dimen/custom_profile_padding"
    android:layout_gravity="center"
    android:alpha=".8"/>
Johannes Knust
  • 891
  • 1
  • 11
  • 18
  • hey john where I am going to get this text view because it is defined dynamically at the run time as it cant be changed because it is a decompiled class file . – Nikhil Singh Jan 19 '17 at 06:28