- Web
- Maps Embed API
New map styling is coming soon to Google Maps Platform. This update to map styling includes a new default color palette and improvements to map experiences and usability. All map styles will be automatically updated in March 2025. For more information on availability and how to opt in earlier, see New map style for Google Maps Platform.
- Home
- Products
- Google Maps Platform
- Documentation
- Web
- Maps Embed API
- Guides
Google Maps Platform products are secured from unauthorized use by restricting API calls to those that provide proper authentication credentials. These credentials are in the form of an API key - a unique alphanumeric string that associates your Google billing account with your project, and with the specific API or SDK.
This guide shows how to create, restrict, and use your API Key for Google Maps Platform.
Before you begin
Before you start using the Maps Embed API, you need a project with a billing account and the Maps Embed API enabled. To learn more, see Set up in Cloud Console.
Create API keys
The API key is a unique identifier that authenticates requests associated with your project for usage and billing purposes. You must have at least one API key associated with your project.
To create an API key:
Console
-
Go to the Google Maps Platform > Credentials page.
Go to the Credentials page
- On the Credentials page, click Create credentials > API key.
The API key created dialog displays your newly created API key. - Click Close.
The new API key is listed on the Credentials page under API keys.
(Remember to restrict the API key before using it in production.)
Cloud SDK
gcloud alpha services api-keys create \ --project "PROJECT" \ --display-name "DISPLAY_NAME"
Read more about the Google Cloud SDK , Cloud SDK installation , and the following commands:
- gcloud alpha services api-keys create
Restrict API keys
Google strongly recommends that you restrict your API keys by limiting their usage to those onlyAPIs needed for your application. Restricting API keys adds security to your application byprotecting it from unwarranted requests. For more information, seeAPI security best practices.
To restrict an API key:
Console
-
Go to the Google Maps Platform > Credentials page.
Go to the 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:
- Application restrictions:
- To accept requests from the list of websites that you supply, select HTTP referers (web sites) from the list of Application restrictions.
- Specify one or more referrer websites. You can use wildcard characters to authorize all subdomains (for example,
https://*.google.com
accepts all sites ending in.google.com
when accessed over HTTPS). Note that if you specify www.domain.com, it acts as a wildcard www.domain.com/*, and authorizes any subpath on that hostname. Only thehttps://
andhttp://
referrer schemes are supported.
- Click Restrict key.
- Select Maps Embed API from Select APIs dropdown. If the Maps Embed API is not listed, you need to enable it.
- 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.
Cloud SDK
List existing keys.
gcloud services api-keys list --project="PROJECT"
Clear existing restrictions on existing key.
gcloud alpha services api-keys update "projects/PROJECT/keys/KEY_ID" \ --clear-restrictions
Set new restrictions on existing key.
gcloud alpha services api-keys update "projects/PROJECT/keys/KEY_ID" \ --api-target="maps-embed-backend.googleapis.com" --allowed-referrers="referer"
Read more about the Google Cloud SDK , Cloud SDK installation , and the following commands:
- gcloud alpha services api-keys update
- gcloud alpha services api-keys lookup
- gcloud services api-keys list
Add the API key to your request
You must include an API key with every Maps Embed API request.In the following example, replace YOUR_API_KEY
with yourAPI key.
https://www.google.com/maps/embed/v1/MAP_MODE?key=YOUR_API_KEY¶meters
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-06-12 UTC.
[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }] [{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]