Is there an easy way to calculate the distance between two points (addresses)?
We use a google script to calculate the distance between addresses using google sheets.
(See Script Below)
Is there a way to have AppSheet call the script and get the distance in a cell?
function jobdistance(start_address, end_address){
/*
* Get Distance between 2 different address.
* @param start_address = Address as string. Ex: "1350 SW 57th ave, miami, Florida";
* @param end_address = Address as string. Ex: end_address = "5880 SW 27th Street, Miami, Floirida";
* @ CUSTOMFUCNTION
*/
var mapObj = Maps.newDirectionFinder();
mapObj.setOrigin(start_address);
mapObj.setDestination(end_address);
var directions = mapObj.getDirections();
var meters = directions["routes"][0]["legs"][0]["distance"]["value"];
var miles = meters * 0.00062137;
var time = directions["routes"][0]["legs"]["value"];
return miles
} //end function jobdistance ***
Solved! Go to Solution.
My understanding is you have your cunstom function made by GAS like โ
Then for instance, you have start address in A2 cell and end address B2 cell, then you push your expression into C3 cell with
=jobdistance(A3, B2)
This is basically nothing to do with Appsheet, but how to deal with Google Spreadsheet.
User | Count |
---|---|
18 | |
10 | |
8 | |
6 | |
5 |