---
title: "Google"
section: "Third party keys"
route: /thirdpartykeysgoogle
account: {accountId}
bruce_api: https://{accountId}.api.nextspace.host
guardian_api: https://guardian.nextspace.host
---
# Google

Google Maps Platform keys are saved under two program IDs. "GoogleApi" covers Places, Air Quality and geocoding. "GooglePhotogrammetry" covers Google Photorealistic 3D Tiles. They are separate records and each feature reads only its own ID.

Both can hold the same key value. If you have one Google key with every API it needs enabled, save it under both IDs.

In Operator they are the "Google API" and "Google Photorealistic Tiles" fields of the Third Party Keys panel. You can read about the record and its requests in [Third party keys](/thirdpartykeys).

## GoogleApi

The "GoogleApi" key powers:

- The "Google address" option of Navigator's search box. When a Google search fails, Navigator searches Cesium Ion instead.
- "GoogleSearch" Menu Items, which show places found around the view, and the place details and photos opened from them.
- "GoogleAirQuality" Menu Items: current conditions and forecasts.
- The "Geocode" and "ReverseGeocode" Data Mapping functions, which turn an address into coordinates and coordinates into an address. AI suggested Data Mappings only offer these two functions when the key is set.

Navigator calls these through proxies on the account's API, which add the key server side:

| Proxy | Forwards to | Used by |
| --- | --- | --- |
| GET "proxy/google-places/{path}" | "https://maps.googleapis.com/maps/api/{path}". Eg: "place/autocomplete/json", "place/details/json", "place/photo", "place/nearbysearch/json". | The "Google address" search and "GoogleSearch" Menu Items. |
| POST "proxy/google-air-quality/{path}" | "https://airquality.googleapis.com/{path}". Eg: "v1/currentConditions:lookup", "v1/forecast:lookup". | "GoogleAirQuality" Menu Items. |

The geocoding functions call "https://maps.googleapis.com/maps/api/geocode/json" directly from the API. So the key needs the Places API, the Air Quality API and the Geocoding API enabled in Google Cloud for all three features to work.

Without the key, both proxies return a 404 error with the code "NotFound". You can read about Data Mapping functions in [Data Mapping](/apidatamapping).

## GooglePhotogrammetry

The "GooglePhotogrammetry" key loads Google Photorealistic 3D Tiles. Navigator loads that tileset in one of two ways:

- When the account has its own "CesiumIon" key, through Cesium Ion. The Google key is not used.
- Otherwise, when "GooglePhotogrammetry" is set, through the "proxy/google-tiles/" proxy.

With neither key the tileset is not rendered. The "GooglePhotoTileset" Menu Item editor and the Google option when creating a Project View in Navigator both ask for this key and save it under "GooglePhotogrammetry".

| Proxy | Forwards to | Used by |
| --- | --- | --- |
| GET "proxy/google-tiles/{path}" | "https://tile.googleapis.com/{path}". Eg: "v1/3dtiles/root.json". Tile links in JSON responses are rewritten to come back through the proxy. | Google Photorealistic 3D Tiles. |

Without the key the proxy returns a 404 error with the code "NotFound".

## Key restrictions

The three proxies send the account's API URL as the "Referer" header to Google. If you restrict the key by HTTP referrer in Google Cloud, allow the account's API URL, not the Navigator URL.

## Set the keys

Save each key with its own request.

### Set the Google API key

```http
POST https://{accountId}.api.nextspace.host/programkey
```

**Requires:**

- Account ID: Account ID must be specified in the subdomain of the request url.
- Logged in user auth token: A token for an active user session on the account, sent as "Authorization: Bearer <token>".

| Parameter | In | Required | Description |
| --- | --- | --- | --- |
| `{accountId}` | path | yes | The account id of the account to perform the request on. |

**Example request body**

```json
{
    "ProgramId": "GoogleApi",
    "Key": "your-google-api-key"
}
```

**Response**

```typescript
// The response is the saved Program Key record.
```

**Javascript example**

```javascript
const url = "https://{accountId}.api.nextspace.host/programkey";
const method = "post";
const token = "your-token";
const body = {
    "ProgramId": "GoogleApi",
    "Key": "your-google-api-key"
};

async function doRequest(type, url, body, token) {
    const headers = {
        "Authorization": `Bearer ${token}`,
        "Content-Type": "application/json"
    };
    const options = {
        method: type,
        headers: headers,
        body: body ? JSON.stringify(body) : null
    };
    const res = await fetch(url, options);
    const json = await res.json();
    return json;
}

doRequest(method, url, body, token).then((res) => {
    console.log(res);
}).catch((err) => {
    console.error(err);
});
```

### Set the Google Photorealistic Tiles key

```http
POST https://{accountId}.api.nextspace.host/programkey
```

**Requires:**

- Account ID: Account ID must be specified in the subdomain of the request url.
- Logged in user auth token: A token for an active user session on the account, sent as "Authorization: Bearer <token>".

| Parameter | In | Required | Description |
| --- | --- | --- | --- |
| `{accountId}` | path | yes | The account id of the account to perform the request on. |

**Example request body**

```json
{
    "ProgramId": "GooglePhotogrammetry",
    "Key": "your-google-api-key"
}
```

**Response**

```typescript
// The response is the saved Program Key record.
```

**Javascript example**

```javascript
const url = "https://{accountId}.api.nextspace.host/programkey";
const method = "post";
const token = "your-token";
const body = {
    "ProgramId": "GooglePhotogrammetry",
    "Key": "your-google-api-key"
};

async function doRequest(type, url, body, token) {
    const headers = {
        "Authorization": `Bearer ${token}`,
        "Content-Type": "application/json"
    };
    const options = {
        method: type,
        headers: headers,
        body: body ? JSON.stringify(body) : null
    };
    const res = await fetch(url, options);
    const json = await res.json();
    return json;
}

doRequest(method, url, body, token).then((res) => {
    console.log(res);
}).catch((err) => {
    console.error(err);
});
```

---

Urls on this page are resolved for account `{accountId}`.
Site index: https://docs.nextspace.host/llms.txt · whole site in one file: https://docs.nextspace.host/llms-full.txt
Human-readable version of this page: https://docs.nextspace.host/thirdpartykeysgoogle
