duanlijia5864 2016-08-12 09:32
浏览 113
已采纳

Google Maps API距离矩阵请求

I've been using the Google Distance Matrix API for a while now to calculate distances between the consumer and businesses on my website; I have currently hit a wall and seen that my quote hits 2,500 and doesn't process anymore requests after that.

I then decided to give the documentation a quick read over to see if there's anything I could do to maybe kill two birds with one stone, so to say, and seen on the API Usage Limits Page that you have have 25 origins and 25 destinations per requests.

Does this means that within one request I can concatenate 25 origins and destinations and return their miles.

Here's the PHP code I use to get the milage between the consumer and customer:

final public function Distance($A, $B){

    $URL = "https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=".urlencode($A)."&destinations=".urlencode($B)."&key=API_KEY_HERE";
    $Data = json_decode(file_get_contents($URL));

    return str_replace(" mi", "", $Data->rows->elements->distance->text);        
}
  • 写回答

2条回答 默认 最新

  • duandong7980 2016-08-12 09:37
    关注

    The quota is in terms of elements:

    Users of the standard API:

    2,500 free elements per day, calculated as the sum of client-side and server-side queries.

    Also:

    Each query sent to the Google Maps Distance Matrix API is limited by the number of allowed elements, where the number of origins times the number of destinations defines the number of elements.

    Adding more origins/destinations to a request won't increase the amount of distances that can be retrieved before hitting the quota.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作