Nick
Nick

Reputation: 6385

Map TouchOverlay and ItemizedOverlay

I have a MapView that has an ItemizedOverlay on it which displays markers. This overlay also overrides onTap to perform an action when the marker is tapped.

My map also includes a normal Overlay that overrides onTouchEvent to perform an action when anywhere else on the map is touched.

However, when the user taps on the marker, the onTouchEvent from the normal Overlay is called as well as the onTap from the ItemizedOverlay.

So my question is: is there any way to have the onTouchEvent not called (or ignored) when the marker is tapped?

Thanks.

Upvotes: 0

Views: 129

Answers (2)

YankeeWhiskey
YankeeWhiskey

Reputation: 1582

make the ItemizedOverlay above Overlay and let your onTap return false.

Upvotes: 0

A Random Android Dev
A Random Android Dev

Reputation: 2691

Yes, there's an extremely simple solution to this. The answer stems from the way Java inheritance works. Basically, ItemizedOverlay extends Overlay, so all you need to do is to not call the super.onTap() method in your itemizedOverlay override of onTap(). That should do it as far as I know. Do let me know if it doesn't work and I'll provide you with an alternative solution.

Upvotes: 2

Related Questions