我正在开发一个移动应用程序,我想使用 Google Directions API (http://code.google.com/apis/maps/documentation/javascript/services.html#Directions)。
我有一个地点列表,我想显示按距离(距用户位置)排序的列表。这可以通过使用 Google API 执行请求来完成,请查看以下帖子,有一个工作示例:
Android:如何获取两个人之间的步行距离地理坐标?)。
我的问题:
1)是否可以仅使用一个请求来计算从一个原点(我当前的位置)到多个点(地点)的距离?
2)是否可以减小响应的大小(以减少网络流量)?我只需要距离+所需时间。我希望仅当用户单击列表中的项目时才显示地图。
非常感谢您的帮助。
毛罗
I'm working on a mobile app and I would like to calculate the distance between two points using the Google Directions API (http://code.google.com/apis/maps/documentation/javascript/services.html#Directions).
I have a list of places and I would like to show this list ordered by distance (from the user position). This can be done performing a request using Google API, look at the following post, there is a working example:
Android: how to get the walking distance between two geo coordinats?).
My questions:
1) Is it possible to calculate the distance from one origin (my current position) to several points (places) using just one request?
2) Is it possible to reduce the size of the response (in order to reduce network traffic)? I just need distance + required time. I would like tho show the map only when the user click the item in the list.
Many thanks in advance for your help.
Mauro
发布评论
评论(1)
您应该查看 google.maps.DirectionsLeg 和 < a href="http://code.google.com/apis/maps/documentation/javascript/examples/directions-waypoints.html" rel="nofollow">此示例。
You should look at google.maps.DirectionsLeg and this example.