按 Google 方向 api 创建路线时出现问题
Issue in creating route by Google directions api
这是我正在使用的 URL :
https://maps.googleapis.com/maps/api/directions/json?origin=28.6139,77.2090&destination=25.992003,-80.117802&key=API KEY
当我在浏览器中点击此 URL 时,我收到以下响应:
{
"geocoded_waypoints" : [ {}, {} ],
"routes" : [],
"status" : "ZERO_RESULTS"
}
源位置是德里,目标位置是 3555 N Ocean Dr, Hollywood, FL 33019, USA。如果我将目标位置更改为任何其他位置,那么我将获得地理编码 waypoints 的值,但为什么不获取上述值?
非常感谢您的帮助。
我认为您的错误是由 API 方向的出行方式限制引起的。
出行方式
When you calculate directions, you may specify the transportation mode
to use. By default, directions are calculated as driving
directions. The following travel modes are supported:
driving
(default) indicates standard driving directions using the road network.
walking
requests walking directions via pedestrian paths & sidewalks (where available).
bicycling
requests bicycling directions via bicycle paths & preferred streets (where available).
transit
requests directions via public transit routes (where available). If you set the mode to transit
, you can optionally specify either a departure_time
or an arrival_time
. If neither time is specified, the departure_time
defaults to now (that is, the departure time defaults to the current time). You can also optionally include a transit_mode
and/or a transit_routing_preference
.
Google 地图应用程序(浏览器)中的示例路线
https://www.google.com.ph/maps/dir/28.6139,77.209/'25.992003,-80.117802'/@22.2476068,-39.0397189,4z/data=!3m1!4b1!4m6!4m5!1m0!1m3!2m2!1d-80.117802!2d25.992003
如果您在浏览器中检查link,出行模式是飞行,在API方向不可用。
这是之前的问题:How to set travel mode to “Flight” in google map direction API
希望这对您有所帮助。
这是我正在使用的 URL :
https://maps.googleapis.com/maps/api/directions/json?origin=28.6139,77.2090&destination=25.992003,-80.117802&key=API KEY
当我在浏览器中点击此 URL 时,我收到以下响应:
{
"geocoded_waypoints" : [ {}, {} ],
"routes" : [],
"status" : "ZERO_RESULTS"
}
源位置是德里,目标位置是 3555 N Ocean Dr, Hollywood, FL 33019, USA。如果我将目标位置更改为任何其他位置,那么我将获得地理编码 waypoints 的值,但为什么不获取上述值?
非常感谢您的帮助。
我认为您的错误是由 API 方向的出行方式限制引起的。
出行方式
When you calculate directions, you may specify the transportation
mode
to use. By default, directions are calculated asdriving
directions. The following travel modes are supported:
driving
(default) indicates standard driving directions using the road network.walking
requests walking directions via pedestrian paths & sidewalks (where available).bicycling
requests bicycling directions via bicycle paths & preferred streets (where available).transit
requests directions via public transit routes (where available). If you set the mode totransit
, you can optionally specify either adeparture_time
or anarrival_time
. If neither time is specified, thedeparture_time
defaults to now (that is, the departure time defaults to the current time). You can also optionally include atransit_mode
and/or atransit_routing_preference
.
Google 地图应用程序(浏览器)中的示例路线
https://www.google.com.ph/maps/dir/28.6139,77.209/'25.992003,-80.117802'/@22.2476068,-39.0397189,4z/data=!3m1!4b1!4m6!4m5!1m0!1m3!2m2!1d-80.117802!2d25.992003
如果您在浏览器中检查link,出行模式是飞行,在API方向不可用。
这是之前的问题:How to set travel mode to “Flight” in google map direction API
希望这对您有所帮助。