AllTravel
Comments
 Share
The version of the browser you are using is no longer supported. Please upgrade to a supported browser.Dismiss

 
£
%
123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Still loading...
ABCD
1
Driving Distance Ready Reckoner1function DrDist (Orig,Dest) {Use (Origin, Destination)
2
This tool has been produced with the help of Google Maps and Google Apps Scripts see:-2var n = Orig.search(",");Find the place of the comma in origin Lat,Long
3
https://developers.google.com/apps-script/reference/maps/direction-finder3var OLat = Orig.substring(0,n);Get the origin Latitude as string
4
The actual apps script used is shown on the right. It would work without lines 2 to 13 but4var OLatn = Number(OLat);Change to number,
5
I was getting errors but still got the same number of errors when the lat long was5var len = Orig.length;Find length of Origin string
6
explicitly worked out. Just had to repeat some of the cell calculations.6var OLon = Orig.substring(n+1,len);Get origin Longitude as string
7
7var OLonn = Number(OLon);Change to number,
8
In the Distances sheet the leagues are selected in column 'A'.8n = Dest.search(",");Lines 8 to 13 do the same as 2 to 7 for destination.
9
Put 'O' for teams in the Original league and 'T' for teams in the Target league.9var DLat = Dest.substring(0,n);
10
The target league is the league a team may be moved to from the original league.10var DLatn = Number(DLat);
11
The distances are totalled for teams in the original league to get to teams in the11len = Dest.length;
12
target league.12var DLon = Dest.substring(n+1,len);
13
The totals can be seen for travel out and back in the 'Totals' sheet. Put '1' in cell 'M1' to13var DLonn = Number(DLon);
14
sort the teams, lowest mileage first.14var directions = Maps.newDirectionFinder()Call google direction finder
15
15.setOrigin(OLatn,OLonn)set origin lat and long
16
16.setDestination(DLatn,DLonn)set destination lat and long
17
17.setMode(Maps.DirectionFinder.Mode.DRIVING)set the mode
18
18.getDirections();get the information
19
19var d = directions.routes[0].legs[0].distance.value;extract the distance in metres.
20
20return d /1000 * 0.621371;change to miles.
21
21}
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Loading...
 
 
 
Help
Distances
Totals
LatLong