得到两缘点之间的距离 [英] Get the distance between two geo points

查看:109
本文介绍了得到两缘点之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要作出这样的检查有什么从用户是最近的地方应用程序。我可以很容易地获取用户的位置和我有随纬度和经度的地方的清单。

什么是知道对当前位置的名单最近的地方的最佳方式。

我找不到在谷歌API的任何东西。

我很担心,我需要求助于我的计算和必须做数学计算的呢。

你们有什么感想?

欢呼和感谢阅读或回复。

解决方案

 位置LOC1 =新的位置();
loc1.setLatitude(LAT1);
loc1.setLongitude(lon1);

位置LOC2 =新的位置();
loc2.setLatitude(LAT2);
loc2.setLongitude(lon2);

浮distanceInMeters = loc1.distanceTo(LOC2);
 

参考:<一href="http://developer.android.com/reference/android/location/Location.html#distanceTo(android.location.Location)">http://developer.android.com/reference/android/location/Location.html#distanceTo(android.location.Location)

I want to make a apps that check what's the nearest place from where the user is. I can easily get the location of the user and I have a list of places with latitude and longitude.

What would be the best way to know the nearest place of the list against the current position.

I could not find anything in the google APIs.

I am worried I need to resort to my calculate and have to do math to calculate it.

What do you guys think ?

Cheers and thanks for reading or replying.

解决方案

Location loc1 = new Location("");
loc1.setLatitude(lat1);
loc1.setLongitude(lon1);

Location loc2 = new Location("");
loc2.setLatitude(lat2);
loc2.setLongitude(lon2);

float distanceInMeters = loc1.distanceTo(loc2);

Reference: http://developer.android.com/reference/android/location/Location.html#distanceTo(android.location.Location)

这篇关于得到两缘点之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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