<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Toronto subway stations" 
             description="The TTC subway system with stations"
             author="Ian Stevens"
             author_email="icstevens@hotmail.com"
             title_url="http://crazedmonkey.com/toronto-transit-map/">
    <Require feature="sharedmap"/>
</ModulePrefs>

<Content type="html">
<![CDATA[
    <p>For a more accurate searchable map of the TTC, complete with bus routes for the Toronto area, visit the <a href="http://crazedmonkey.com/toronto-transit-map/">Toronto transit map</a>.</p>

    <script type="text/javascript">
// Copyright 2005, ian stevens.  Some rights reserved.  Please ask permission before using.

// Creates a marker whose info window displays the given number
function CM_createMarker(point, html, icon) 
{
    var marker = new GMarker(point,icon);
    GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); });
    return marker;
}

function CM_getStationHtml(station)
{
    return "<div class=\"station\"><h3>" + station.replace( "|", "</h3><p>" ) + "</p></div>";
}

function CM_addLine(map, points, html, color, stationMarkers, stations, startIndex, icon)
{
    map.addOverlay( new GPolyline( points, color, 10 ) );
    for( var i = 0; i < html.length; i++, startIndex++ )
    {
        var marker = CM_createMarker( points[ i ], CM_getStationHtml( html[ i ] ), icon );
        map.addOverlay( marker );
        stationMarkers[ startIndex ] = marker; 
        var name = html[ i ].substring( 0, html[ i ].indexOf( "|" ) );
        stations[ startIndex ] = "<li id=\"" + name + "\" onclick=\"GEvent.trigger(CM_stationMarkers[" + startIndex + "],'click')\" style=\"background-color:" + color + "\">" + name  + "</li>";
    }

    return startIndex;
}

var CM_yongeLinePoints = [  new GLatLng(43.750241, -79.462871),
 new GLatLng(43.734072, -79.450225),
 new GLatLng(43.724790, -79.447005),
 new GLatLng(43.716210, -79.442936),
 new GLatLng(43.709193, -79.442247),
 new GLatLng(43.699085, -79.435165),
 new GLatLng(43.683991, -79.415245),
 new GLatLng(43.674944, -79.407303),
 new GLatLng(43.666873, -79.402128),
 new GLatLng(43.667400, -79.399655),
 new GLatLng(43.666662, -79.393116),
 new GLatLng(43.658496, -79.389655),
 new GLatLng(43.654750, -79.387971),
 new GLatLng(43.650370, -79.386737),
 new GLatLng(43.648227, -79.384991),
 new GLatLng(43.645671, -79.379466),
 new GLatLng(43.648804, -79.377886),
 new GLatLng(43.652336, -79.379103),
 new GLatLng(43.656371, -79.381110),
 new GLatLng(43.661170, -79.383150),
 new GLatLng(43.664672, -79.384325),
 new GLatLng(43.669998, -79.386525),
 new GLatLng(43.677214, -79.389467),
 new GLatLng(43.683008, -79.391836),
 new GLatLng(43.688217, -79.394044),
 new GLatLng(43.697851, -79.396646),
 new GLatLng(43.704686, -79.398077),
 new GLatLng(43.725369, -79.402126),
 new GLatLng(43.743221, -79.406339),
 new GLatLng(43.768987, -79.412960),
 new GLatLng(43.781990, -79.416208) 
];

var CM_bloorLinePoints = [  new GLatLng(43.638633, -79.537689),
 new GLatLng(43.645283, -79.521333),
 new GLatLng(43.647513, -79.511238),
 new GLatLng(43.649688, -79.495256),
 new GLatLng(43.649481, -79.484372),
 new GLatLng(43.651278, -79.476187),
 new GLatLng(43.653853, -79.464407),
 new GLatLng(43.654589, -79.459862),
 new GLatLng(43.656279, -79.451910),
 new GLatLng(43.658236, -79.442516),
 new GLatLng(43.660082, -79.434994),
 new GLatLng(43.661937, -79.425156),
 new GLatLng(43.663785, -79.418031),
 new GLatLng(43.665040, -79.410912),
 new GLatLng(43.666873, -79.402128),
 new GLatLng(43.667400, -79.399655),
 new GLatLng(43.669747, -79.389716),
 new GLatLng(43.672457, -79.376973),
 new GLatLng(43.672750, -79.369854),
 new GLatLng(43.676346, -79.358765),
 new GLatLng(43.677594, -79.352350),
 new GLatLng(43.679050, -79.344962),
 new GLatLng(43.680499, -79.337492),
 new GLatLng(43.681247, -79.332751),
 new GLatLng(43.683458, -79.323763),
 new GLatLng(43.685757, -79.312997),
 new GLatLng(43.688240, -79.301938),
 new GLatLng(43.693253, -79.289030),
 new GLatLng(43.711529, -79.283861),
 new GLatLng(43.732577, -79.264723) 
];

CM_rtLinePoints = [ 
 new GLatLng(43.775323, -79.252353),
 new GLatLng(43.775804, -79.259592),
 new GLatLng(43.770471, -79.271862),
 new GLatLng(43.766155, -79.277257),
 new GLatLng(43.750430, -79.270838),
 new GLatLng(43.732577, -79.264723) 
];

CM_sheppardLinePoints = [  new GLatLng(43.761353, -79.411016),
 new GLatLng(43.766957, -79.387321),
 new GLatLng(43.768421, -79.379512),
 new GLatLng(43.770518, -79.369908),
 new GLatLng(43.775246, -79.346947) 
];

CM_yongeLineHtml = ["Downsview|1035 Sheppard Ave West",
"Wilson|570 Wilson Ave",
"Yorkdale|Yorkdale Shopping Centre",
"Lawrence West|655 Lawrence Ave West",
"Glencairn|765 Glencairn Ave",
"Eglinton West|1300 Eglinton Ave West",
"St. Clair West|370 St Clair Ave West",
"Dupont|278 Dupont St",
"Spadina|371 Bloor St West",
"St George|323 Bloor St West",
"Museum|75 Queen's Park",
"Queen's Park|671 University Ave",
"St. Patrick|449 University Ave",
"Osgoode|260 University Ave",
"St. Andrew|147 University Ave",
"Union|55 Front St. West",
"King|70 Yonge St",
"Queen|171 Yonge St",
"Dundas|300 Yonge St",
"College|448 Yonge St",
"Wellesley|551 Yonge St",
"Bloor-Yonge|733 Yonge St",
"Rosedale|1009 Yonge St",
"Summerhill|1189 Yonge St",
"St. Clair|1441 Yonge St",
"Davisville|1900 Yonge St",
"Eglinton|2190 Yonge St",
"Lawrence|3101 Yonge St",
"York Mills|4015 Yonge St",
"North York Centre|5152 Yonge St",
"Finch|5714 Yonge St" ];

CM_sheppardLineHtml = [ "Sheppard-Yonge|4800 Yonge St",
"Bayview|550 Sheppard Ave East",
"Bessarion|701 Sheppard Ave East",
"Leslie|1209 Sheppard Ave East",
"Don Mills|1700 Sheppard Ave East" ];

CM_bloorLineHtml = [ "Kipling|5247 Dundas St West",
"Islington|3286 Bloor St West",
"Royal York|3012 Bloor St West",
"Old Mill|2672 Bloor St West",
"Jane|2440 Bloor St West",
"Runnymede|2218 Bloor St West",
"High Park|1874 Bloor St West",
"Keele|1733 Bloor St West",
"Dundas West|1525 Bloor St West",
"Lansdowne|1287 Bloor St West",
"Dufferin|1126 Bloor St West",
"Ossington|883 Bloor St West",
"Christie|726 Bloor St West",
"Bathurst|565 Bloor St West",
"Spadina|371 Bloor St West",
"St. George|323 Bloor St West",
"Bay|64 Bloor St West",
"Sherbourne|420 Bloor St East",
"Castle Frank|600 Bloor St East",
"Broadview|90 Danforth Ave",
"Chester|370 Danforth Ave",
"Pape|650 Danforth Ave",
"Donlands|990 Danforth Ave",
"Greenwood|1177 Danforth Ave",
"Coxwell|1568 Danforth Ave",
"Woodbine|2072 Danforth Ave",
"Main Street|2550 Danforth Ave",
"Victoria Park|777 Victoria Park Ave",
"Warden|3276 St Clair Ave East",
"Kennedy|2455 Eglinton Ave East" ];

CM_rtLineHtml = [ "McCowan|1275 McCowan Rd",
"Scarborough Centre|Scarborough Town Centre",
"Midland|2085 Midland Ave",
"Ellesmere|1025 Ellesmere Rd",
"Lawrence East|2444 Lawrence Ave East" ];

var CM_stationMarkers = new Array( CM_yongeLineHtml.length + CM_bloorLineHtml.length + CM_rtLineHtml.length + CM_sheppardLineHtml.length );
var CM_stations = new Array( CM_stationMarkers.length );

function drawTtcSubwayMapColor( map, yongeColor, bloorColor, rtColor, sheppardColor )
{
    var CM_ttcStationIcon = new GIcon();
    CM_ttcStationIcon.image = "http://crazedmonkey.com/ttcgooglemap/ttc-sm.png";
    CM_ttcStationIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
    CM_ttcStationIcon.iconSize = new GSize(37, 14);
    CM_ttcStationIcon.shadowSize = new GSize(50, 17);
    CM_ttcStationIcon.iconAnchor =  new GPoint(19, 7);
    CM_ttcStationIcon.infoWindowAnchor =  new GPoint(15, 1);

    var lastIndex = 0;
    lastIndex = CM_addLine( map, CM_yongeLinePoints, CM_yongeLineHtml, yongeColor, CM_stationMarkers, CM_stations, lastIndex, CM_ttcStationIcon );
    lastIndex = CM_addLine( map, CM_bloorLinePoints, CM_bloorLineHtml, bloorColor, CM_stationMarkers, CM_stations, lastIndex, CM_ttcStationIcon );
    lastIndex = CM_addLine( map, CM_rtLinePoints, CM_rtLineHtml, rtColor, CM_stationMarkers, CM_stations, lastIndex, CM_ttcStationIcon );
    lastIndex = CM_addLine( map, CM_sheppardLinePoints, CM_sheppardLineHtml, sheppardColor, CM_stationMarkers, CM_stations, lastIndex, CM_ttcStationIcon );
}

function drawTtcSubwayMap( map )
{
    drawTtcSubwayMapColor( map, "#FF6666", "#66FF66", "#6666FF", "#FF66FF" );
}

function writeTtcSubwayStations()
{
    CM_stations.sort();
    document.write( "<div><div id=\"stations\"><ul>" );
    for( i = 0; i < CM_stations.length; i++ )
    {
        document.write( CM_stations[ i ] );
    }
    document.write( "</ul></div></div>" );
}
        var map = new GMap2();
//        map.setCenter(new GLatLng(43.660241, -79.386871), 14);

        drawTtcSubwayMap( map );
    </script>
]]>
</Content>
</Module>
