GCalMap: Mashup Google Maps and Calendar
Posted by pat 60 days ago
Calendars are great, but they can be viewed on other surfaces than the classic year/month/week/day views: the surface of the earth for example. GCalMap is a demo mashup that I put together for Mashup Camp, where I will be presenting it tomorrow. It allows you to visualize upcoming events from a Google Calendar on a Map.
Google Calendar exposes Calendars as feeds: go to manage calendar, find the xml icon, then replace basic by full in the url, that's your full feed. Paste your feed in the Calendar url field, then press Go. After that you can change the number of months in the future for which you want to see events, using the slider.
This is sample code, to show what can be done with Google APIs, and start exploring this direction of mixing space and time in visualization. It could use many improvements.
I use a whole salsa of tech stuff in there:
- ROME and ROME fetcher to get and parse the feed, with a half baked quickly hacked new ROME GData module to parse the Google Data Calendar format and transform it to java beans (I just implemented what I needed). One of my colleague asked me why I used ROME instead of the Google open source GData java client library. This is actually the first thing I tried, I have a sentimental attachment to ROME but we have no GData module for now, and I wanted the fastest development time. The issue was that no JSON marshalling lib could handle the objects that this lib generates to represent feeds, since they don't follow the Javabeans conventions. Since ROME Beans do, they get JSON serialization for free:-) As a side note, about all this json business: it is regrettable that Microsoft does not implement E4X in IE 7, as it is implemented in Firefox: with E4X, no need for JSON, you have an easy way to work with XML in javascript (and can wrap the xml in a javascript string served as a javascript script source in order to avoid cross site scripting limitations).
- DWR (Direct Web Remoting) to marshal the ROME Beans to JSON and access it from javascript
- Google Maps API to add it on the map
- and a Slider from webfx
When doing this mashup the main difficulties I encountered were: DWR conflicts with Yahoo UI API and Scriptaculous (I had heard that at Ajax Experience, I can confirm it is true), so I had to lose a lot of time experimenting, then dig another Slider (it seems none has implemented a Slider control in GWT yet); All the Java to JSON libs I tried to translate ROME Beans to JSON failed (JSON-RPC and another one, forgot the name), but DWR serialized it very easily. However as Joe Walker told me at Ajax Experience when I asked, it seems not trivial to extract the serialization code from DWR, so I had to use it all (ideally I'd prefer to create a ROME Mano Atomlet that would spit out JSON without all the DWR remoting business). That's it, the rest is quite boilerplate code, hacked quickly in a long night.
DWR is really worth trying, for java engineers who are starting to get into Ajax. It is a remoting framework. You configure the DWR servlet, with a file where you specify which java classes from your server you want to expose. Then DWR generates javascript files that you can include in your UI layer, and automagically, you now have javascript objects that mimick your java objects. They do it the other way as well, letting you take control of the browser from the server side, through a backchannel that they setup when their js is parsed. Nifty! This was my first occasion to really play with DWR after attending Joe's talk at Ajax Experience, and I have to say: it rocks! However I could not refrain myself from thinking about 1997, when we had a CORBA ORB included in Netscape Communicator, and a VM as well, and the Browser was going to be the platform. It seems like 10 years after that folks reinvent CORBA in javascript:-)