无需用户输入即可触发 ItemizedOverlay onTap 操作,以便在更改为屏幕活动时使气球可见
我的项目中有一个 MapView,我在其中使用 ItemizedOverlay 显示一组项目。
当用户点击其中一个项目时,会在其上方显示一个带有一些信息的气球。
现在,我想要实现的是当更改为地图活动屏幕时,无需用户点击屏幕即可显示气球...就像初始化一样,我使气球在没有用户的情况下就可见输入。
I have a MapView in my project where I display a set of items with ItemizedOverlay.
When a user taps one of the items a balloon is displayed over it with some info.
Now, what I am trying to achieve is when changing to the map activity screen have a balloon show up without the user tap the screen... like an initialization, where I make a balloon already visible without user input.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许你可以做到这一点。当您最初在
ItemizedOverlay
上显示一组项目时,当您确定应显示气球的项目时,请为该项目的索引运行onTap
方法。如果项目已显示,只需识别或检索相关项目的索引,然后为其运行onTap
。Maybe you can do this. While you are initially displaying the set of items on
ItemizedOverlay
, and as you identify the item that should show the balloon, runonTap
method for that item's index. If items are already displayed, just identify or retrieve the index for item in question, and runonTap
for it.我使用以下命令完成此操作:
对象
itemizedoverlay
是我的ItemizedOverlay
扩展的实例。I did it using the following command:
The object
itemizedoverlay
is an instance of my extension ofItemizedOverlay
.您是否尝试过重写 MapView 的 onResume ?每次您的活动进入前台时都会调用它。
希望有帮助!
Have you tried to override onResume for your MapView? It will be called everytime your activity goes to foreground.
Hope it helps!