Display A Simple Text Label / Descrption Bubble When User Taps On A OverlayItem In MapView

- 1 answer

I would like to further annotate the custom markers I have placed on a MapView (using ItemizedOverlay) by displaying a simple text label that appears for a particular item when the onTap event is fired.

This is a trivial exercise in the Google Maps JavaScript API and in MapKit on iPhone, but it is not obvious to me what the best or easiest way to do this is on Android.



If you want the message to be transient, use a Toast. See here for an example.

If you want the message to be more persistent, you could:

  1. Put the MapView inside some container that supports z-axis ordering (e.g., RelativeLayout)
  2. Add a child of that same container, after the MapView, that is your "a simple text label / descrption bubble", with android:visibility="gone"
  3. When you want to display the bubble, adjust its top and left padding to position it where you want relative to the point, then make it visible
  4. When the user does something to make the bubble go away, make its visibility be GONE again
  5. Repeat steps #3 and #4 as necessary