Getting driving directions
With the vast availability of map services from Google, Bing, Yahoo!, and even MapQuest, getting directions is very easy. We will explore how to use the Google Directions API to generate driving directions from one place to another.
Note
First, we need the request URL of the Google Directions API. Based on the documentation, the request URL is as follows:
http://maps.googleapis.com/maps/api/directions/output?parameters
The output can be either JSON or XML, depending on which format of output we want our result to be. We will be using JSON for our example. There are also required parameters such as those described in the following table:
Parameter |
Description |
---|---|
|
Beginning address |
|
Destination address |
|
Indicator of whether or not the request is coming from a device or a location sensor; it can be either |
So, if we are going to get directions from Los Angeles, California to San Francisco, California, we need to use the...