280 Part III — Google Map Hacks
The API has three methods of access:
REST:This is the method used in earlier examples in this book, and by parts of the
Google Maps API, to submit requests. The request and any options or arguments are
supplied as part of the URL. The return value is an XML document with the informa-
tion you were looking for.
XML-RPC:This is one of the web services interfaces. Information is returned as an
object (according to your request environment).
SOAP:This is the other web service interface. Information is returned as an object.
The REST interface is the easiest to use from within JavaScript and a browser. The techniques
REST uses to parse and extract the XML returned are just the same as those that have been
demonstrated in earlier examples.
Whichever method you use, the array of available functions and operations remains constant.
Getting a Flickr API Key
To use the API you must have a unique API key. There are fewer restrictions on the Flickr
API key and its use compared to the Google Maps API key, but the Flickr system also only
provides access to publicly uploaded photos, rather than the copyrighted material used in
Google Maps and satellite images.
To obtain a key, you need to create an account with Flickr (where you will also need to upload
your photos). Once you have your account, go to the Flickr Services API page (http://www
.flickr.com/services/api/) to request your key.
The key you are given provides access to all of the Flickr photos. It also provides special infor-
mation for your own photos that might not generally available to the public.
Adding Geographic Data to Your Flickr Photos
Adding geographic data to a photo within Flickr is a simple case of adding suitable tags to the
photo. There are many ways in which you can do this, including an automatic system using the
GreaseMonkey script environment within the Firefox browser. However, because the basic pro-
cess of writing the tag to the Flickr photo is the same, it is safe to concentrate on the basic tag
structure.
Three tags are used to record geographical information:
geotagged:This simply indicates that the photo is tagged with geographical informa-
tion. Generally the existence of the tag is designed to make searching for geotagged
photos easier.
geo:lat=XXX:This is the latitude of where the photo was taken.
geo:lon=XXX:This is the longitude of where the photo was taken.