crazed monkey

Archive for July, 2005

RSS

TTC Google Maps for all!

I just spent a few minutes factoring out my TTC subway map Javascript code so that it can be called to insert the TTC subway into any Google Map:

<div id="map">
<script src="http://crazedmonkey.com/ttcgooglemap/ttcgooglemaps.js"
type="text/javascript"></script>
<script type="text/javascript">
<!--
    var map = new GMap( document.getElementById( "map" ) );
    map.addControl( new GSmallMapControl() );
    map.centerAndZoom( new GPoint( -79.386871, 43.660241 ), 4 );

    // Add your own markers and polylines here.

    drawTtcSubwayMap( map );
-->
</script>

There are two other additional functions, drawTtcSubwayMapColor() and writeTtcSubwayStations(), which can be used to specify the colors for the different subway lines and to display the colour-coded list in a div, respectively. I might add more helper methods later if there is a demand for them.

You can affect how the stations appear in the info pop-up by styling div elements of the station class.

Originally I had thought to limit access to my Javascript file to those who asked permission to use it. Doing so would make me aware of how people were using the map. For now, people are free to link the Javascript in their pages. All I ask is that you leave a comment on my weblog with a link to your page, and include the following HTML somewhere near the map:

<p>TTC station code and coordinates provided by
<a href="http://crazedmonkey.com/">Ian Stevens</a> and his
<a href="http://crazedmonkey.com/ttcgooglemap/">TTC Subway Google Map</a>.</p>

Linking, not copying, the script has its advantages, namely that any changes or additions that I make will propagate to your map. There are also a few known bugs, all of which have to do with Internet Explorer, that I hope to address soon.

Tags:
  • none

Posted on July 29th, 2005 in programming, transitmap, ttc - 17 Comments »

TTC subway map using Google Maps, now easier to use

To make stations on my TTC subway map easier to locate, I have added an alphabetical, clickable list of subway stations, colour-coded by subway line. Enjoy.

Tags:
  • none

Posted on July 16th, 2005 in programming, transitmap, ttc - 9 Comments »

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.

Tags:
  • none

Posted on July 2nd, 2005 in programming, transitmap, ttc - 20 Comments »