How can I create an onTap() event for the GroundOverlay in Android Google Maps API V2?

512 Views Asked by At

I am migrating from Google maps API v1 to V2. I am looking for an implementation similar to my old code.

OLD CODE:

public class UsingOverlaysForMarkers extends ItemizedOverlay<OverlayItem> {

private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
Context mContext;


public UsingOverlaysForMarkers(Drawable defaultMarker) {
    super(boundCenterBottom(defaultMarker));
    // TODO Auto-generated constructor stub
}

public UsingOverlaysForMarkers(Drawable defaultMarker,Context context) {
    super(boundCenterBottom(defaultMarker));
    mContext = context;
    // TODO Auto-generated constructor stub
}

@Override
public int size() {
    // TODO Auto-generated method stub
    return mOverlays.size();
}

@Override
protected boolean onTap(int index) {
  OverlayItem item = mOverlays.get(index);
  AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
  dialog.setTitle(item.getTitle());
  dialog.setMessage(item.getSnippet());
  dialog.show();
  return true;
}

}

NEW CODE

itemizedoverlay1 = mMap.addGroundOverlay(new GroundOverlayOptions()
    .image(drawable).visible(true).position(g,30));

I want to create on onTap() event for the itemizedoverlay1.

1

There are 1 best solutions below

0
On

there is no listener that detect a click event on ground overlay, how ever you can use onMapClickListener() and use the returned latLng to detect a click event.