简体   繁体   English

Google Maps(Android)中的位置更新率

[英]Location update rate in Google Maps (Android)

I'm writing a simple GPS based app for location awareness. 我正在写一个简单的基于GPS的应用程序来进行位置感知。 Whenever GPS is enabled, the app requests location updates and prints latitude and longitude in a TextView . 每当启用GPS时,应用程序都会请求位置更新,并在TextView打印纬度和经度。 If GPS is disabled, the location provider fall-backs to LocationManager.NETWORK_PROVIDER for triangulating device position relative to neighboring cell-towers. 如果禁用了GPS,则位置提供程序将回退到LocationManager.NETWORK_PROVIDER ,以对相对于相邻蜂窝塔的设备位置进行三角测量。 The aim is whenever device movement is detected, it should start populating the TextView with lat/long. 目的是每当检测到设备移动时,都应开始使用纬度/经度填充TextView When there is no movement, the process should stop. 当没有移动时,该过程应停止。 In order to do so, I've implemented the location update rate as: 为此,我将位置更新率实现为:

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 1, this);

The above line causes very frequent location updates (even when there is no movement, I keep getting lat/long values). 上一行会导致非常频繁的位置更新(即使没有移动,我也会不断获得经/纬度值)。 I read somewhere that putting minTime=0 is not a good idea (battery drains faster). 我在某处读到将minTime=0放置不是一个好主意(电池消耗更快)。 When I change it to 2 or 3 seconds, the update becomes very slow (even if the device moves more than 50 meters). 当我将其更改为2或3秒时,更新变得非常慢(即使设备移动了50多米)。 Changing minDistance doesn't seem to work either! 更改minDistance似乎也不起作用! I want to know what settings does Google Maps application use? 我想知道Google Maps应用程序使用什么设置? Power consumption is not a limiting factor for me as I'm developing the app for some network drive test equipment (which gets constant power from vehicle's on-board lead acid battery). 对于我来说,功耗并不是一个限制因素,因为我正在为某些网络驱动测试设备开发应用程序(该应用程序从车辆的车载铅酸电池获得恒定功率)。

The frequency of updates is highly dependent on the hardware. 更新的频率高度依赖于硬件。 Good gps chips send very frequent updates(Samsung Galaxy S3) while some struggle even to show lat-lan position. 好的gps芯片会发送非常频繁的更新(三星Galaxy S3),尽管有些挣扎甚至无法显示拉特兰的位置。 The gist here is normalize the the frequency for receiving updates on the basis of distance and time. 要点是根据距离和时间归一化接收更新的频率。 Use various time and distance configuration and test them and use the most appropriate values. 使用各种时间和距离配置,并对其进行测试并使用最合适的值。 For my project I used following values: //for walking user 对于我的项目,我使用以下值://对于步行用户

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5, 10, this); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,5,10,this);

//for user in a car //适用于汽车用户

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2, 50, this); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,2,50,this);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM