Set up the Maps JavaScript API

  • Google Maps Platform requires an API key for authentication and billing purposes, associating your project with a unique alphanumeric string.

  • You can create and manage API keys via the Google Cloud Console or the Cloud SDK, enabling access and specifying restrictions for security.

  • Restricting API keys is highly recommended, limiting usage to specific applications and websites for enhanced security.

  • Include your API key in every Maps JavaScript API request, replacing YOUR_API_KEY in the provided script snippet.

This document describes the steps needed to start using the Maps JavaScript API.

Enable the API

Before you can use Maps JavaScript API, you must use the Google Cloud console or the gcloud command to enable it in your Google Cloud project.

To enable the API:

Console

  1. Open the product page in the Google Cloud console:

    Enable the Maps JavaScript API
  2. Click the Enable button.

gcloud

gcloud services enable \
    --project "PROJECT" \
    "maps-backend.googleapis.com"

Read more about the Google Cloud SDK , Cloud SDK installation , and the following commands: