Google Distance Matrix API

  • 0
  • 2
  • Question
  • Updated 2 years ago
  • Answered
I would like to see if there is a way for me to create an API that will call into Google Distance Matrix API and return the distance a worker's home is from the job site. I was able test the API in Postman but I am having a hard time adding it to Quickbase. Not sure if I should do this with a formula URL field or a webhook
Photo of @lin

@lin

  • 840 Points 500 badge 2x thumb

Posted 2 years ago

  • 0
  • 2
Photo of Matthew Neil

Matthew Neil

  • 31,678 Points 20k badge 2x thumb
Generally this requires custom coding depending on your exact needs.  

Are you looking to just have a button that pulls up the map w/ directions?   (this is an easy button, that I can share if needed)

Or something that is automatic when a worker is assigned to a job site?  (This is much more advanced)
Photo of Jacob

Jacob

  • 758 Points 500 badge 2x thumb
The first button sounds interesting if you are willing to share it I would love to see how it works!  Thanks!
Photo of @lin

@lin

  • 840 Points 500 badge 2x thumb
Matthew,
Thanks for your resoonse!
I am looking for something that will go to google and get the distance when a worker is assigned to the job. Can you give me some pointers?
Photo of Matthew Neil

Matthew Neil

  • 31,678 Points 20k badge 2x thumb
https://developers.google.com/maps/documentation/javascript/3.exp/reference

This is something we have done several times.  If you need help implementing this on your app, feel free to contact me ( Matthew@cirrusops.com) or another QuickBase Developer if you choose.
Photo of @lin

@lin

  • 840 Points 500 badge 2x thumb
Thank you!
Photo of Matthew Neil

Matthew Neil

  • 31,678 Points 20k badge 2x thumb
Directions Button,

This is formula URL button:

"https://www.google.com/maps/dir/"&URLEncode([Resource - Home Address])
&"/"&URLEncode([Project Location])

This is just a URL Button that will go to google maps.  Both of those field are full address fields being referenced.
(Edited)
Photo of @lin

@lin

  • 840 Points 500 badge 2x thumb
Thank you!
Any way I could get you to point me in the right direction for the automated way?
Can I use a webhook to get the information and then post it somehow on to a field?
Again, thanks for taking the time to help me!!
Photo of Jacob

Jacob

  • 758 Points 500 badge 2x thumb
I agree with this is there anyway to enter two addresses on the QuickBase record and have the Google API calculate the distance and then have it shown on the QuickBase record? 
Photo of Matthew Neil

Matthew Neil

  • 31,678 Points 20k badge 2x thumb
Yes, I do it with a code page.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 63,962 Points 50k badge 2x thumb
We are all hoping for a day soon where QuickBase exposes the "geocoding" (lat & long) of an Address field to use as an automatically populated field associated with an Address field.  When that day comes, this will be a lot easier to calculate the distance - not the driving distance, but at least the "as the crow flies" distance - a straight line.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 29,964 Points 20k badge 2x thumb
This is easy to do with script. I have to travel now but I will either post an example I did earlier or create a new demo.

Trivia: Most of you probably don't know that my business is named after the esoteric trigonometric function haversine which is used in calculating the great circle distance between two points on a sphere:



https://en.wikipedia.org/wiki/Haversine_formula

Numb3rs Scene: Everything is numbers, Math is everywhere
https://www.youtube.com/watch?v=vFRTgr7MfWw
Photo of @lin

@lin

  • 840 Points 500 badge 2x thumb
I know... It would be great if they would at least add some Trig functions in there (Sin, Cos...) that way we could use them to calculate as crow flies.
Photo of @lin

@lin

  • 840 Points 500 badge 2x thumb
An example would be great! 

Thank you!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 63,962 Points 50k badge 2x thumb
Here is the non trigonometry solution. No Sin and Cos requires because in fact the earth is flat. https://community.quickbase.com/quickbase/topics/is-there-a-formula-within-quickbase-that-would-calc...
Photo of @lin

@lin

  • 840 Points 500 badge 2x thumb
This is awesome! The earth is flat... The people in the middle ages were right after all :)
I'll try your approach.

Thank you!
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 29,964 Points 20k badge 2x thumb
The Earth is an oblate spheroid.