You must have at least one API key associated with your project.

To get an API key:

  1. Register in Google API Console.
  2. Add and validate billing.
  3. Create a project.
  4. Add Maps JavaScript API, Places API.
  5. Get the API key.
    1. Go to the Google Cloud Platform Console
    2. Click the project drop-down and select or create the project for which you want to add an API key.
    3. Click the menu button and select APIs & Services > Credentials.
    4. On the Credentials page, click Create credentials > API key.
    5. The API key created dialog displays your newly created API key.
    6. Click Close.
    7. The new API key is listed on the Credentials page under API keys.
    8. Remember to restrict the API key before using it in production.

Restrict the API key

We strongly recommend that you restrict your API key. Restrictions provide added security and help ensure only authorized requests are made with your API key. There are two restrictions. You should set both:

To restrict an API key:

  1. Go to the Google Cloud Platform Console.
  2. Click the project drop-down and select the project that contains the API key you want to secure.
  3. Click the menu button and select APIs & Services > Credentials.
  4. On the Credentials page, click the name of the API key that you want to secure.
  5. On the Restrict and rename API key page, set the restrictions:
  6. Application restrictions
  7. Select HTTP referrers (web sites).
  8. Add the referrers.
  9. API restrictions
  10. Select Restrict key.
  11. Click Select APIs and select Maps JavaScript API.
  12. (If the Maps JavaScript API is not listed, you need to enable it.)
  13. If your project uses Places Library, also select Places API. Similarly, if your project uses other services in the JavaScript API (Directions Service, Distance Matrix Service, Elevation Service, and/or Geocoding Service), you must also enable and select the corresponding API in this list.
  14. Click SAVE.