Manoj
Manoj

Reputation: 2442

how to pop up a dialog when tapping on a Map marker?

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.

Upvotes: 2

Views: 6681

Answers (3)

Niranj Patel
Niranj Patel

Reputation: 33248

You can use or refer to MapViewBalloons project

example project

Upvotes: 1

April Smith
April Smith

Reputation: 1830

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;

      }

}

Upvotes: 2

Lucifer
Lucifer

Reputation: 29642

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

Upvotes: 0

Related Questions