Sunday, November 04, 2007

Google: the world's favourite command line

Google is, essentially, a honking great unix system whose command line interface is addressed through URLs. This came to mind preparing the embedded map for the G3 Systems post; Google Maps autogenned a slightly different location than the view I wanted every time, although I could link directly to the right view.

So, of course, I started fiddling with it; the embedded map function seems to work as follows. Here's some code:
iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.uk/?q=Byron+Industrial+Estate,+Brookfield+Rd,+Arnold,+Nottingham,+NG5+7ER&
ie=UTF8&t=k&om=1&ll=53.001614,-1.119962&spn=0.001834,0.008476&
z=17&iwloc=addr&output=embed&s=AARTsJqS0vJdXgvvmSH9pm0agdKb_l1g-Q">/iframe>
small>ah ref="http://maps.google.co.uk/?q=Byron+Industrial+Estate,
+Brookfield+Rd,+Arnold,+Nottingham,+NG5+7ER&ie=UTF8&t=k&om=1&ll=53.001614,-1.119962&spn=0.001834,0.008476&
z=17&iwloc=addr&source=embed" style="color:#0000FF;text-align:left">View Larger Map/a>/small>
Some tags have been disabled. OK, so we kick off by declaring an iFRAME whose dimensions match what appears to be an emerging standard; anything you embed in a website is usually 425 by 350 pixels for some reason. Its content is to be drawn from the URL that follows, and a link to a near-identical page is provided beneath.

To kick off, after the ? sign that signals the end of the real URL and the beginning of the command-line argument, we've got the command q, which permits you to pass search terms, each string separated by commas and multi-word strings concatenated with + signs (just like in Python). In this case the search is an address. An & marks the end of the statement. Then there's ie which specifies encoding for the target page, in this case UTF8. Again, the statement is ended with the delimiter &, and the next one begins with a semicolon.

Next we have t, which I reckon specifies the type of map to display as its value here is k, as in KeyHole. Then there's om, set to 1; I don't know what it does. ll is crucial, as it passes the latitude and longitude of the map centre, separated by a comma, like this: 53.001614,-1.119962. spn appears to contain geographic data as well, but I'm not sure what. z controls the zoom level, a number with a maximum of 30. iwloc is one I don't know; output tells the machine to treat this one as an embed, and finally comes s, which looks to be a hashed unique identifier, and causes the whole thing to stop working if you omit or change it.

So, I increased z from 14 to 17, read off the lat, long and spn values from the view I wanted, and altered the code accordingly. And now it works.

1 comment:

duaneg said...

More like the URL is the command and the parameters are the arguments to it. But nitpicking aside, it is an interesting thought. Google as the world's most widely used command-line program, albeit mostly accessed via a thin GUI wrapper.

kostenloser Counter