Alpha Maps: a mashup of Wolfram|Alpha and Google Maps

Hands down, Wolfram is awesome. Mathematica has been my favorite computer algebra system* from the start (okay, there were some wrong ways towards Maple in the very beginning, but hey, everybody makes mistakes); and Wolfram|Alpha is a big step (and still stepping) towards a huge semantic web.

Now I just came across the pretty new Wolfram|Alpha API and thought I had to do something with it. Having been a maps guy since the tripedia days, I had the idea of mashing up W|A with Google Maps.

A user can enter an arbitrary Wolfram|Alpha query (usually a city), the query is sent to W|A and the result is parsed on the client side. All items in the result that refer to geolocations are queried also to get a set of markers on the map. With nice info windows showing the data that W|A returned for them.

W|A sends quite a lot of information, but for now I was only interested in plain facts. These can be accessed using the plaintext field for every so-called “subpod”. Each of these plaintexts actually represents a table encoded by newlines and | separators. One could argue about the elegance of this representation in the API, but whatever.

The W|A API is a server-side-only API, as it doesn’t set the Access-Control-Allow-Origin HTTP header to *, so accessing it directly from any modern browser will violate the same-origin policy and thus fail. Therefore, a thin PHP wrapper on a server is needed. The good thing is that this wrapper can also cache queries to avoid reaching the free API limit of 2000 monthly calls too soon.

I don’t want to go into the details of the implementation here—it’s basically a bit of JavaScript using jQuery. If you’re interested, the code is online at github, and the resulting site is Alpha Maps.

It’s been a nice day of hacking. Any thoughts on how to turn this into something (even more) useful?

* I also like Sage, of course, and—surprise!—Mathics.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>