title: Android Mapview Custom marker not working with Picasso
body: <p>I am implementing android Mapview with Custom marker. The custom marker has a background view to which an image is asynchronously loaded. I am using Picasso to load image in to marker view. Here is the code I am using,</p>
  
  <pre><code>for(int i=0;i&lt;10;i++)
          {
  
  
                  // latitude and longitude
                  double latitude = getShop_latitude(i);
                  double longitude = getShop_longitude(i);
  
                  // create marker
                  MarkerOptions marker = new MarkerOptions().position(
                          new LatLng(latitude, longitude)).title("");
                  PicassoMarker pm = new PicassoMarker(marker,getActivity());
  
                  String url = PPConfig.IMAGE_URL + Uri.encode(getPpyOfferIcon(i));
                  Picasso.with(getActivity()).load(url).into(pm);
  
                  // Changing marker icon
  
                  builder.include(marker.getPosition());
  
  
                  // adding marker
                  googleMap.addMarker(marker);
  
          }
  </code></pre>
  
  <p>Here is the class that extends Target
  public class PicassoMarker implements Target {
      private MarkerOptions mMarker;
      private FragmentActivity mActivity;</p>
  
  <pre><code> public PicassoMarker(MarkerOptions marker,FragmentActivity activity) {
          mMarker = marker;
          mActivity = activity;
      }
  
      @Override
      public int hashCode() {
          return mMarker.hashCode();
      }
  
      @Override
      public boolean equals(Object o) {
          if(o instanceof PicassoMarker) {
              MarkerOptions marker = ((PicassoMarker) o).mMarker;
              return mMarker.equals(marker);
          } else {
              return false;
          }
      }
  
      @Override
      public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
          //Load Custom marker view
          View markerView = mActivity.getLayoutInflater().inflate(R.layout.fragment_map_marker,
                  null);
          ImageView image = (ImageView) markerView.findViewById(R.id.markerImage);
          image.setImageBitmap(bitmap);
          RelativeLayout rl = (RelativeLayout)markerView.findViewById(R.id.markerContent);
          rl.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Toast.makeText(view.getContext(), "Clicked", Toast.LENGTH_LONG).show();
              }
          });
          mMarker.icon(BitmapDescriptorFactory
                  .fromBitmap(createDrawableFromView(mActivity, markerView)));
      }
  
      @Override
      public void onBitmapFailed(Drawable errorDrawable) {
      }
  
      @Override
      public void onPrepareLoad(Drawable placeHolderDrawable) {
  
      }
  
      // Convert a view to bitmap
      private Bitmap createDrawableFromView(Context context, View view) {
          DisplayMetrics displayMetrics = new DisplayMetrics();
          mActivity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
          view.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT));
          view.measure(displayMetrics.widthPixels, displayMetrics.heightPixels);
          view.layout(0, 0, 107, 117);
          view.buildDrawingCache();
          Bitmap bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
  
          Canvas canvas = new Canvas(bitmap);
          view.draw(canvas);
  
          return bitmap;
      }
  }
  </code></pre>
  
  <p>But this code is not loading my custom marker view, instead its loading the default marker pin point. Whats going wrong here?</p>
  
  <p>Thanks.</p>