Source: site.view [edit]
Function name: distance
Arguments: fromAddr,toAddr
Description: Calculates the distance in miles fromAddr toAddr
Page type: webl
Render function:   distanceRender
Module: global

Page source:

// Calculates distance using Distance24's distance calculator
//     URL[Distance24 Documentation|https://www.distance24.org/api.xhtml]


var P = GetURL(`https://www.distance24.org/route.json`,
   [. "stops"=fromAddr + "|" + toAddr .]);

var distMi = ToInt(Text(Elem(P, "distances")[0])) ? 0;
var duration = ToString(distMi div 60) + " hours and " + ToString(distMi mod 60) + " minutes";

[. distanceInMiles = distMi, duration=duration .];