Skip to Content
Node与Express开发(第2版)
book

Node与Express开发(第2版)

by Ethan Brown
June 2021
Intermediate to advanced
290 pages
9h 21m
Chinese
Posts & Telecom Press
Content preview from Node与Express开发(第2版)
集成第三方
API
|
225
现在我们就有了一个函数,它可以连接到谷歌
API
并为地址生成地理编码。如果
API
未能
找到某个地址(或因为任何原因失败了),就会返回一个错误。
API
也有可能返回多个地
址。例如,如果你搜索“
10 Main Street
”而没有指定一个城市
、州或邮编,就会返回几十
条结果。我们的实现只是简单地取出第一条。这个
API
可
以返回大量的信息,但目前我们
只对地理坐标感兴趣。你可以很容易地修改接口,让它返回更多的信息。如果想了解这个
API
所返回数据的更多信息,请查阅谷歌地理编码的
API
文档。
使用限制
目前,谷歌地理编码
API
有一个每月使用的限制
,但你可以为每个额外编码请求支付
0.005
美元
。因此如果你在某一个月里发出了
1 000 000
个请求,那么就会从谷歌收到一张
5000
美元的账单……所以对你来说很可能会有一个现实的限制。
如果你忘记了停止服务,或某个坏家伙得到了你的登录凭据,就可能会导致
费用失控。如果担心这样的事情发生,可以设置一个预算以及几项警告,当
达到警告条件时会发出通知。进入你的谷歌开发者控制台,从结算菜单里选
择“预算与警告”。
写作本书时,为了避免滥用,谷歌限制在
100
秒内只能发出
5000
个请求,这个限制应该
是很难超过的。谷歌的
API
还要求
,如果你的网站需要使用地图,就要使用谷歌地图。也
就是说,如果使用了谷歌的服务来为你的数据生成地理编码,就不能转而使用
Bing
地图
来显示这些位置信息,这是违反服务条款的。一般而言,这不是什么过分的限制,因为如
果你不打算在地图上显示位置 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

面向对象的思考过程(原书第5版)

面向对象的思考过程(原书第5版)

马特 魏斯费尔德
精通模块化JavaScript

精通模块化JavaScript

Nicolás Bevacqua

Publisher Resources

ISBN: 9787115565099