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.
Just moved to TO and this is fabulous! Thanks!
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
TTC Subway Map
http://groups.msn.com/thetorontoemploymentdirectory/ttcbusroutes.msnw
http://groups.google.com/group/googletransit
My god. this is absolutely awesome. If only the TTC would use something like this.
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
Very neat; the TTC ought to take this up and provide some decent route information!
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.
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.
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.
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/
[...] 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. [...]
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?
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.
(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… :)
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!
Google Maps API is very cool. I used it for my http://www.TorontoRents.com site. The TTC was a nice touch.
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)
Very handy and NICE!!!
Thank you for spending time on it.
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.
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.
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
Nice work. I wish i had come across it earlier but am pretty sure i will make use of it.
cheers
S