Googlemaps API Key for Localhost

adam78 picture adam78 · Sep 5, 2016 · Viewed 130.3k times · Source

How do I get googlemaps api key to work on localhost?

I've created an API key and under referers I add the following:

Accept requests from these HTTP referrers (websites) (Optional)

Use asterisks for wildcards. If you leave this blank, requests will be 
accepted from any referrer. Be sure to add referrers before using this key 
in production. 

localhost

This doesnt work and if I exclude the api key it doesnt work either?

Answer

mirzaei.sajad picture mirzaei.sajad · Jul 19, 2017
  1. Go to this address: https://console.developers.google.com/apis
  2. Create an API key for your project
  3. Click on "Library"
  4. Click on any API that you want
  5. Click on "Enable" (top right)
  6. Click on "Credentials" > "Edit Key"
  7. Under "Key Restriction", select "HTTP referrers (web sites)"
  8. Type your website address (or "localhost", "127.0.0.1", "localhost:port" etc for local tests) in the text field and press ENTER to add it to the list
  9. Use your key in your project