![](/img/trans.png)
[英]What is the best way to get latitude and longitude from GPS in Android?
[英]What is the best way to calculate distance from GPS in Android Phone?
我正在开发一个应用程序,每60秒捕获用户的经度和经度,并计算用户行进的距离。 有时我的手机在同一个位置超过一个小时,但GPS会跳到不同的位置导致错误的距离计算。
如何减少gps跳跃并提高距离精度?
GPS的准确性在整个会话期间将不一致。 但有办法克服这一点。 即使用户没有改变位置,仍然是latitide,经度值在连续的时间段内会有所不同。 请查看以下方法如何修改这些异常。
// for location updates
private int locationupdate = 8000; //in milliseconds
private int locationdistance = 10; // in meters
创建位置请求时,请根据您的要求提及setSmallestDisplacement
和setInterval
,如下所示
protected void createLocationRequest() {
locationRequest = new LocationRequest();
locationRequest.setInterval(locationupdate); //in milliseconds
locationRequest.setFastestInterval(5000); //in milliseconds
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setSmallestDisplacement(locationdistance);
}
有关更多信息,请查看此链接
你必须检查位置的准确性,如果不够好就不要使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.