android,计算两个地方之间的距离,谷歌距离矩阵

时间:2011-06-23 16:48:58

标签: android google-maps mobile google-maps-api-3 latitude-longitude

只有一个我不理解的问题是,在谷歌距离矩阵的页面上,例如:

要求从温哥华,不列颠哥伦比亚省,加拿大以及从美国华盛顿州西雅图到美国加利福尼亚州旧金山和加拿大不列颠哥伦比亚省维多利亚的距离和持续时间。

在那部分,它是什么意思BC,WA等在请求中

http://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver+BC|Seattle&destinations=San+Francisco|Victoria+BC&mode=bicycling&language=fr-FR&sensor=false

为什么选择温哥华+ BC,为什么不选择Seatle + WA。

最重要的问题是,如果我想使用latidute和经度,而不是使用地名,我该怎么做?

1 个答案:

答案 0 :(得分:0)

看看我在这个帖子上发布的答案:

android google map finding distance

它使用Google Directions API,但您仍然可以获得所需的数据,并使用Lat / Lon作为请求。您还需要添加:

JSONObject duration = steps.getJSONObject("duration");

        String sDuration = duration.getString("text");
        int iDuration = duration.getInt("value");

为了获得持续时间,请确保在JSONObject步骤= legs.getJSONObject(0)之后放置它;

相关问题