android中的GPS_PROVIDER或NETWORK_PROVIDER的位置不一致 [英] Location from GPS_PROVIDER or NETWORK_PROVIDER in android is not consistent

查看:202
本文介绍了android中的GPS_PROVIDER或NETWORK_PROVIDER的位置不一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试做什么
使用服务,以便只要应用程序正在运行位置可以被检索


我面临的问题


  • 即使我在相同的位置很长时间,每次纬度,经度不同的准确性等级

  • 因此,即使用户没有更改他的位置,如果我正在绘制 GoogleMap 中的 Location ,它使得我的缩放级别变得非常接近 18.0f

  • mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom (currentLatLon,18.0f));



我尝试了 stackove rflow Link One 计算器链接两个

但即使我坐在相同的位置,并定期检索位置,纬度和经度差异是这样的, 在每次经过结束时查看突出显示的值



纬度:12.8379 283 长:经度:77.6647 266

纬度:12.8379 233 长:经度:77.6647 368



纬度:12.8379 285 长:经度:77.6647 506

纬度:12.8379 245 长:经度:77.6647 546



但仍然每次精度不同,Lat Lon略有变化。

由于我的代码试验与链接中提到的完全相同,我不只是在这里复制粘贴。这将得到解决

解决方案

GPS的精确度并不是绝对的,所以即使是静态设备也会在连续读数中显示不同位置。请尝试以下操作:


  1. 您可以添加一个方法,通过读取加速度计来检测手机是否静止 - 如果两个读数大于某个阈值 - 设备正在移动。如果它太小 - 它不会移动。要确定增量 - 将设备放在一张桌子上,看看你得到了什么值。

  2. 忽略近距离读数 - 以高精度(< 20m或您确定的其他值)并将其用作参考 - 如果下一次读数给出非常小的距离,接近参考(<10m或其他值),则忽略它。如果它更大 - 将其设置为新的参考。


What I am trying to do

  • Get users location at specified interval using a Service so that as long as application is running Location can be retrieved

Problem I am facing

  • Even if I am in same location for long time, each time the Latitude , Longitude changes with different Accuracy levels
  • Due to this, even if user has not changed his location, if I am plotting the Location in GoogleMap it makes jump to very near by places being my zoom level 18.0f
  • mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(currentLatLon, 18.0f));

I have tried approaches mentioned in stackoverflow Link One and stackoverflow Link Two

But even though I am sitting in the same location and retrieving location in regular interval, the Lat and Lon differs like this , see the highlighted values at end of every lat lon:

Latitude: 12.8379283 Long: Longitude: 77.6647266

Latitude: 12.8379233 Long: Longitude: 77.6647368

Latitude: 12.8379285 Long: Longitude: 77.6647506

Latitude: 12.8379245 Long: Longitude: 77.6647546

but still every time the Accuracy differs and Lat Lon slightly changes.

As my code trials are exactly same as mentioned in link's I am not just copy pasting here. How can this be resolved

解决方案

The accuracy of the GPS is not absolute, so even a static device will show different locations in successive readings. Try the following:

  1. You can add a method that detects if the mobile is static or not, by reading he accelerometer - if the delta between two readings is bigger than some threshold - the device is moving. If it's too small - it's not moving. To determine the delta - put the device on a table and see what values you get.
  2. Ignore close readings - Take the first reading with good accuracy (<20m or other value you determine) and use it as a reference - if the next reading gives a very small distance, close to the reference (<10m or other value), ignore it. If it's bigger - set it as the new reference.

这篇关于android中的GPS_PROVIDER或NETWORK_PROVIDER的位置不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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