我正在尝试了解DistanceMatrix API。当我在浏览器上执行此操作时:https://maps.googleapis.com/maps/api/distancematrix/json?origins=14.614786,121.046587&destinations=14.610301,121.080233&mode=driving&language=zh-CN&departure_time=now&key=MY_KEY我得到了duration_in_traffic。{ "destination_addresses" : [ "17 Orchard Rd, Bagumbayan, Quezon City, 1109 Metro Manila, Philippines" ], "origin_addresses" : [ "74 C. Benitez St, Quezon City, Metro Manila, Philippines" ], "rows" : [ { "elements" : [ { "distance" : { "text" : "8.5 km", "value" : 8470 }, "duration" : { "text" : "23 mins", "value" : 1406 }, "duration_in_traffic" : { "text" : "35 mins", "value" : 2112 }, "status" : "OK" } ] } ], "status" : "OK"}但是当我使用地图API将其放在golang中时我没有得到duration_in_traffic并且只返回null r := &maps.DistanceMatrixRequest{ Language: *language, DepartureTime: "now", ArrivalTime: *arrivalTime,}我做错了什么吗?
2 回答
喵喵时光机
TA贡献1846条经验 获得超7个赞
另一个潜在的陷阱是,如果Google没有流量数据,则不会返回duration_in_traffic。
文档状态:
仅当满足以下所有条件时,才返回流量持续时间:
The request includes a departure_time parameter.
The request includes a valid API key, or a valid Google Maps Platform Premium Plan client ID and signature.
Traffic conditions are available for the requested route.
The mode parameter is set to driving.
- 2 回答
- 0 关注
- 263 浏览
添加回答
举报
0/150
提交
取消