[英]how to write a directions request for Google Maps Directions?
I am making an android app that uses the google maps directions services.我正在制作一个使用谷歌地图路线服务的安卓应用程序。 I have finished almost all of the app but i have a problem with the directions request.
我已经完成了几乎所有的应用程序,但我对路线请求有疑问。 I need that the request will give me a bus route and that there will be no transfers.
我需要该请求将为我提供一条公交路线,并且不会有任何接送服务。 I know i need to use the transit_mode bus ,and the transit_routing_preference fewer_transfers.
我知道我需要使用transit_mode 总线和transit_routing_preference less_transfers。 but i dont know how to add it to the request.
但我不知道如何将其添加到请求中。 do i need to write &transit_mode=bus&transit_routing_preference=fewer_transfers& ?
我需要写 &transit_mode=bus&transit_routing_preference=fewer_transfers& 吗? i looked everywhere but i still dont know how to add those options to the request.
我到处找,但我仍然不知道如何将这些选项添加到请求中。
The Google Maps Directions API uses a simple HTTP interface , you're on the right track setting the transit_mode=bus
and transit_routing_preference=fewer_transfers
. Google Maps Directions API 使用一个简单的HTTP 接口,您在正确的轨道上设置了
transit_mode=bus
和transit_routing_preference=fewer_transfers
。 You'll also need to set mode=transit
to activate transit mode.您还需要设置
mode=transit
以激活运输模式。
I think the final URL you're looking for will look like: https://maps.googleapis.com/maps/api/directions/json?origin=Mountain%20View&destination=1600%20Amphitheatre%20Parkway&mode=transit&transit_mode=bus&transit_routing_preference=fewer_transfers&key=YOUR_API_KEY
.我认为您要查找的最终网址如下所示:
https://maps.googleapis.com/maps/api/directions/json?origin=Mountain%20View&destination=1600%20Amphitheatre%20Parkway&mode=transit&transit_mode=bus&transit_routing_preference=fewer_transfers&key=YOUR_API_KEY
: https://maps.googleapis.com/maps/api/directions/json?origin=Mountain%20View&destination=1600%20Amphitheatre%20Parkway&mode=transit&transit_mode=bus&transit_routing_preference=fewer_transfers&key=YOUR_API_KEY
。
Note - The transit_mode
and transit_routing_preference
parameters will bias your results, but not guarantee the results will always be a bus route with 0 transfers.注意
transit_mode
和transit_routing_preference
参数会使您的结果产生偏差,但不能保证结果将始终是具有 0 次换乘的公交路线。 You'll need to design your application to handle > 0 transfer bus routes.您需要将应用程序设计为处理 > 0 条公交路线。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.