Google距离矩阵API:最大参数数量?

时间:2016-04-25 15:02:46

标签: google-maps google-distancematrix-api

我可以为此功能提供的最大起源数和目的地数是多少? 或者更好:我可能要求的最大起始目的地组合数是多少?

现在我有33个起点和3个目的地 - 它正在运作。 至于我再输入一个目的地 - 发生错误。 它说像

Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 223, in _get
    result = self._get_body(resp)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 242, in _get_body
    raise googlemaps.exceptions._RetriableRequest()
googlemaps.exceptions._RetriableRequest

During handling of the above exception, another exception occurred:

我有12次这样的行,最后

Traceback (most recent call last):
  File "C:\Python34\Lib\site-packages\googlemaps\distance_matrix_test.py", line 41, in <module>
    '28821 Coslada','10179 Berlin'], mode='driving')
  File "C:\Python34\Lib\site-packages\googlemaps\distance_matrix.py", line 130, in distance_matrix
    return client._get("/maps/api/distancematrix/json", params)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 184, in _get
    raise googlemaps.exceptions.Timeout()
googlemaps.exceptions.Timeout

很高兴得到你的帮助!顺便说一句:我检查了额外的地址 - 这不会导致问题。它必须是地址的数量。但是我想就此获得专业意见......

谢谢!!!

1 个答案:

答案 0 :(得分:2)

来自Google Maps Distance Matrix API Usage Limits的文档:

  

发送到Google Maps Distance Matrix API的每个查询都受到允许元素数量的限制,其中原始数量乘以目标数量来定义元素数量。

     

Google Maps Distance Matrix API具有以下限制:

     

标准使用限制
  标准API的用户:

  • 每天2,500个免费元素
  • 每个查询100个元素
  • 每10秒100个元素

当您提交维度33 x 3矩阵时,您只有99个元素,这些元素在免费服务等级的限制范围内。但是当你添加一个目的地(给你一个尺寸为34 x 333 x 4的矩阵)时,你超过100,因此错误。

您的选择包括选择高级服务,每次查询最多可提供625个元素,或以某种方式减少输入矩阵的大小。