We are going to find the distance between two city or two point
01 we provide JavaScript you should copy and paste in your google sheet
02 then type command as mention bellow
then you can see below result
01 open google sheet
paste this code
const GOOGLEMAPS_DISTANCE = (origin, destination, mode) => {
const { routes: [data] = [] } = Maps.newDirectionFinder()
.setOrigin(origin)
.setDestination(destination)
.setMode(mode)
.getDirections();
if (!data) {
throw new Error("No route found!");
}
const { legs: [{ distance: { text: distance } } = {}] = [] } = data;
return distance;
};
=GOOGLEMAPS_DISTANCE(B4,C4,"driving")
Type this code
and drags to bottom
0 Comments