You can view the page source at joey.tufts.edu and get a glimpse of how they do it. First they create labels for each of their stops:
map.addOverlay(createLabel(new GLatLng(42.396333, -71.122527), “Davis Square”));
map.addOverlay(createLabel(new GLatLng(42.405698, -71.119781), “Mayer Campus Center”));
map.addOverlay(createLabel(new GLatLng(42.409500, -71.122034), “Carmichael Hall/Wren Hall”));
map.addOverlay(createLabel(new GLatLng(42.407837, -71.121712), “Olin Hall”));
Then they add the bus route overlay on the map using the polyline encoder tool mentioned above:
map.addOverlay(new GPolyline.fromEncoded({
color: “#0000FF”,
weight: 10,
//note that backslashes (\) must be escaped by adding another \ in front of each
points: “qkyaGppaqLfA{DQgFh\\qCtGrKpFfNfJlEwCbDwUvQuLdE|E}P|Fm^e@_NqWvBPnFqBnM}CkB{HtWsJsFTeBa@k@h@uA|AbAfBoHhInFrDsM”,
levels: “BBBBBBBBBBBBBBBBBBBBBBBBBB”,
zoomFactor: 32,
numLevels: 4
}));
Then you can see they use simple logic that determines whether or not the bus is close to a stop:
//override campus center alert if bus is getting close
if (arrBuses.getPoint().y > 42.40567403715082 && arrBuses.getPoint().x > -71.124759 && arrBuses.getPoint().y < 42.410498 && arrBuses.getPoint().x < -71.11907243728638) {
timeToCampusCenter = “<span style=\“color: #de6020;\”>less than 5 min</span>”;
}
//override Davis alert if bus is getting close
if (arrBuses.getPoint().x > -71.12244129180908 && arrBuses.getPoint().y < 42.400167970925544 && arrBuses.getPoint().x < -71.116176 && arrBuses.getPoint().y > 42.395731) {
timeToDavis = “<span style=\“color: #de6020;\”>less than 2 min</span>”;
}
and they detect if students are boarding the bus:
//override campus center alert if bus is there
if ($(this).find(“description”).text() == “22 Professors Row, Somerville, Massachusetts” || $(this).find(“description”).text() == “24 Professors Row, Somerville, Massachusetts” || $(this).find(“description”).text() == “26 Professors Row, Somerville, Massachusetts” || $(this).find(“description”).text() == “28 Professors Row, Somerville, Massachusetts”) {
timeToCampusCenter = “<span style=\“color: #ba2234;\”>boarding</span>”;
}
//override Davis alert if bus is there
if ($(this).find(“description”).text().indexOf(“Davis Sq, Somerville, Massachusetts”) > -1) {
timeToDavis = “<span style=\“color: #ba2234;\”>boarding</span>”;
}
Please post if you have any additional questions. Obviously, this requires a fair amount of JavaScript knowledge.