> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Geolocation

> Client-mode REST API connectors for Google Maps Platform: geocoding, elevation, time zone, device geolocation, Routes API ETAs and matrices, Roads API snap to roads and speed limits, Places search, Address Validation, Weather and Air Quality

Technical Preview

## Overview

Client-mode REST API connectors for Google Maps Platform: geocoding, elevation, time zone, device geolocation, Routes API ETAs and matrices, Roads API snap to roads and speed limits, Places search, Address Validation, Weather and Air Quality.

This is one of the templates in the Google Maps Platform REST API app (`google-maps-platform`). Deploy it alongside the other connectors of that app when they depend on each other (for example a token connector plus an API connector).

> [!NOTE]
>
> Not yet verified against the live vendor API: No Google Maps Platform API key: every event needs a key. All 18 events were sent to the real Google hosts with a dummy key and got Google's invalid-key answer (classic web services 200 status REQUEST\_DENIED, newer APIs 400 API\_KEY\_INVALID), but no keyed call could run.

## Auth

* **schemes**: \["API key query parameter key= (Geocoding, Elevation, Time Zone, Geolocation, Roads, Address Validation, Weather, Air Quality)", "X-Goog-Api-Key header + required X-Goog-FieldMask header (Routes API, Places API (New))"]
* **secrets**: \["GOOGLE\_MAPS\_API\_KEY"]
* **note**: OAuth 2.0 service accounts not packaged (Fleet Engine and Route Optimization need OAuth).

## Template parameters

| Placeholder | Type | Description | Required |
| - | - | - | - |
| `RouteName` | string | Name of the Google Geolocation connector | no |
| `BaseUrl` | string | Google Geolocation base URL without trailing slash (e.g. [https://www.googleapis.com](https://www.googleapis.com)) | yes |

`BASE_ADDRESS` default: `https://www.googleapis.com`.

## Events

| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
| - | - | - | - | - | - |
| `Geolocate` | POST | `/geolocation/v1/geolocate?key={value.json.apikey}` | `fleet/google-maps/geolocate` | `fleet/google-maps/geolocate/response` | `apikey`, `body` |

## Deploy

Get the template card (JSON with `template` and `metadata`) from the broker, then deploy the connector:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_pub -t '$SYS/Coreflux/Command' -m "-routeCode GOOGLE_GEOLOCATION"
```

The deployable connector from the REST API app, with `BASE_ADDRESS` already filled in:

```lot theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ROUTE GoogleGeolocation WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://www.googleapis.com"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '30'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT Geolocate
        WITH SOURCE_TOPIC "fleet/google-maps/geolocate"
        WITH DESTINATION_TOPIC "fleet/google-maps/geolocate/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/geolocation/v1/geolocate?key={value.json.apikey}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
```

Deploy it with `-addRoute` (do not include `ADD METADATA`).

## Usage example

Call `Geolocate` by publishing a JSON payload to its request topic, and read the reply on the response topic:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_sub -t 'fleet/google-maps/geolocate/response' &
mosquitto_pub -t 'fleet/google-maps/geolocate' -m '{"apikey": "<apikey>", "body": {}}'
```

## Related

* [REST API Connectors](/latest/lot-language/routes/rest-api-routes)
* [REST API Apps catalog](/latest/lot-language/routes/rest-api-apps)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.