gpt4 book ai didi

android - 我怎样才能返回谷歌地图方向的距离?

转载 作者:行者123 更新时间:2023-11-30 02:08:09 25 4
gpt4 key购买 nike

我是 android 的新手,我一直在关注 this tutorial关于获取要显示的 map 。

我想知道有没有一种方法可以让您在获得路线时返回 A 点和 B 点之间的行驶(非直线)距离,并将其显示在 TextView 中?

谢谢。

最佳答案

使用以下内容:

float[] result = new float[0];
Location.distanceBetween(startLatitude, startLongitude, endLatitude, endLongitude, result);
//The computed distance is now stored in results[0].

Source

您也可以使用 Google Maps Android API Utility Library :它有静态方法来计算距离。

SphericalUtil.computeDistanceBetween(from,to)
//Returns the distance between two LatLngs, in meters.

Source

关于android - 我怎样才能返回谷歌地图方向的距离?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30445753/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com