android - Google Maps Cluster Item Marker Icon with Picasso -


i'm using google map sdk 7.3.0 android-maps-utils 0.3.4 because need clusters markers on map.

my map

ok, here problem is, shouldn't have red marker. green+blue markers. subclassed defaultclusterrenderer create custom marker view doesn't work.

i'm using picasso green icon because it's coming api. problem is, when picasso has loaded bitmap it's late, icon has been set default 1 (red).

here's onbeforeclusteritemrenderer :

            picasso.with(getapplicationcontext()).load(item.url).into(new target() {             @override             public void onbitmaploaded(bitmap bitmap, picasso.loadedfrom from) {                 framelayout icon = (framelayout) layoutinflater.from(getapplicationcontext()).inflate(r.layout.marker, null);                 if (build.version.sdk_int >= build.version_codes.jelly_bean) {                     icon.findviewbyid(r.id.bg).setbackground(new bitmapdrawable(getresources(), bitmap));                 } else {                     icon.findviewbyid(r.id.bg).setbackgrounddrawable(new bitmapdrawable(getresources(), bitmap));                 }                   bitmap b = createdrawablefromview(home.this, icon);                  if (marker != null) {                     marker.icon(bitmapdescriptorfactory.frombitmap(b));                 }             }              @override             public void onbitmapfailed(drawable errordrawable) {              }              @override             public void onprepareload(drawable placeholderdrawable) {              }         }); 

--- edited ---

when downloading image inside onbeforeclusteritemrendered downloading image every time cluster manager tries load marker, if have, example, 100 markers download image 100 times.

you should download image inside oncreate, save in static variable, call mclustermanager.cluster(); after saving image, , inside onbeforeclusteritemrendered wrtie marker.icon(bitmapdescriptorfactory.frombitmap(youractivity.b));


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -