我正在使用地图矩阵api来查找英格兰各地点之间的过境距离。
https://maps.googleapis.com/maps/api/distancematrix/json?
units=metric
&key=YOUR_KEY_HERE
&origins=SE108aJ
&destinations=SE164UN
&mode=transit
&arrival_time=1568618400
®ion=UK
它返回:
{
"destination_addresses" : [ "London SE16 4UN, UK" ],
"origin_addresses" : [ "Dartmouth Hill, Blackheath, London SE10 8AJ, UK" ],
"rows" : [
{
"elements" : [
{
"status" : "ZERO_RESULTS"
}
]
}
],
"status" : "OK"
}
对谷歌地图的相同请求有效:
https://www.google.com/maps/dir/SE10+8AJ,+达特茅斯+希尔,+布莱克希思,+伦敦/伦敦+SE16+4UN
所以我有点困惑为什么API调用没有
找到它时,我包含了一个过去的到达时间,将其更改为未来的时间和日期使其能够工作。
2019-09-16 08:20:00 GMT==1568618400
现在==1573060070
2019-11-16 08:20:00 GMT==1573892400
https://maps.googleapis.com/maps/api/distancematrix/json?
units=metric
&key=YOUR_KEY_HERE
&origins=SE108aJ
&destinations=SE164UN
&mode=transit
&arrival_time=1573892400
®ion=UK
结果在:
{
"destination_addresses" : [ "London SE16 4UN, UK" ],
"origin_addresses" : [ "Dartmouth Hill, Blackheath, London SE10 8AJ, UK" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "9.1 km",
"value" : 9143
},
"duration" : {
"text" : "41 mins",
"value" : 2481
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}