# Get your Google Maps key (no coding)

Source: https://help.ruuster.com/idx/google-maps-key

> Step by step, with no coding, how to get the Google Maps key and Map ID your listing map needs, lock them to your website, set a spending alert, and save them in your console.

The map on your search, area and listing pages is a Google map, and it runs on your brokerage's own
Google account. You need two things from Google: a **Maps key** and a **Map ID**. Getting them takes
about 15 minutes, you don't need to write any code, and you only do it once.

Everything else on your pages (the listing cards, photos, search box, filters and forms) works
without these. Only the map needs them.

## Before you start

Have these ready:

- **A Google account** your brokerage owns, such as the one you use for Gmail or Google Workspace.
  Use a company account rather than a personal one, so the key stays with the business if someone
  leaves.
- **A credit or debit card.** Google asks for one to turn on its map service. Your first 10,000 map
  views each month are free, and step 7 sets an alert so Google emails you before your spending
  passes an amount you choose. [What it costs](https://help.ruuster.com/idx/google-maps-key#what-it-costs) shows the math for a typical site.
- **Your website address**, such as `www.yourbrokerage.com`, and the address of your test site if you
  have one.

## Step 1: Open Google Cloud and create a project

1. Go to [console.cloud.google.com](https://console.cloud.google.com) and sign in with your
   brokerage's Google account.
2. If Google asks you to agree to its terms the first time, read them, tick the box and click
   **Agree and continue**.
3. At the top left, next to the Google Cloud logo, click the project picker. It says **Select a
   project** or shows the name of an existing project.
4. In the window that opens, click **New project** at the top right.
5. In **Project name**, type your brokerage's name and the word Maps, such as `Peach Realty Maps`.
   Leave the other fields as they are.
6. Click **Create**. Wait a few seconds, then open the project picker again and click your new
   project so its name shows at the top of the page.

## Step 2: Turn on billing

1. Click the menu button (three lines) at the top left, then click **Billing**.
2. Google shows one of these:
   - **"This project has no billing account"**: click **Link a billing account**, then **Create
     billing account**. Enter your country, your business name and address, and your card, then
     click **Submit and enable billing**.
   - **A list of billing accounts**: pick your brokerage's account and click **Set account**.
   - **The billing overview of an account**: billing is already on. Go to step 3.

## Step 3: Turn on the Maps JavaScript API

1. Go to the [Maps JavaScript API page](https://console.cloud.google.com/apis/library/maps-backend.googleapis.com).
   Check that your project's name shows at the top.
2. Click **Enable**. If the button says **Manage**, it's already on.
3. Wait a minute before the next step. Google takes a moment to switch it on.

## Step 4: Create your Maps key

1. Click the menu button (three lines), then **Google Maps Platform**, then **Keys & Credentials**.
2. Click **Create credentials**, then **API key**.
3. In the panel that opens, under **Select API restrictions**, make sure **Maps JavaScript API** is
   ticked and nothing else is. Then click **Create**.
4. Google shows your new key. It is a long code that starts with `AIza`. Click the copy button next
   to it and paste it into a note for now. You can always see it again on this page by clicking
   **Show key**.

## Step 5: Lock the key to your website

This makes the key work only on your own website, so nobody can copy it and use it on theirs.

1. On **Keys & Credentials**, click the name of the key you just made.
2. Under **Key restrictions**, choose **Set an application restriction**, then **Websites**.
3. Add each of these, one per line, replacing `yourbrokerage.com` with your own domain:
   - `https://yourbrokerage.com`
   - `https://*.yourbrokerage.com` (this covers `www` and any other address on your domain)
   - your test site, if you have one, such as `https://staging.yourbrokerage.com`
   - `http://localhost` and `http://localhost:3000`, only if a developer builds your site on their
     own computer
4. Under **API restrictions**, check that **Restrict key** is chosen and **Maps JavaScript API** is the
   only one ticked.
5. Click **Save**. Changes can take up to five minutes to apply.

## Step 6: Create your Map ID

The Map ID lets the map show price pins on each home.

1. Click the menu button (three lines), then **Google Maps Platform**, then **Map management**.
2. Click **Create map ID**.
3. In **Name**, type `Listings map`.
4. For **Map type**, choose **JavaScript**, then **Vector**.
5. Click **Save**.
6. Google shows the new Map ID, a shorter code of letters and numbers. Copy it into your note next to
   the key.

## Step 7: Set a spending alert

This emails you if your map use ever heads past the free amount, so there are no surprises.

1. Click the menu button (three lines), then **Billing**, then **Budgets & alerts**.
2. Click **Create budget**.
3. Name it `Maps`, leave the project and services as they are, and click **Next**.
4. Under **Budget type** choose **Specified amount**, enter the most you're comfortable spending on
   maps in a month, such as `$50`, and click **Next**.
5. Keep the alerts Google suggests (at 50%, 90% and 100%) and tick **Email alerts to billing admins
   and users**.
6. Click **Finish**.

An alert tells you about spending but doesn't stop it. If you also want a hard limit, open
**Google Maps Platform**, then **Quotas**, pick **Maps JavaScript API**, and lower **Map loads per
day**. When a day's limit is reached, the map pauses until the next day and the rest of your pages
keep working.

## Step 8: Save the key and Map ID in your console

1. Open your Listings API console and click **Website**.
2. Find **Google Maps key and Map ID**, and paste the key and the Map ID into their boxes.
3. Save.

Your pages receive both from `GET /v1/meta` with your own Listings API key, so they are saved in
one place. If a developer builds your site, send them both values too. They go into the site's settings as `NEXT_PUBLIC_GOOGLE_MAPS_KEY` and
`NEXT_PUBLIC_GOOGLE_MAP_ID` (other frameworks use the names in [Keys, domains and environment
names](https://help.ruuster.com/idx/keys-and-domains)). Both are safe to show in a web page, because
step 5 locked the key to your domain.

## Check that it works

Open a search or area page on your site. You should see the map with a price pin on each home and,
on an area page, the area's outline. Click a pin to see the home.

## If the map doesn't show

| What you see | What it means | What to do |
|---|---|---|
| A grey map that says **"For development purposes only"** | Billing isn't on for the project | Do step 2 again and make sure your project is the one selected at the top |
| **"This page can't load Google Maps correctly"** | The key doesn't allow this website | In step 5, check the website address, including `https://`, and wait five minutes after saving |
| A map with no price pins | The Map ID is missing or was typed wrong | Copy the Map ID again from **Map management** and paste it on **Website** in your console |
| No map at all, and the rest of the page is fine | The key or Map ID isn't saved yet | Do step 8, then reload the page after a few minutes |
| **"This API project is not authorized to use this API"** | The Maps JavaScript API isn't turned on | Do step 3 |

## What it costs

Google counts one map view each time a page with a map opens. The first **10,000 map views a month
are free**. After that, Google charges $7 for each additional 1,000 views, and the price per view
drops at higher volumes. Two examples:

| Your site | Map views a month | Google's charge a month |
|---|---|---|
| 100 visitors a day, each opening three pages with a map | about 9,000 | $0 (inside the free 10,000) |
| 300 visitors a day, each opening three pages with a map | about 27,000 | about $119 (17,000 views past the free amount) |

Google's current prices are on its
[pricing page](https://developers.google.com/maps/billing-and-pricing/pricing). The charges come from
Google to your brokerage's billing account.
