MyLocationOverlay dispatchTap() doesn't propagate
Asked Answered
G

1

6

I have a MapView with some overlays and a subclass of MyLocationOverlay on top of them because I want the user current location to show above the other markers.

I'm handling the onTap event for the markers to show a panel with info of the tapped marker and if tapped outside of a marker (even in the location marker) the panel should hide.

If I click on a marker or in an empty spot everything is fine, the panel shows or hides as expected, but if I click on the location marker nothing happens (if the location marker is over another marker the info doesn't show and if it's outside and the info is showing it doesn't hide).

In my MyLocationOverlay I overrided dispatchTap() function making it return false as stated in docs:

Returns: True if this tap was processed; false if it should be sent to the other overlays.

but still doesn't work, even I tried returning true just in case, but nothing...

Anybody knows how to propagate the onTap event to the other overlays?

Greaves answered 6/2, 2011 at 12:49 Comment(1)
is dispatchTap actually being called? (it should return false by default). Have you tried overriding public boolean onTouchEvent(android.view.MotionEvent e, MapView mapView) to see if thats getting called?Touchhole
D
1

"Fixed since android 2.0, it was a known issue of some phones"

From - Propagate events in several layers android google maps

"If you are seeing the overlay items you put on your MapView, your onTap() will be triggered when you tap on any of the overlay items. onTap(GeoPoint point, MapView view) is always triggered regardless of where the user taps. Therefore, you can override it to see if it's triggered. onTap(int i) will run after it in the case where an overlay item is clicked."

From - https://stackoverflow.com/questions/6680387/ontap-event-on-map-is-not-fired

Disembroil answered 23/12, 2011 at 16:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.