How to use google maps simple api on localhost

2020-02-20 11:02发布

I have requested a link for embedding google maps on my website on

https://developers.google.com/maps/documentation/embed/start

and have authorized everyone with the link to use it

Referers: Any referer allowed
https://code.google.com/apis/console/

but I still receive a

The Google Maps API server rejected your request. This API project is not authorized 
to use this API. Please ensure that this API is activated in the APIs Console: 
Learn more: https://code.google.com/apis/console

Is there some other way to test my website locally with embedded google maps?

EDIT: They say:

Easy embedding

Google Maps Embed API maps are easy to add to your webpage—just set the URL 
you build as the value of an iframe's src attribute. Control the size of the 
map with the iframe's height and width attributes. No JavaScript required.

but I still can't access the link.

3条回答
霸刀☆藐视天下
2楼-- · 2020-02-20 11:31

The problem was that they have their "quick start" out of date.

https://developers.google.com/maps/documentation/embed/start

It says you should only provide them with your API key but the thing is that there is a new version of the same website which they don't have links to from their guide but which you get a link to elsewhere( I got offered when in "billing" )

The new service is called Cloud Console and I found the API on/off buttons there.

https://console.developers.google.com/project/...

You have to enable the "Static Maps API", "Google Maps API" and "Google Maps Embed API" and make sure to have your link in an iframe div

查看更多
啃猪蹄的小仙女
3楼-- · 2020-02-20 11:34

I also had to enable the Google Maps JavaScript API.

查看更多
对你真心纯属浪费
4楼-- · 2020-02-20 11:40

As Dominik said, go here:

https://console.developers.google.com/project/%your-project-name%/apiui/apis/library?q=google%20maps

Enable both APIs:

  • Google Maps Embed API
  • Static Maps API

Then go here: https://console.developers.google.com/project/%your-project-name%/apiui/credential

  • Create New Key
  • Browser Key

And you're done.

查看更多
登录 后发表回答