Ask GoogleMap for routing-infos

I would like to determine the distance and travel time between two addresses/coordinates given a particular means of transportation (car, bicycle, …) from a 4D application. As far as I know the Google Distance Matrix API should do the trick, but I don’t know how to integrate it in the 4D environment.

Ask Google to look up at Google-documentation

Paste the example from there
http://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver+BC|Seattle&destinations=San+Francisco|Victoria+BC&mode=bicycling&language=fr-FR&sensor=false
into your Browser-Window. Result is some JSON.

To achieve the same, write some 4D-code like this
C_TEXT($url;$received_T)
C_LONGINT($result_L)
$url:=“http://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver+BC|Seattle&destinations=San+Francisco|Victoria+BC&mode=bicycling&language=fr-FR&sensor=false“
$result_L:=HTTP Get($url;$received_T)

Your work then is to understand the URL and optimize the URL for your needs – like exchanging json just before the ? with xml and you’ll receive the same data as xml – and of course you need to parse the received JSON/XML.

If your are on Mac, starting with Mavericks, you could code like this
$url:=“http://maps.apple.com/?daddr=San+Francisco,+CA&saddr=cupertino“
OPEN WEB URL($url)
and learn here how it’s supposed to work.