如何计算多个经度和纬度之间的距离? [英] How can I calculate distance between multiple latitude and longitude?
本文介绍了如何计算多个经度和纬度之间的距离?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想计算包含经纬度和经度的每个点之间的总距离,这些点存储在本地数据库中,因此方案是我要计算从点a到点b的距离.从b到c c到d,这些点(纬度和经度)将使用google place api
I want to calculate total distance between each points both contains lat and long, these points are stored in local database, so the scenario is I want to calculate distance from point a to b & b to c & c to d and these points(lat and long) are stored into database using google place api
所有点都从数据库中获取.
All the points are fetched from database.
推荐答案
float[] distanceWidth = new float[2];
Location.distanceBetween(
startLatitude,
startLongitude,
endLatitude,
endLongitude,
distanceWidth);
//You will get float[] of results after Location.distanceBetween().
float distance = distanceHeight[0];
float distanceInKm = distance/1000;
这篇关于如何计算多个经度和纬度之间的距离?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文