Walking tour of Keene: followup

On Friday I said I'd follow up with details on the Google Maps walking tour. Here's what I've got so far. First, to run the "application" yourself, do this:

  1. Drag this bookmarklet -- wtkn -- to your Mozilla or IE linkbar.
  2. Visit Google Maps.
  3. Click wtkn on the linkbar.

My abbreviation for "walking tour of Keene, NH" -- wtkn -- is typical of the cryptic labels I've been assigning to my growing collection of indispensable bookmarklets. This bookmarklet thing is getting out of control. We're going to have to admit that this way of injecting behavior into pages is here to stay, and allow the mechanism to mature.

The tour should work in both Mozilla and IE, once you allow popups from weblog.infoworld.com. But although Google Maps does now support Safari and Opera, the tour crashed Safari. (I haven't tried it in Opera.)

The extra window that pops up loads the XML/JavaScript hybrid that runs the tour, using the remote-window technique that Matt King learned from Jesse Ruderman. The script that gets loaded by the bookmarklet contains one big string that's instantiated as JavaScript using document.write. That string is mainly a packet of XML, in the same format as was originally returned by the output=XML parameter to Google Maps URLs.

The XML packet includes this encoded representation of the waypoints:

At http://libgmail.sourceforge.net/googlemaps.html, maintained by someone I know only as follower at myrealbox.com, I found a link to the GoogleMapsHacking wiki, where in turn I found a Perl script that knew how to produce the necessary encoding from a list of GPS points like this:
4293763, -7226913
4293766, -7227150
4293980, -7227116
I'm not using the END_OF_STREAM marker you see in that script, though, because it created an endpoint about 8 miles off my map.

The XML packet also includes an encoded representation of the zoom levels associated with each waypoint. If you examine the Google Maps JavaScript code linked from follower's page or the Wiki, you can see how this gets decoded, but I still haven't found a complete explanation of how it works. Following Matt King, I just included a string of Bs equal in length to the number of points (14) along my route.

The bulk of the XML packet is a set of <location> tags, like so:

<location infoStyle='/mapfiles/localinfo.xsl' id='A'>
<point lat='42.93766' lng='-72.27150'/>
<icon image='/mapfiles/markerA.png' class='local'/>
<info><title xml:space='preserve'>greenlawn cemetery</title>
<address><line>beaver st. entrance</line></address>
<description><references count='1'><reference>
<url>http://jonudell.net/udell/gems/googleMaps2_media/greenlawnCemetery.jpg </url>
<title xml:space='preserve'>beaver st. entrance</title>
<url>http://www.google.com/search?q=greenlawn+cemetery+keene+nh </url>
<distance>beaver st. entrance</distance></info></location>
I've repeated info/title and info/address as reference/title and reference/distance, which isn't really kosher I'm sure, but it gave me the effect I wanted without requiring me to alter the structure of the XML packet. Can you alter the structure? I haven't tried yet. Can you change how the existing structure is displayed? According to part 8 of follower's page you can, by swapping in alternate XSLT stylesheets. I haven't tried this yet either.

Your route can include any number of points, but you can only mark 10 of them -- A through J. The info/url is the first link in the popups, and you describe its "domain" in info/domain. You can also stuff one or more URLs into info/description/references/reference, though I'm just using one for each marker. If you've watched the movie you'll note that I open these URLs into Firefox tabs. With IE, you'll want to open them into separate windows. This application breaks the back button, so you'll lose context if you open these links in situ.

There's lots of stuff here to play with. Was this all just an unintended consequence, or does Google really get that the future is services co-created by the people who use them? The latter, I hope, but we'll soon see.

Former URL: http://weblog.infoworld.com/udell/2005/02/28.html#a1186