TTC subway map using Google Maps
I spent a little time this weekend playing with the Google Maps API and creating an overlay of the TTC subway. Not surprisingly, creating the station markers and route lines was easy. The most difficult part, however, was obtaining a list of subway stations and their addresses in a text format for easy extraction.
Translating the subway station addresses into GPoint
objects was a little difficult given that there appears to be no free geocoding service for Canadian addresses. However, Google Maps can work as a geocoder, albeit a somewhat slow one, sometimes taking several seconds to produce a result. If you have access to a Unix command-line, you can make use of the following script:
#!/bin/sh
wget -q -O- http://maps.google.com?q=\\
`echo $1 | tr " " "+"` | sed -n -e \\
"s/.*<point lat=\"\\([^\"]*\\)\" lng=\"\\([^\"]*\\)\".*/new GPoint( \\2, \\1 )/p"
If I have one beef with the API, it’s with the GIcon
class and the requirement to set the icon shadow, the icon and shadow sizes and the anchor point. A shadow should not be required and image sizes can be inferred. However, the icon will not display if any of these properties are not set.
Update: I have since added a clickable list of subway stations to the map.
Update: Now any Google Map can contain the TTC subway map.
September 21, 2006 at 1:20 am
Just moved to TO and this is fabulous! Thanks!
June 21, 2006 at 10:01 pm
There actually is a free geocoding service for Canada, you can use either http://www.geocoder.ca
or you can actually use Yahoo’s API, the key is to NOT provide the postal code, and simply the country code following the address.
I prefer yahoo as the limitations of use are far less than geocoder.ca however with such a small amount of stations
January 13, 2006 at 11:18 pm
TTC Subway Map
http://groups.msn.com/thetorontoemploymentdirectory/ttcbusroutes.msnw
http://groups.google.com/group/googletransit
December 19, 2005 at 8:23 pm
My god. this is absolutely awesome. If only the TTC would use something like this.
December 18, 2005 at 10:14 pm
It seems we had the same idea, but went about it a different way. I georeferenced the Ride Guide map, and worked from there: http://scruss.com/blog/?p=2363
October 30, 2005 at 8:37 am
Very neat; the TTC ought to take this up and provide some decent route information!
September 3, 2005 at 3:23 pm
I wanted to let you know that I just posted a Google Earth .kml file at http://bbs.keyhole.com/ubb/showthreaded.php/Cat/0/Number/96590/an/0/page/0#96590
It all started with your coordinates, but I have done a lot of tweaking by hand.
August 24, 2005 at 10:00 pm
Well spotted on the exclusion of St. George and Spadina on the Yonge-University line, Chad. I have since fixed the map. The page where I was able to find a relatively easily parsable address list seems to have disappeared. However, the Javascript code which creates the TTC Google map contains all the addresses.
August 24, 2005 at 2:41 pm
Great work! I found it because I was looking for the addresses in text format. It would be more than helpful if you could tell me where you got them or send me the file.
There is a small mistake on the University line. It does not go to the St. George and Spadina stations.
July 22, 2005 at 10:11 am
Hi Ian
Nice work with the TTC map, I was thinking of trying that myself.
Just wanted to let you know that there is now a free geocoding service for Canadian addresses. Check out http://www.geocoder.ca/
November 11, 2006 at 12:50 am
[…] About a year ago I played around with the Google Maps API and created a map containing the TTC subway system. It wasn’t intended to be all that useful as the TTC’s own map contains much more information. Still, that didn’t stop my map from rising to the top of the Google rankings for TTC-related searches, resulting in hundreds of visits. A few people sent me emails and comments thanking me for making the map, and it even got a mention in the print version of the June 2006 issue of HUB. I didn’t see much reason for the fuss as the map could have been so much better. […]
November 13, 2006 at 11:24 am
I was looking at your java script referenced above and I noticed a slight problem. CM_rtLinePoints has six points, but CM_rtLineHtml has only five labels. It seems Kennedy at 2455 Eglinton Ave. East is not present. Is there a reason?
November 13, 2006 at 1:01 pm
I probably didn’t include Kennedy in the HTML for the RT line because it exists in the HTML for the Bloor-Danforth line, and I didn’t want to create duplicate markers. It’s in the points for the RT line probably because of an oversight.
November 21, 2006 at 12:54 am
(please delete my previous post, it was for a wrong article)
Nice stuff! We need something similar in Montreal, our STM morons still sitting on their ass with
PDF files too..
Check out my map: http://mtlmap.com – just started, only subway for now, pretty simple.
BTW, how long it took you to draw this image?!!! Must be weeks and weeks… :)
February 20, 2007 at 8:17 pm
This is the most useful tool in getting around Toronto that I’ve encountered in the 18 months I have been here! Thank you sooo much!
March 20, 2007 at 5:45 pm
Google Maps API is very cool. I used it for my http://www.TorontoRents.com site. The TTC was a nice touch.
April 11, 2007 at 1:33 pm
hax!
This is pretty cool stuff, man. Maybe TTC will order you another custom map. This time for the busdrivers. With all the Tim Hortons locations on it, so these a$$hole$ know where to stop by on the route. =)
(You know how annoying this is when you’re in a hurry and they do it? lol)
July 7, 2007 at 12:41 am
Very handy and NICE!!!
Thank you for spending time on it.
August 28, 2007 at 10:50 am
This is great! One more item if you can add that will make it perfect is having to/from field for calculating distances/directions from/to subway stations and bus routes.
November 20, 2007 at 9:46 pm
Hi, Thanks for the map. I must suggest that the area name list be unicoloured and tighter margins, allowing the map to fill a greater field with mapquest-like appearance. This shoud be linked on the TTC homepage.
May 29, 2008 at 1:20 pm
Nice work.
One small improvement, if you have time:
Could you print the complete street address of the stop in the balloons, including the Postal Code?
If I paste the existing partial address you display into a GoogleMaps ‘get directions to’ pane, I get a lot of potential choices for this destination but I don’t know which one is correct.
Thx
August 19, 2008 at 12:33 am
Nice work. I wish i had come across it earlier but am pretty sure i will make use of it.
cheers
S