Google Maps API is never satisfied

非 Y 不嫁゛ 提交于 2021-01-04 12:51:35

问题


If I use URL referrer authentication with Geocoding API it says:

There was an error while trying to fix the Venues geolocation information: API keys with referer restrictions cannot be used with this API.

Which after research I find that this means that Google Maps is looking for IP address authentication.

But if I use IP address authentication with Javascript Maps API it says:

JavaScript API error: RefererNotAllowedMapError

https://developers.google.com/maps/documentation/javascript/error-messages#referer-not-allowed-map-error Your site URL to be authorized: https://example.com

What can be going on?

How can I fully satisfy the good ol'Google Maps?


回答1:


It looks like you're using two different Maps APIs; the client-side JavaScript API and the server-side Geocoding API web service. This means you need 2 API keys; one restricted with HTTP referrers for client-side use, and the other one restricted by IP address for web services only.

To learn more on how API key restrictions work check out Google's documentation on API key best practices.

Hope this helps!




回答2:


I know this is 3 months old now. But I had the same problem and I found out how to solve this.

As evan said, you need 2 API Keys. And annoyingly, The Events Calendar only have one field for the API Key. BUT, I found a link here: https://support.theeventscalendar.com/ to https://support.theeventscalendar.com/716190-Using-Google-Maps-API-Key-Restrictions. The page redirects though... But I managed to screen shot parts of it before it redirects and found this snippet: https://gist.github.com/cliffordp/a2ec320313afbc1ffb5f0e5ac654b7fb (I changed the code to use a define instead because I don't want my API key in git)

This filter will make it possible to have two API KEYS.



来源:https://stackoverflow.com/questions/58241284/google-maps-api-is-never-satisfied

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!