谷歌地图Android api v2折线长度 [英] Google Maps Android api v2 polyline length

查看:144
本文介绍了谷歌地图Android api v2折线长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到android maps api v2方法,该方法将确定我在移动时创建的折线的长度。我会把它放在onLocationChanged()中以进行持续更新。任何人都知道方法是什么以及地图api将显示长度的单位?

I'm trying to find the android maps api v2 method that will determine the length of the polyline that I am creating while I am moving. I would put it inside onLocationChanged() for continual updates. Anyone know what the method is and what units the the maps api will display the length?

Polyline line = map.addPolyline(new PolylineOptions());


public void onLocationChanged(Location location) {



line.add(new LatLng(location.getLatitude(), location.getLongitude())
 .width(5)
 .color(Color.RED));

}


推荐答案

你可以使用 Location.distanceBetween 。如果您想要距离起点和终点位置的总距离,那么随着您的位置变化,请保持一个总计距离

you can use Location.distanceBetween on your last location to your current location. If you want a total distance from your start and end positions then keep a running total as your location changes

这篇关于谷歌地图Android api v2折线长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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