The Incrementalist

7/2/2005

MBTA Google Maps Experiment

Filed under: — Joe @ 8:35 pm

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 Stops button 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.

14 Responses to “MBTA Google Maps Experiment”

  1. Michael Higgins Says:

    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?

  2. Joe Hughes Says:

    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:

    • Dynamic HTML — This is one of those massive tomes that covers all the parameters of HTML, CSS, and JavaScript. A good reference.
    • JavaScript — This is the book on JavaScript (the Rhino interpreter is named after its cover animal); it offers more in-depth discussion than the DHTML book.
    • JavaScript & DHTML Cookbook — I haven’t spent much time with this one yet, but it seems to have nice coverage of common DHTML needs & idioms.
  3. Alison Says:

    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.

  4. Alison Says:

    sorry, put the url in wrong. Try this.

  5. theasianmenace Says:

    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.

  6. Joe Hughes Says:

    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…

  7. Abby Says:

    Best Saturday afternoon experiment EVER!

  8. regis Says:

    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.

  9. chaz Says:

    Oh no! I loved this thing, but it appears to no longer work. Anyone found another similar tool?

  10. Joe Says:

    Chaz, the app still seems to work in my tests–could you tell me a little more about what problems you’re experiencing?

  11. eeka Says:

    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.

  12. Joe Says:

    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…

  13. Miran Badzak Says:

    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.

  14. Joe Says:

    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.

Leave a Reply