Display a simple text label / descrption bubble when user taps on a OverlayItem in MapView

StackOverflow https://stackoverflow.com/questions/1976036

  •  21-09-2019
  •  | 
  •  

문제

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top