Hi
Today I would like to share with you how to ensure the distance between two locations is within 5km.
Problem
User is asked to record his/her location and the location his/her planned to visit.
Objective
Make sure the second location is within 5km radius of the first location.
Step & Configuration
-
Create information
- Information type - Location
- location1
- location2
- Information type - Number
- latitude1
- longitude1
- latitude2
- longitude2
- distance (km)
- Information type - Location
-
To store more decimal places for latitude and longitude, select latitude1, open the advanced settings, type ‘5’ for the column of decimal places.
(Repeat this step by replace latitude1 with longitude1, latitude2, and longitude2)
**It is not necessary to change to 5 decimal places, you may set as your preferences.
**If you prefer to have 2 decimal places, you can just skip this step.
-
Configure a form for create
i. Click ‘Start here’ in Basic.
ii. Click ‘click to add’, then select the information created.
iii. Set location1 and location2 as required field. (Mouse over the information name, then click the star button)
iv. Set the formula for latitude1, longitude1, latitude2, and longitude2. (Mouse over the information name, then click the mathematics symbol. Then key in the formula, such as #Form#location1[‘lat’] for latitude1, and #Form#location1[‘lng’] for longitude1.)
v. Hide the information distance (km) from the form. (To avoid the user key in the value.)
vi. Click ‘SAVE’ after done. (To save the form.)
-
Create an automation to calculate the distance between the 2 recorded location.
i. Clicking the thunder icon to create new automation.
ii. Toggle ‘Enable Advanced’.
iii. Define the formula in the column of ‘Trigger Before Script’.
iv. Click ‘OK’ after done.
-
Then, click ‘SAVE’ at the top right of the module.
Sample Result
Congratulations! You have done to define an automation to limit the distance between 2 location.