Mapview onTap 未针对 OverlayItem onTap 触发
我的应用程序中有一个地图视图,并且所有内容都与 touchEvents 配合得非常好。
然而,为了最大限度地提高应用程序的用户数量,我也一直在尝试添加轨迹球界面功能,但遇到了问题。
当轨迹球处于焦点时,轨迹球会正确滚动地图视图,但是当用户集中在覆盖项目上时,我无法触发 onTap 事件。
当我单击鼠标按钮(我正在使用模拟器)来模拟轨迹球用户的单击(F6 接合轨迹球)时,没有任何反应。 onTrackBallEvent 代码在这种情况下永远不会被触发,鉴于 API 文档说,我希望如此在这种情况下 onTap 应该被触发,但它也不会被触发。
如果我没有以overlayItem为中心,我确实会在onTrackBallEvent中获得ACTION_DOWN和ACTION_UP事件,只有当地图以OverlayItem为中心时,onTrackBallEvent才不会被触发。不幸的是 onTap 事件也不会被触发。显然,当覆盖层位于屏幕中心下方且用户单击轨迹球时,操作系统正在通过这些点击执行某些操作,但如果我能弄清楚它是什么,我就该死了。
有谁知道我应该寻找什么活动?
I have a mapview in my app, and everything is working fabulously with touchEvents.
However to maximize usership of the App, I have been trying to add trackBall interface functionality as well and am running into a problem.
The trackball properly scrolls the mapView around when it is in focus, however I am unable to get the onTap event to fire when the user has centered on an overlay item.
When I click the mouse button (I am using the emulator) to simulate a click by the trackball user (F6 engaged trackball) nothing happens.. The onTrackBallEvent code never gets fired in this situation, which I would expect given the API docs say that the onTap should be fired in this instance, but it doesn't get fired either.
If I am not centered on an overlayItem I do get the ACTION_DOWN and ACTION_UP events in the onTrackBallEvent, it is only when the map is centered on an OverlayItem that the onTrackBallEvent does not get fired. Unfortunately the onTap Events don't get fired either. Obviously the OS is doing something with these clicks when an overlay is under the center of the screen and a user clicks on the trackball, but I will be darned if I can figure out what it is.
Does anyone know what Event I should be looking for?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个相当老的问题,但我想我会给出 2 美分。由于某种原因,您需要在地图上的某个位置添加叠加层,然后 onTap() 覆盖才能在您单击的位置添加其他叠加层。我用过:
This is quite an old issue but figured I'd give my 2 cents. For some reason, you need to add an overlay somewhere on the map before the onTap() override can add other overlays where you click. I used:
因为它适用于此。我检查屏幕上的点击点是否与某些覆盖项目匹配。
For it works with this. I check if the hit point on the screen matches with some overlay item.
请试试这个。这用于在地图视图上显示多个叠加层,可能会解决问题:https://github。 com/donnfelker/android-mapviewballoons
please try this one. This is used for showing multiple overlays on map view, may be it will solve the problem: https://github.com/donnfelker/android-mapviewballoons