MyLocationOverlay或LocationManager更新当前位置 [英] MyLocationOverlay or LocationManager for updating current location

查看:182
本文介绍了MyLocationOverlay或LocationManager更新当前位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的图形页面,以在地图上显示用户的当前位置。要在用户处于移动状态更新位置,我有一个选择:

I am using MapView to show current location of a user on a Map. To update the location while the user is on the move, I have to a choice:

  • 我可以用MyLocationOverlay绘制的当前位置,并扩展它允许在移动用户的位置跟踪,并具有自定义标记。与MyLocationOverlay的问题是,我无法控制与该装置从GPS请求的位置的频率。我担心这里的电池消耗。
  • 我可以使用位置管理和订阅使用requestLocationUpdates从GPS得到的位置。在这里,我有更多的控制与GPS的查询次数。我可以连接一个LocationListener的,写了code在那里。

不过,我在这里读,这样它可能不是使用位置管理和MyLocationOverlay应该pferred超过这个$ P $不错的办法。

But I have read here at SO that it might not be good approach to use Location Manager and MyLocationOverlay should be preferred over to this.

此外,考虑到我的应用程序是一个基于位置的应用程序,因为他移动用户的位置应该被跟踪。

Also, consider that my app is a location based app the location of the user should be tracked as he moves.

人能否提供这是实现最好的方法,对电池的相对影响较小。

Can people suggest which is the best approach to implement and has relatively less impact on battery.

请注意,我在Android的初学者,所以请原谅任何明显的错误。

Note that I am a beginner in Android, so pardon any obvious mistakes.

感谢你在前进, 刘德华

Thank you in advance, andy

推荐答案

我用小蓬松的位置 - 它的图书馆,你设定的时间进行更新,还是距离,该库做一个广播接收器,实现LocationListener的,正通知你的应用程序时,位置的变化。

I using Little Fluffy Location - Its a library, you setting time for updates or distance, this library make a broadcast receiver, implements LocationListener, n notify your application when location changes.

简单,快捷,方便!

请参阅这个链接:

位置发生改变后,更新您的覆盖上图! =)

After location changed, update your overlay on the map! =)

如果你需要,我送我的完整的解决方案的位置。

if you need, i send my full solution for locations.

这篇关于MyLocationOverlay或LocationManager更新当前位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆