如何使用坐标从LocationManager来计算距离坐标、如何使用、距离、LocationManager

2023-09-04 23:35:30 作者:b站因为名字不能重复,短id很容易重名,所以有小伙伴想找又长

我使用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.

推荐答案

您可以一看的位置类。可以设置的经度和纬度,并有一个 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