MyLocationOverlaydispatchTap() 不传播

发布于 2024-10-16 06:01:21 字数 733 浏览 6 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情绪失控 2024-10-23 06:01:21

“自 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文