# Distance by Postcode

⚠️ In order to use this option a valid API key must be added on the [plugin's settings page](/uni-cpo-4-documentation/usage/plugins-settings.md). The steps of how to get the API key are described on the page about [Google Map option](/uni-cpo-4-documentation/usage/options/google-map.md). The following API must be enabled:

:point\_right: Maps JavaScript API

&#x20;:point\_right: Geocoding API

This option has two modes: single and dual

![Two modes of the option](/files/-MR6oRmXR7r5n6L9E47D)

### Single mode

This mode should be used when you need to get distance between your postcode (origin) and user defined (destination). For instance, you want to get the distance for delivery service. You have to define origin's postcode and country in this case.

![](/files/-MR6pGnaDGm8a_RElA1Q)

### Dual mode

This mode should be used when you need to let user define both origin and destination postcodes and get distance between these two. In this case you have to define only country.

![](/files/-MR6qARsoXmKuuCRcsyS)

#### Why must I define country?

Google distance API works so you have to set country name explicitly, otherwise the will be wrong distance/calculation. This is the limitation of the API.

### Information about variables

This options' main variable holds **destination** postcode value. Additionally, the option has two special variables which ends with:

`...origin}` - origin's postcode

`...distance}` - distance between origin and destination, km

In dual mode origin is the first input and the destination is the second:

![](/files/-MR6ryyki272meIATBVT)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kb.moomoo.agency/uni-cpo-4-documentation/usage/options/distance-by-postcode.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
