如何使用坐标从LocationManager来计算距离 [英] How to calculate distance using coordinates from LocationManager

查看:88
本文介绍了如何使用坐标从LocationManager来计算距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用LocationManager获得纬度用户和经度的值。这些值被定期更新到数据库。

I am using LocationManager to get the values of Latitude and Longitude of a user. These values are updated regularly to a database.

现在,我要找出两个用户基础上存储的纬度和经度值之间的距离。我想显示一个消息,当两个用户之间的距离小于(说100米)。任何人都可以请指导我有一个教程或如何实现它的一些样品code。

Now, i want to find out the distance between two users basing on the stored Latitude and Longitude values. I want to display a message when distance between two users is less than (say 100 meters). Can anyone please guide me with a tutorial or some sample code of how to achieve it.

推荐答案

您可以一看的位置类。可以设置的经度和纬度,并有一个<一个href="http://developer.android.com/intl/fr/reference/android/location/Location.html#distanceTo%28android.location.Location%29"相对=nofollow> distanceTo ,你可以使用方法

You can have a look at the Location class. You can set the longitude and latitude and there is a distanceTo method that you can use

这篇关于如何使用坐标从LocationManager来计算距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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