在谷歌地图的位置更新率(Android版) [英] Location update rate in Google Maps (Android)

查看:285
本文介绍了在谷歌地图的位置更新率(Android版)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了位置感知一个简单的基于GPS的应用程序。当启用了GPS,应用程序请求位置更新和版画纬度和在的TextView 经度。如果GPS被禁用,位置提供跌落背朝 LocationManager.NETWORK_PROVIDER 为三角相对于邻近的细胞塔设备位置。这样做的目的是当检测到设备的运动,它应该开始与纬度/填充的TextView 长。如果没有运动,这个过程应该停止。为了做到这一点,我已经实现了位置更新率:

I'm writing a simple GPS based app for location awareness. Whenever GPS is enabled, the app requests location updates and prints latitude and longitude in a TextView. If GPS is disabled, the location provider fall-backs to LocationManager.NETWORK_PROVIDER for triangulating device position relative to neighboring cell-towers. The aim is whenever device movement is detected, it should start populating the TextView with lat/long. 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);

上面一行将导致非常频繁的位置更新(即使没有运动,我不断收到经/纬度值)。我读的地方,把 minTime = 0 是不是一个好主意(电池的消耗速度更快)。当我它更改为2或3秒,更新变得很慢(即使该设备移动超过50米)。更改 minDistance才会似乎并不擦出火花!我想知道是否谷歌地图应用程序中使用哪些设置?功耗是不是限制因素对我来说,因为我正在开发一些网络驱动器测试设备的应用程序(从车辆的车载铅酸电池电量恒功率)。

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). When I change it to 2 or 3 seconds, the update becomes very slow (even if the device moves more than 50 meters). Changing minDistance doesn't seem to work either! I want to know what settings does Google Maps application use? 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).

推荐答案

更​​新的频率是高度依赖于硬件。好的GPS芯片发送非常频繁的更新(三星Galaxy S3),而有的甚至斗争,显示经纬度岚位置。这里的要点是标准化的频率为距离和时间的基础上接收更新。使用不同的时间和距离的配置并测试它们并使用最适当的值。对于我的项目,我用以下数值:
//行走用户

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. 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,这一点);

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

//用于用户在汽车中

//for user in a car

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

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

这篇关于在谷歌地图的位置更新率(Android版)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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