Calculation of itinerary time?

Hello everyone,

I have a question. Is it possible in Glide to calculate the time of the itinerary between two addresses by selecting the type of transport (bike, car, commun transport etc) like we can do it in GoogleMap?

Thanks in advice for your answers.

1 Like

As of now it’s not possible, but a script in Google Sheets can return what you want, albeit you have to take into account that there’s a limit of calculation request per day and a lag to update that data to your app.

Thank you for the answer and sorry for my belated replay.
I’m not sure that (or I don’t know yet how) we can count the spending time by transport between two addresses in Google Sheets. For exemple, I need to do the request linked to filled data by user for planning:
I know that the person 1 is at 2 p.m in address 1. I need to be sure that this person 1 can be at 3 p.m. (and not later) in address 2 and he uses the bicycle. The same request for the person 2 who uses the bus, for example, etc. The calculation should tell me , for exemple: the person 1 can arrive at 3 p.m. in the address 2/ the person 2 can arrive at 2. 50 p.m. (or at 3.15 p.m.) in the address 2 etc…

I know that Google map propose to intergrate to application the requests but I am not sure that we can intergrate it to Glideapps.

Thanks again for your answer.

This needs a script of its own.

Go to Tools > Editor and add this script to your dashboard.

* Get the distance between 2 different addresses.
* @param {string} origin_address The origin/start address as string Eg. "102 Petty France, London, SW1H 9AJ".
* @param {string} destination_address The destination/end address as string Eg. "10 Whitechapel High Street, London, E1 8QS".
* @param {string} travel_mode The mode of travel as string. Default: DRIVING. Options: BICYCLING, TRANSIT, WALKING.
* @param {string} return_type The return type as string. Default: MILES. Options: KILOMETERS, MINUTES, HOURS, STEPS.
* @return the distance between 2 different addresses.
* @customfunction
function GOOGLEDISTANCE(origin_address,destination_address,travel_mode,return_type) {
  var travelMode = "";
  switch(travel_mode) {
case "bicycling":
  travelMode = Maps.DirectionFinder.Mode.BICYCLING;
case "DRIVING":
case "driving":
  travelMode = Maps.DirectionFinder.Mode.DRIVING;
case "TRANSIT":
case "transit":
  travelMode = Maps.DirectionFinder.Mode.TRANSIT;
case "WALKING":
case "walking":
  travelMode = Maps.DirectionFinder.Mode.WALKING;
  // Default to driving
  travelMode = Maps.DirectionFinder.Mode.DRIVING;
  //return "Error: Wrong travel mode";

  // var auth = Maps.setAuthentication(clientId, signingKey);
  var directions = Maps.newDirectionFinder()

  if (directions.status !== "OK") 
return 999999
  var route = directions.routes[0].legs[0];
  var time = route.duration.value;
  var distance = route.distance.value;
  var steps = {
  return step.html_instructions.replace(/<[^>]+>/g, "");
  switch(return_type) {
case "MILES":
case "miles":
  return distance * 0.000621371;
case "kilometers":
  return distance / 1000;
case "MINUTES":
case "minutes":
  return time / 60;
case "HOURS":
case "hours":
  return time / 60 / 60;
case "STEPS":
case "steps":
  return steps;
  // Default to miles
  return distance * 0.000621371;
  //return "Error: Wrong return type";


Then go back to your Sheet, for every itinerary calculation you can call a function like this.


With A2 being the origin, B2 the destination.


Waw! Thank you for this explication and solution! :pray: :star_struck:
It is true, I haven’t thought about writing my own script yet. :thinking:


Let me know if you need further help to set this up, I will help :wink:


Thank you :slight_smile:

1 Like