MBTA Google Maps Experiment
Since Google so graciously released an API for their excellent mapper last week, I figured I’d take it for a spin. I had written some code to prise nearby stops and bus times from the MBTA’s handy trip planner a while back, and so I decided to glom them together and see what happened. Here’s the result.
Here’s how it works: You pan and zoom around the map until you find an area of Boston you’re interested in, and then click Recalculate Stops. The map will then update to show stops within a half-mile of the center of the map. You can click on any of these points to get the next three times for the routes at that stop. Seems to work for bus, subway, commuter rail, and ferry routes.
It’s vaguely useful for an afternoon’s work, though there are a few quirks:
- Stops which are too close to each other may be impossible to click on (sometimes you can tell because their shadows look darker)–I’d probably have to write some code to combine these into a single marker.
- The same subway line is often broken into separate listings. This is something that the trip planner does, perhaps to get around some sort of database limitation? In any case, this can probably be remedied with more code on my end.
- Other than the subways, each route is listed only once per map, at the nearest stop. This means that even though the 87 might stop in several places within the mile-wide area being searched, you’ll only see the stop that’s nearest to the center of the map.
- There’s no way to jump to a particular address. The Google Maps API currently doesn’t do geocoding, though I could integrate geocoder.us or the trip planner’s built-in geocoder given a little more time.
- Clicking the
Recalculate Stopsbutton isn’t the smoothest thing in the world. My first attempt updated the query automatically when you panned the map, but that made things a bit too jumpy as you panned around to get a better look at the stops and surroundings. Needs more work. - The iconography and layout could be better.
- I have no official connection with the MBTA, and they could break the scraping code that this depends on at any time. I hope they’ll be more flattered than offended if they find this.
All in all, the Maps API is pleasant to work with, though the way that Google binds API keys to individual directories keeps you from being able to just copy the source files from your test directory to your deployment directory. But that’s the most minor of nitpicks, given that you can dispense keys for all the directories you want. They’ve done a great job, and I think we’re going to see an even bigger wave of new mapping apps in the coming weeks.

July 3rd, 2005 at 8:55 am
The guy from Yahoo Local at Where 2.0 alleged that Yahoo Maps’ API supported geocoding (well, that you could pass it addresses). http://developer.yahoo.net/maps/
I haven’t ever done much DHTML programming… how much learning curve am I going to face hacking on this stuff? Did you find the on-line tutorials sufficient, or should I invest in a book?
July 3rd, 2005 at 2:38 pm
Yeah, but Yahoo’s mapper isn’t nearly as swank as Google’s.
The Google Maps API is pretty JavaScript-centric; you don’t need much DHTML at all to get useful results. As for learning curve, if you’ve done work with ActionScript, it probably won’t be too foreign. I get a lot of mileage out of googling for the answers to specific questions. The key issue is debugging—Safari has a so-so console which more or less means you want to make small incremental changes and test them to narrow down where bugs could be. Firefox’s Venkman extension offers a much nicer debugger and interactive shell for experimenting with syntax.
I have three related O’Reilly books that I’d recommend:
July 5th, 2005 at 1:19 pm
Have you seen Seattle’s Bus Monster? It’s pretty similar to what you are trying to do, although it actually shows where the buses are real time.
July 5th, 2005 at 1:21 pm
sorry, put the url in wrong. Try this.
July 6th, 2005 at 1:30 am
When I used to live in SF, I used NextBus a lot to see when the next MUNI was coming. It also plots public transportation real-time.
July 6th, 2005 at 11:55 am
Yeah, it’s always nice when the transit system has invested in the infrastructure to make real-time info available. Unfortunately, neither Pittsburgh nor Boston has done that, as far as I know. Thanks for the pointer, Alison–that’s a really nice route display. Hopefully I’ll have time to do more experiments in that direction when I get back from France…
July 17th, 2005 at 11:12 am
Best Saturday afternoon experiment EVER!
November 12th, 2005 at 8:23 am
this is great. i’ve used it occasionally and i’ve just used it again today and thought i’d leave a thank you. thanks!
afaik, the mbta has no real-time information available online. heck, for busses i’m not sure if they’ve got real-time information available to themselves.
one thing that could be even cooler, if you ever make an updated version, would be if the description of the bus stop contained a link to the mbta page for that route.
February 6th, 2006 at 6:28 am
Oh no! I loved this thing, but it appears to no longer work. Anyone found another similar tool?
February 6th, 2006 at 10:45 am
Chaz, the app still seems to work in my tests–could you tell me a little more about what problems you’re experiencing?
June 2nd, 2006 at 1:36 pm
Hey, this is fun! Nice work.
I wonder if you might make a different-colored BWOORP pop up depending whether the stop is bus/subway/commuter? That way I don’t have to click on all of them to see if a location is near a train (train stations are also better landmarks).
Also, it seems to miss a LOT of routes. Like, it seems to only show about 6 buses leaving from Dudley. It also doesn’t seem to show the orange line at North Station.
June 2nd, 2006 at 4:25 pm
Thanks for the comments, eeka. Good idea about the differently-colored markers. As far as the low number of buses leaving from Dudley, I’ll look into it…
June 5th, 2006 at 6:26 am
Very nice work on the map. How did you get access to the MBTA info? I’ve looked at their trip planner and “closest stops,” but couldn’t find anything useful. I’m trying to do something very similar to what you’re doing, but just for specific addresses.
June 5th, 2006 at 8:58 am
Miran, my MBTA mashup takes its information directly from the MBTA’s “Service Around a Location” feature. I use geocoder.us for the geocoding of addresses.