Google Maps Platform Connector
The Google Maps Platform Connector in an inbound Connector that allows you to validate addresses, retrieve postal addresses, and calculate distances with Google Maps Platform Service in BPMN process.
Create a Google Maps Platform Connector task​
To use a Google Maps Platform Connector in your process, either change the type of existing task using the wrench-shaped Change type context menu or create a new Connector task by using the Append Connector context menu. Follow our guide on using Connectors to learn more.
Make your Google Maps Platform Connector executable​
To work with the Google Maps Platform Connector, choose the required operation type in the Operation section and enable the required Google Service API (which depends on the operation). Set the API key in the Authentication section and complete the mandatory fields highlighted in red in the Connector properties panel.
All the mandatory and non-mandatory fields and required settings depending on the operation selection you choose are covered in the upcoming sections.
Authentication​
In the Authentication section, set the relevant API key. See the official documentation for more information on creating an API key.
We advise you to keep your authentications and secrets data safe and avoid exposing it in the BPMN XML file by creating a secret:
- Follow our guide for creating secrets.
- Name your secret (i.e
GOOGLE_MAPS_PLATFORM_API_KEY
) so you can reference it later in the Connector.
Operation types​
Validate address​
This operation allows you to validate an address and its components, standardize the address for mailing, and determine the best known geocode for it. To use this operation, enable the Google Address Validation API. See the official documentation for more information on enabling the Google API.
Get place ID​
This operation allows you to get the Google Maps place ID by address. To use this operation, enable the Google Places API. See the official documentation for more information on enabling the Google API.
Calculate distance​
This operation allows you to calculate a distance between two place IDs. To use this operation, enable the Google Directions API. See the official documentation for more information on enabling the Google API.
Usage​
Address validation, formatting, getting postal address​
- Select Validate Address from the Operation type dropdown in the Operation section.
- Populate the Authentication section as described in the respective section.
- (Optional) In the Input section, set Region Code (i.e
US
). You can find supported region codes here. - (Optional) In the Input section, set Locality, an incorporated city or town political entity (i.e
Mountain View
). - In the Input section, set Address, an incorporated city or town political entity (i.e
1600 Amphitheatre Pkwy
). - In the Output section set Result Variable or Result Expression. See the response mapping documentation to learn more.
- Find a full example of the Google Maps Platform Connector response here. To get postal address and formatted address, set to Result Expression in the FEEL expression:
{
formattedAddress: response.body.result.address.formattedAddress,
postalAddress: response.body.result.address.postalAddress
}
Get place ID​
- Select Get Place ID from the Operation type dropdown in the Operation section.
- Populate the Authentication section as described in the respective section.
- In the Input section, set Address. This address can be
formatedAddress
, which you can get using this example. - In the Output section in the Result Expression property, the following expression is preset:
{
placeId: response.body.candidates[1].place_id
}
In this way, the response of this method will contain a mapping from the variable 'placeId' and the ID of the place:
{
"placeId": "place....."
}
Calculate distance​
- Select Calculate Distance from the Operation type dropdown in the Operation section.
- Populate the Authentication section as described in the respective section.
- In the Input section, set Destination, the place ID value that you want to use as the destination for calculating distance.
- In the Input section, set Origin, the place ID value that you want to use as the starting point for calculating distance.
- Select the unit system to use when displaying results from the Units dropdown in the Input section.
- Select the transportation mode to use when calculating distances and directions from the Mode dropdown in the Input section.
- In the Output section, set Result Variable or Result Expression. See the response mapping documentation to learn more.
- Find a full example of the Google Maps Platform Connector response here. To get a distance, set Result Expression in the FEEL expression:
{
distance: response.body.routes[1].legs[1].distance.text
}
Using Google Maps Platform Connector best practice​
There is no guarantee a queue item will be processed right away. In that case, we suggest building your BPMN diagram to periodically retry polling. To learn more, see the entry titled Solution with Timer and Loop on the Camunda BPMN examples page.
To avoid performance issues, it is recommended to limit the number of loop retries.