最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - getting error using google maps api : This API project is not authorized to use this API - Stack Overflow

programmeradmin5浏览0评论

The google maps request is going to the Google Maps Api (javascript). But I am getting this error message

And yes the google maps api is enabled and I have generated a key that I am using in my code. But getting this error "This API project is not authorized to use this API", screenshot below

The google maps request is going to the Google Maps Api (javascript). But I am getting this error message

And yes the google maps api is enabled and I have generated a key that I am using in my code. But getting this error "This API project is not authorized to use this API", screenshot below

Share Improve this question edited Jun 8, 2019 at 23:08 Thufir 8,49736 gold badges133 silver badges287 bronze badges asked Jun 27, 2016 at 11:00 Aurobindo ParidaAurobindo Parida 111 gold badge1 silver badge2 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 2

According to the recent changes announced on June 22, 2016

We now count Google Maps JavaScript API client-side requests towards the daily limit of the associated web service API.*

http://googlegeodevelopers.blogspot..es/2016/06/building-for-scale-updates-to-google.html

That means you have to enable Geocoding API in your project if you use geocoding service of Maps JavaScript API. If you use places library, you have to enable Places API and so on.

I am having this problem as well, but only on some pages within my site - on other pages, it works fine. All the pages which use the maps API use it in exactly the same way, via a shared javascript library.

I pared the network calls on pages with and without the error, and they appear to be 100% identical except for the Referrer URL (https://site.url/page/that/works vs. https://site.url/page/that/fails).

I have https://site.url in the "Accept requests from these HTTP referrers" list, and this functionality used to work on all the pages! It stopped working recently, perhaps as recently as this weekend, yesterday, or today.

Are you appending the maps script by hand on your website, or using a plugin? Can you send here your website URL? Anyway, here it is how to append the API key: Let's assume that you have the following piece of code

<script async defer src="//maps.googleapis./maps/api/js" type="text/javascript"></script>

To append the apy key, you must add ?key=YOUR_API_KEY at the end of the src path, like this:

<script async defer src="//maps.googleapis./maps/api/js?key=YOUR_API_KEY" type="text/javascript"></script>

If, instead, your src path already has some appended parameters (for example, "//maps.googleapis./maps/api/js?v=3.exp&sensor=false"), just add &key=YOUR_API_KEY at the very end: "//maps.googleapis./maps/api/js?v=3.exp&sensor=false&key=YOUR_API_KEY" This is how you append the API parameter (obviously, replace YOUR_API_KEY with your API key code).

You can find more information on obtaining a google maps key at https://developers.google./maps/documentation/javascript/get-api-key

Your API key should be up and running within 5 minutes. Enjoy!

To make it work we need to use Google Maps Geocoding Api and Google Maps Javascript Api I was unfortunately using only the javascript one. It's working fine now.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论