Concept for 5km delivery constraint & time taken to travel

Hi Gliders,

Inspired by this posts regarding how some businesses can’t offer a delivery outside their 5km radius.

I developed a solution to calculate distance between customer’s input address and
the business’ fixed address. The use of postcode was proposed in some threads, but I don’t think it would have the same effect as taking the exact distance via Google.

My test app link: geocodetest.glideapp.io

Demonstration video:

ezgif-1-223b6941057e

User flow:

  • Sign in via mail, if user has not filled their name, address and phone number, order options won’t be shown. They can fill up those information via the Profile tab. Thanks @Robert_Petitto for his instructions on this!

  • Once they have “signed up”, a small profile of them will be shown on the top of the “Dishes” tab, containing their address, how many minutes it takes to deliver to them, and a message for them to see if delivery is available for their address or not.

  • If they are more than 5km away, the options for ordering won’t be shown, and vice versa. They can edit their address and phone number via the item in “Dishes” tab as well, and it takes some seconds for recalculation once they have entered a new address.

  • I did not develop the further steps in the process (ordering, add to cart, etc.) since this is concentrated on how to restrict orders outside of a certain radius.

Data flow:

  • Address, phone number, email and avatar (avatar is not required) will be assigned to a “User Profile” tab in the Sheets.

  • The script I used will be in charge of calculating the distance and travel duration for user’s address to the fixed business address. For demonstration, the fixed address was set to “Santiago Bernabeu Stadium”.

  • When the user edits their delivery info in the “Dishes” tab, their user profile info will be edited as well. Next time they log in, the address will be the last one they used.

  • Calculation of distance and travel time will be done automatically thanks to another script that copies the formulae down (since they do not work with arrayformula).

This was done with the help of Google Scripts. If any people want to integrate this to their app, please drop me a message here or via email ariesarsenal@gmail.com.

6 Likes

Thank you so much to @Robert_Petitto and @Jeff_Hager, I struggled with the flow at first but ultimately I think I made it good enough to integrate to whoever needs this.

2 Likes

Hi @Robert_Petitto, I just checked your input, it seems like when you are too far away (like USA and Spain) in this case the script can’t return a value.

When I changed the fixed address to an address closer to your input, it worked.

Nice. I’d like to see this work dynamically. Get the distance between two people, let’s say. Only thing is that scripts can’t see Glide data columns.

1 Like

Yeah, currently there’s no way to get Glide data back to script so that’s it.

Furthermore, if we can get the value of user’s current location then this would make the flow better. Users don’t have to manually enter the address anymore.

2 Likes

@ThinhDinh: This is amazing, thank you for sharing such detailed flows!

For our use case, we’re looking to do something along similar but less complex lines, i.e. enable users to search venue listings x miles/hours distance to venues from whatever town/city or postcode they enter, e.g. 2 hours from London, or 50 miles from Manchester etc.

Does the key to making this work lie in Google Scripts?

1 Like

Yes, it lies in the scripts. If you’re interested, drop me a personal message or email me and we can discuss about setting it up for you.

1 Like

@ThinhDinh: Thanks, I may take you up on that but right now we’re getting all our ducks in order first as the distance feature isn’t a ‘must have’ for the app at the moment.

1 Like

No worries, feel free to contact me when you need to implement it.

@ThinhDinh: thank you! Yes, it will be best when we have a few listings to experiment with.

1 Like

Nice job @ThinhDinh

I was doing something similar but I stopped it due to I had to finish another project. Good to see this idea working fine on other APPs

Let me share my original idea (what I had developed so far to compare to yours):

  1. I saved all my customers (stores/places) in my GS along with their coordinates (I supposed that working with coordinates instead addresses the searching will be faster and more accurate, it was my plan B)
  2. The user writes his address using an Entry Text Field and the searching begins. I let the user use any address instead using the one used in his profile (just a matter of style, no problem)
  3. Using an own function in GS I look for distances (Km) from User address to my customers (each one), something like
    =DistanceKm(UserAddress, CustAddress)
  4. via Query() I get the 4-5 closest places/stores (I could show more places but I was thinking as my user on my APP) and show those few options on screen
  5. I was thinking of letting a choice component to set the distance to search. I mean, my scope searching could be:
  • 2 Km
  • 4 km
  • 7 km
  • 10 Km
    to give more chances to my user to decide where to go or ask for. Again, it’s just a matter of style.

I stopped my APP at step 4 so far but I wonder if your APP was using the same way I was thinking days ago (I use Query() instead of filters and other things than make any sheet something bigger)??

Thanks
Feliz día!

1 Like

Hi Gustavo, nice idea you have there.

I agree that coordinates would present a more accurate solution, that’s for sure. That’s why getting current user’s coordinates would give our ideas much better results.

At first I got the user to write his address, that would change per order, but later changed it to this. Yeah it’s a matter of style, no problem.

I like your idea, let me know if I can help.