Washington via WMATA
March 7th, 2014 [programming]
What would the Washington, DC region look like if you never went further than 500 meters from a Metro station? Well, there’s an app for that! I was inspired by a car-free friend who pointed out the difficulty of finding a Metro-accessible dentist when moving to DC. So, let’s put the Internet to work to make that simpler.
I used the Places Library of the Google Maps API to discover dentist locations for a geographic region. To connect to Metro stations, I submitted a separate search for each Metro station. Of course, “dentist” is just one option for a type of place. The API has 96 Supported Place Types, from airport to zoo.
Try the Metro Places app to discover businesses near your favorite Metro station. To make your own search, select the type of place from the drop-down list, which station you want and how many stops you’re willing to travel (I assume no one wants to transfer), and how far you’re willing to walk from the end-station. You can display the results as a collection of icons or a heat map, or both. The icons returned are part of the Places API, such as a giant tooth for dentists, and a martini glass for bars.
The Metro-search works only for Washington, DC, but you can use the program elsewhere by using the “find places on map,” which uses the current bounds of the map to query the Places API.
Every search you conduct is cumulative; that is, the old icons stay on the screen until you hit “clear.” So, to search the entire Metro system, you could search 20 stops from Metro Center (to cover the Red, Orange, and Blue lines) and then 20 stops from Archives (to cover the Yellow and Green lines).
The heat map get recalculated every time new data is added. A slider lets you control the radius of each point.
Because the Places API limits how many queries I can make, the icons aren’t added instantaneously. When the Metro icon first appears it will have a faint blue outline, meaning I am waiting for a response from Google. Once I get a valid response, it is outlined with silver if places are found nearby, and red if nothing was found for that station. If Google send back an “OVER_QUERY_LIMIT” status code, I wait a few seconds before trying again. I get to run 10 queries in the first second, and it slows down further after that. (The program gives up eventually.)
The Places API does contain noticeable errors, or at least questionable decisions of what qualifies for a given category.
When you hover over a place’s marker icon, the infowindow will display a link for walking directions. This uses the Google Directions web site, which you can customize for default directions using the URL query string.
For people who rely on Metro to get around, the Metro Places map helps reveal what Washington, DC looks like to them.