2

I want to display a dialog box when tapping a marker on my map. i could set the marker on the map, but i am unable to pop up the dialog box which should contain the some description about the marked place. I tried overriding onTouchEvent(), but then the box appeared only when tapping the exact point. But what i want is to display the dialog box when touching any point within the marker. Could anybody pls help me?

Thanks.

Manoj
  • 2,056
  • 1
  • 20
  • 35

3 Answers3

2

In this case, i have class extend ItemizedOverlay you just override onTap

public class PlaceItemizedOverlay extends ItemizedOverlay<OverlayItem> {



    @Override
    protected boolean onTap(final int index) {


      final OverlayItem oi = mOverlays.get(index);
      AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
      dialog.setTitle("your title");
      dialog.setMessage("youmessage");
      dialog.setNegativeButton("Cancel", null);
      dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {

            }
      });
      dialog.show();
      return true;

      }

}
April Smith
  • 1,790
  • 2
  • 26
  • 52
1

You can use or refer to MapViewBalloons project

example project

Niranj Patel
  • 36,011
  • 11
  • 98
  • 132
0

You can display an AlertDialog for this with the help of Handler Class. Please check my answer here.

Community
  • 1
  • 1
Lucifer
  • 28,933
  • 23
  • 88
  • 140