Monday, April 30, 2007

CalMap: a Calendar/Maps mashup

Not too long ago, I imported MLB schedule data into WikiCalendars.com. This made it simple to see when the Mets were playing next, but not where they would be playing next, so I decided to create CalMap: a mashup that takes a calendar feed and plots the locations of the events on a map:

CalMap screenshot


Currently, CalMap only plots the locations it knows, which are listed in a JSON data file. I also use this to assign marker colors so baseball teams in the same division will have the same color -- this makes the interleague games easy to pick out on the map!

If you inspect the default URL for CalMap, you will see that the URL to the calendar feed that you want to load is simply passed as a GET parameter:

http://calmap.bolinfest.com/?url=http://www.wikicalendars.com/wiki/MLB_2007_nym_protected


For WikiCalendars, you can also splice a number of calendars together and plot them as one calendar. For example, you can combine the calendars for all of the NL East teams and display them as one on CalMap:

http://calmap.bolinfest.com/?url=http://www.wikicalendars.com/splice.php?cal=MLB_2007_nym_protected,MLB_2007_phi_protected,MLB_2007_atl_protected,MLB_2007_fla_protected,MLB_2007_was_protected

The supplied calendar feed needs to follow the GData JSON conventions, so it needs to honor alt=json-in-script, start-min, start-max, etc. This means that, yes, CalMap may execute arbitrary JavaScript from foreign sites, which is why I put it on its own subdomain of bolinfest.com where there are no cookies to steal.

Also, so that my demo does not get trashed, I created copies of the original MLB calendars and made versions of them that only I can edit so that the CalMap home page does not become spammy. I have written a Chickenfoot script to update these new versions of the calendars with data from mlb.com, so if you added one of the old MLB calendars to your Google Calendar account, I recommend replacing it with one from the list of protected calendars as the new calendars will be updated fairly frequently with legitimate data. (You can also subscribe to one of my "protected" MLB calendars by following the Subscribe link at the bottom of CalMap.)

The only thing left to do is to figure out how to run Chickenfoot reliably as a cronjob...

No comments:

Post a Comment