简体   繁体   English

如何从另一个Google地图的标记获取以分钟为单位的持续时间

[英]How get duration in mins from a marker another google maps

How i can to get travel duration in MINS from point A to B in Google maps, below i attach my code fragment: 我如何在Google地图中获取MINS从A点到B点的旅行时长,下面附上我的代码片段:

Location locationB = new Location("point B");

locationB.setLatitude(location.getLatitude());
locationB.setLongitude(location.getLongitude());

distance = locationA.distanceTo(locationB);

double kms = distance / 1000 ;
String distanceKm = new DecimalFormat("#.0").format(kms);

Log.v("log", "distance " + distance);
tv3.setText(distanceKm + "Kms");

Thnks for any help 寻求帮助

Refer below link google provide direction api it give all the information about source to destination place. 参考下面的链接google提供方向api,它提供了有关从源到目的地的所有信息。 read this all things you getting your question solution. 阅读这一切,您将获得问题解决方案。 https://developers.google.com/maps/documentation/directions/start https://developers.google.com/maps/documentation/directions/start

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM