Close balloon showed on MapView
I have a MapView with an ItemizedOverlay and a bunch of OverlayItem:s. When an OverlayItem is tapped on custom layout balloon is displayed on MapView. I can add a close button that hides the balloon layout. But how can I close the balloon if the user tap:s on the map outside the balloon? I have an OnT开发者_JAVA技巧ouchListener on the MapView, but how can I from this localize the open balloon layout and hide it?
/P
You could add a boolean property to your custom layout ballon called isOpen which you would set to true when the ballon gets opened and false when closed. If a user taps outside the ballon, in your onTouch event, iterate through your list of OverlayItems and check their isOpen property - if true, then close it and break out of the iteration loop.
精彩评论