Mystery Incorporated


Programming, photography, news, culture, and cartoons

home | rss | atom

Add to Google

Comparing Driving, Walking, Biking and Transit


December 17th, 2012 [programming]

modesGoogle maps gives you four options for showing directions: by car, by public transit, walking, and bicycling. My Side-by-Side Router shows all four at the same time.

Enter your starting and ending points. You can enter a specific address or any description that Google’s geocoder can figure out. The four routes are shown in different colors (in some cases they will overlap). Use the “steps” buttons to show pins at each step; clicking on the pins will show the specific directions for that step. Some cities will not have any transit information.

The screen also shows the estimated travel time and distance for each mode.

For quick demos, change the “anyplace” drop-down menu to a given town, for quick location choices.

Update: Thanks to a suggestion, I’ve simplified the user interface so instead of typing in addresses, all you have to do is click on the map. The drop-down on the right determines whether to just use the latitude & longitude coordinates, or to reverse-geocode to find an address. Geocoding adds a brief delay, and doesn’t always succeed in finding an address. If the result is too vague, some of the mode options may not be drawn.

You can also now drag the start and end point to adjust the routes’ endpoints.

The program was written in JavaScript, using the Google Maps API. I used their new feature for Styled Maps, which lets you control the map’s colors, line features, and which features get labels. I also used the Google Chart Tools to create custom pin colors. The routing decisions are made via a Google object belonging to their DirectionsRenderer class.

What would make the program more interesting or useful? Leave your thoughts in the comments below.

Tags:

4 Responses to “Comparing Driving, Walking, Biking and Transit”

Site by M.V. Jantzen
mvs202 "at" gmail.com
twitter.com/mvs202