You have to get a Google Maps API key to use maps on your site. This process will take a little of your time, just follow the instructions below.
Everything is ready to begin the process of getting the Google Maps API key. Go to the APIs & Services > Credentials page.
Click + Create Project button to create a new Google Cloud Project. Go to Step 4, if you have already created a project.
Set a unique name for your project, or use default project name. And click the Create button. Please note that the name of the project cannot be changed later.
After creating the project visit Project Dashboard page.
- Go to the Credentials page, click Create credentials > API key.
The API key created dialog displays your newly created API key.
The new API key is listed on the Credentials page under API keys.
(Remember to restrict the API key before using it in production.)
Restricting your API keys
Restricting API Keys adds security to your application by ensuring only authorized requests are made with your API Key. We strongly recommend that you follow the instructions to set restrictions for your API Keys. For more information, see API Key best practices.
To restrict an API key:
Go to the APIs & Services > Credentials page.
Select the API key that you want to set a restriction on. The API key property page appears.
Under Key restrictions, set the following restrictions for Application restrictions:
- To accept requests from the list of website that you supply, select HTTP referrers (web sites) from the list of Application restrictions.
- Specify one or more referrer web sites. For example,
*.google.comaccepts all sites ending in
google.com, such as
Note: file:// referers need a special representation to be added to the key restriction. The “file://” part should be replaced with “__file_url__” before being added to the key restriction. For example, “file:///path/to/” should be formatted as “__file_url__//path/to/*”. After enabling file:// referers, it is recommended you regularly check your usage, to make sure it matches your expectations.
Under Key restrictions, set the following restrictions for API restrictions:
- Click Restrict key
Click Save for the changes to take effect.