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条)

报告相同问题?

悬赏问题

  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来