How to validate customer shared GPS location against selected delivery town?

:bullseye: What is your goal?

I have a Shopify cart form that collects delivery details for local delivery orders.

The customer selects a delivery town and may optionally share their current location from the cart page.

The location is saved as order note_attributes and then imported into Google Sheets by Make.

Fields:

delivery_town
full_delivery_address
delivery_geo_lat
delivery_geo_lng
delivery_maps_url
delivery_address_source
delivery_address_status

I would like Make to help validate whether the shared location is reasonably close to the selected delivery town.

Example logic:

0–20 km from selected town center: OK
20–35 km: needs_review
over 35 km: likely wrong / out_of_area

Questions:

What is the best way in Make to calculate distance between customer lat/lng and a fixed town center lat/lng?
Should I store town center coordinates in Google Sheets and look them up based on delivery_town?
Is there a simple formula/module to calculate distance between two coordinates?
Should I use Google Maps API, or is a simple Haversine formula enough?
How would you structure the scenario so that Make writes a status such as location_ok, needs_review, or location_far into Google Sheets?

I do not need route optimization here. I only need a simple distance validation for operational review.

:thinking: What is the problem & what have you tried?

I have not built this part yet.

I already have a Shopify cart form that saves delivery details as cart attributes, and these attributes become order note_attributes. Make then imports the order data into Google Sheets Orders_Log.

I am planning to add an optional “Share my current location” button in the Shopify cart. If the customer accepts browser geolocation, Shopify should save:

  • delivery_geo_lat
  • delivery_geo_lng
  • delivery_geo_accuracy
  • delivery_maps_url
  • delivery_address_source
  • delivery_address_status

These fields would then arrive in Make and be written into Google Sheets.

The problem I want to solve is operational validation.

The customer selects a delivery town, for example Mombercelli, and may also share their current GPS location. I want Make to check whether the shared location is reasonably close to the selected delivery town.

Example desired logic:

  • 0–20 km from selected town center: location_ok
  • 20–35 km: needs_review
  • over 35 km: location_far / possible wrong town or out of area

I am not sure about the best Make architecture.

Questions:

  1. Should I store town center coordinates in a Google Sheets table and look them up based on delivery_town?
  2. Can Make calculate distance between two coordinates with a formula, for example using the Haversine formula?
  3. Is a simple distance formula enough, or should I use Google Maps API?
  4. How should I write the result back into Google Sheets, for example location_status = location_ok / needs_review / location_far?
  5. Should this validation happen after the order is created, or during the Shopify cart flow?
  6. What module sequence would you recommend in Make?

Expected flow:

Shopify order / note_attributes
→ Make
→ Google Sheets Orders_Log
→ Look up selected town center coordinates
→ Compare town center lat/lng with customer shared lat/lng
→ Calculate distance
→ Write location_status and distance_km into Orders_Log

:clipboard: Error messages or input/output bundles

There is no error message yet. I am asking before building this part.

Current working flow:

Shopify order
→ Make
→ Google Sheets Orders_Log

Current fields already imported into Google Sheets:

  • delivery_town
  • delivery_area
  • delivery_window
  • accommodation_name
  • full_delivery_address
  • customer_whatsapp
  • delivery_notes

Future optional geolocation fields:

  • delivery_geo_lat
  • delivery_geo_lng
  • delivery_geo_accuracy
  • delivery_maps_url
  • delivery_address_source
  • delivery_address_status

Example input:

delivery_town: Mombercelli
delivery_geo_lat: 44.817000
delivery_geo_lng: 8.294000
delivery_maps_url: Google Maps

Expected output written back to Google Sheets:

location_distance_from_selected_town_km: 8.5
location_status: location_ok

or:

location_distance_from_selected_town_km: 28.4
location_status: needs_review

or:

location_distance_from_selected_town_km: 48.2
location_status: location_far

I need guidance on the correct Make module sequence and formula/API approach.

If you have postal codes, the easiest solution is to use something like the API Freaks Zip Code Distance API. You’ll need to use the Make HTTP app to connect.

Pricing is reasonable, starting at $0.63 per 1000 requests on a $10 monthly plan. There’s also a 10,000 credit free trial.

Alternatively you could download a free postal code to Lat/Long dataset from Geonames and load it into a Data Store. You’d then use an Equirectangular Approximation (not as accurate as Haversine but good for up to several hundred kilometers).

You’d then use the following style of formula in a Set Variable module to calculate the distance:
{{6371 * sqrt((((1.lon2 - 1.lon1) * 3.14159 / 180) * cos(((1.lat1 + 1.lat2) * 3.14159 / 180) / 2)) * (((1.lon2 - 1.lon1) * 3.14159 / 180) * cos(((1.lat1 + 1.lat2) * 3.14159 / 180) / 2)) + (((1.lat2 - 1.lat1) * 3.14159 / 180) * ((1.lat2 - 1.lat1) * 3.14159 / 180)))}}