android 地图:拖动完成后如何确定地图中心
有没有办法通过 android 地图 API,在平移动画完成后可以检测地图中心?我想使用此信息从服务器动态加载标记。 谢谢 BD
Is there a way through the android maps API, where I can detect the map center after pan animation has completed? I want to use this information to load markers from a server dynamically.
Thanks
BD
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我还一直在寻找一种“结束拖动”解决方案,该解决方案可以在地图结束移动后的那一刻检测地图中心。我还没有找到它,所以我做了这个简单的实现,效果很好:
就是这样,我希望它有帮助!哦/
I also have been looking for a "did end drag" solution that detects the map center at the moment exactly after the map ended moving. I haven't found it, so I've made this simple implementation that did work fine:
That's it, I hope it helps! o/
您使用的是
MapActivity
吗?这是我使用的代码:您也需要添加与此类似的代码:
Are you using a
MapActivity
? Here's the code I've used:You do need to add code similar to this also:
8 月起,Android 版地图能够检测
onCameraMoveStarted
等事件(以及移动的原因,例如REASON_GESTURE
、REASON_DEVELOPER_ANIMATION
。自 2016年 以下代码(主要取自文档)给出了以下内容你可以实现什么:
Since August 2016 Maps for Android is capable of detecting events such as
onCameraMoveStarted
(and the reasons for the move, e.g.,REASON_GESTURE
,REASON_DEVELOPER_ANIMATION
.The following code (mostly taken from the docs) gives an idea of what you can achieve: