Google Transit Layer through Google Maps API

This is a followup to a post we did a while back that showed how to add the Google Transit and Google Bike layer to a google map using the Google Maps API. We’ve updated this with code based on Google Maps Javascript API version 3.

Google Maps API v3 now allows you to add the Bike route layer and traffic layer via the API, but there still isn’t an easy way to get at the transit layer.

To add the Bike layer:

To add the Traffic layer:

However, you can use the code below to add the Google Transit layer it as a custom tile layer. This will load the image tiles directly from Google’s servers:

This loads the full image types, so any other styles you’ve applied to the basemap will get covered up. Unlike Google Transit, the stations won’t be clickable and transit info won’t pop up unless you add your own markers to the map, but this should work ok for just showing transit routes.

You can see this technique live in our Realtime Transit Map project (also on github).

One Response to “Google Transit Layer through Google Maps API”

  1. [...] I outlined a relatively simple way to use the transit layer in your own map. You can use the same technique to pull the 8bit map tiles. var eightbitOptions [...]

Leave a Comment