Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use google maps simple api on localhost

Tags:

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.

like image 316
ditoslav Avatar asked Nov 01 '14 22:11

ditoslav


People also ask

Can we use Google Map API in localhost?

in the form after "My web site URL:". The API key they give you works for your localhost.

Can I use Google Maps API without API key?

API keys are required for apps and projects that use the Google Maps Platform APIs and SDKs.

Can I use Google Maps API for free?

You won't be charged until your usage exceeds $200 in a month. Note that the Maps Embed API, Maps SDK for Android, and Maps SDK for iOS currently have no usage limits and are at no charge (usage of the API or SDKs is not applied against your $200 monthly credit).


2 Answers

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

like image 78
ditoslav Avatar answered Sep 18 '22 15:09

ditoslav


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.

like image 28
Luis Avatar answered Sep 19 '22 15:09

Luis