Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps api 3 使用源和目标的lat/long通过Python中的Google Directions API获取路由_Google Maps Api 3_Google Api_Google Geocoding Api_Google Directions Api - Fatal编程技术网

Google maps api 3 使用源和目标的lat/long通过Python中的Google Directions API获取路由

Google maps api 3 使用源和目标的lat/long通过Python中的Google Directions API获取路由,google-maps-api-3,google-api,google-geocoding-api,google-directions-api,Google Maps Api 3,Google Api,Google Geocoding Api,Google Directions Api,我只想使用GoogleDirections API获得从A点到B点的路线/方向,给定A和B的纬度/长度坐标。我想用Python来实现这一点 如果我这样做,它会起作用: import googlemaps gmaps = googlemaps.Client(key='mykey') start = 'Constitution Ave NW & 10th St NW, Washington, DC' end = 'Independence and 6th SW, Washington,

我只想使用GoogleDirections API获得从A点到B点的路线/方向,给定A和B的纬度/长度坐标。我想用Python来实现这一点

如果我这样做,它会起作用:

import googlemaps
gmaps = googlemaps.Client(key='mykey')
start = 'Constitution Ave NW & 10th St NW, Washington, DC'
end   = 'Independence and 6th SW, Washington, DC 20024, USA'
dirs  = gmaps.directions(start, end)
然而,这不是我想要的,因为我只得到了lat/long坐标,而没有地址。我知道我可以使用reverse_geocode()将lat/long转换为地址,但这不是我想要的,因为这将在Directions API之上调用地理编码API。我还没有找到直接在lat/long上使用gmaps.directions()的方法

所以我的问题很简单:当我只有A和B的lat/long坐标时,我可以单独使用Directions API来获取从点A到点B的方向吗?还是我必须在上面使用地理编码API

感谢您抽出时间。

根据谷歌的消息:

如果传递坐标,它们将不变地用于计算方向。确保纬度和经度值之间不存在空格。
origin=41.43206,-81.38992


请用下面的方法给出纬度和纬度。因此,希望这会有所帮助:

origin: {lat:19.99, lng:73.78},  // Start Point
destination: {lat:19.697316, lng:73.560936},  // End Point

这是适合坐标的代码。请注意,不能将坐标和字符串地址混合使用

import googlemaps
gmaps = googlemaps.Client(key='mykey')
start = '43.70721,-79.3955999'
end   = '43.7077599,-79.39294'
dirs  = gmaps.directions(start, end)

甚至没有留下评论就被否决了?