Tinderbox and Google Maps
In my various Tinderbox projects, I find I often have containers of people or companies or other Things With Addresses. Sometimes, it might be useful to see a quick summary of the geographical distribution of those addresses.
For example, this morning I was looking at the list of accepted research papers and practitioner reports for WikiSym. Might it be interesting to see where those papers come from? Here's how we can do this in a couple of minutes.
Step 1: We need an address for each paper. I needed to sort through the accepted papers to make sure we have all the co-authors listed correctly, so in passing I also jotted down the address of one author — usually just the city in which they work. (This can be arbitrary, as some papers have co-authors on three different continents. It's a quick study; we accept some compromises.)
Step 2: We ask Google for the latitude and longitude of each paper. Details are covered in any earlier note; I just copied the geocoding agents from that demo.
Step 3: We need to build a URL for Google maps. The instructions are here; in essence, we want to send Google maps a URL like this:
& markers= coordinate 1|coordinate 2| coordinate 3 |
& key=^getFor(/config/key,Text)^
So, the only task left is to build the list of pushpins for the map.
& markers= ^justChildren(coordinates)
& key=^getFor(/config/key,Text)^
Step 4: What remains is to make an export templates named coordinates
that exports the latitude and longitude of each note in the container. The template is simple:
Finally, we wrap this up in an HTML page so we can preview it. Here's what we see for WikiSym:
This is nice. It might be useful. It’s only practical because it’s fast; it took almost no time to get this working. Looking up the geographical coordinates was easy, a matter of copying a couple of agents from the demo and checking their actions to use the attributes from the new file. The new export templates are trivial. Testing was just a matter of looking at the generated URL and fixing obvious problems, and then hitting Preview a few times to tweak the results.