距离计算,从我的位置在android的目标位置 [英] Distance calculation from my location to destination location in android

查看:228
本文介绍了距离计算,从我的位置在android的目标位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须做一个项目,我需要计算的距离从我的位置,目标位置,并显示在一个textview.Here注意,这个距离​​更新时,我的位置change.Is有可能使这种类型的项目?

I have to made a project where i need to calculate the distance from my location to destination location and show it in a textview.Here note that this distance updated when my location change.Is it possible to make such type of project ?

[注:未执行谷歌地图我必须做出后援目的地经度,纬度是known.Just必须找到我的位置,并计算]

[NOTE: without implementing Google map i have to make it.The destination lon ,lat is known.Just have to find my location and make the calculation]

推荐答案

查看文档的谷歌Android开发页面上,看看如何监听位置的变化。 <一href="http://developer.android.com/guide/topics/location/obtaining-user-location.html">http://developer.android.com/guide/topics/location/obtaining-user-location.html

check the documentation on the google android dev page to see how to listen for position changes. http://developer.android.com/guide/topics/location/obtaining-user-location.html

您可以使用此功能来确定当前的(开始)点和目标点之间的距离。

you can use this function to determine the distance between the current (start) point and the target point.

 /**
 * using WSG84
 * using the Metric system
 */
public static float getDistance(double startLati, double startLongi, double goalLati, double goalLongi){
    float[] resultArray = new float[99];
    Location.distanceBetween(startLati, startLongi, goalLati, goalLongi, resultArray);
    return resultArray[0];
}

这篇关于距离计算,从我的位置在android的目标位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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