MyLocationOverlaydispatchTap() 不传播
我有一个 MapView
,上面有一些覆盖层和一个 MyLocationOverlay
的子类,因为我希望用户当前位置显示在其他标记之上。
我正在处理标记的 onTap 事件,以显示带有点击标记信息的面板,如果点击标记外部(即使在位置标记中),面板应该隐藏。
如果我单击标记或空白处,一切都很好,面板会按预期显示或隐藏,但如果我单击位置标记,则不会发生任何情况(如果位置标记位于另一个标记上方,则信息不会显示,并且如果它在外面,信息显示它没有隐藏)。
在我的 MyLocationOverlay
中,我重写了 dispatchTap()
函数,使其返回 false,如 文档:
返回:如果处理了此点击,则返回 True; 如果应发送到其他叠加层,则为 false。
但仍然不起作用,即使我尝试返回 true 以防万一,但什么也没有...
有人知道如何将 onTap
事件传播到其他叠加层吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“自 android 2.0 以来已修复,这是某些手机的已知问题”
来自 - 在多个层中传播事件 android google 地图
“如果您看到放置在 MapView 上的覆盖项目,则当您点击任何覆盖项目时,您的 onTap() 将被触发。 onTap(GeoPoint point, MapView view) 总是被触发,无论用户点击哪里,因此,您可以覆盖它以查看在单击覆盖项时 onTap(int i) 是否会在它之后运行。”
来自 - https://stackoverflow.com/questions/6680387/ontap-event-地图上未触发
"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