I’m fascinated by the latent power of geotagging. My “Diary” project takes photos from Flickr that have been geotagged and groups them by day, showing a map for all photos taken on that day. It’s an interesting way to show where life has taken you.

As with all my apps, you can control it via the URL itself. To look at the most recent photos for a user, go to mvjantzen.com/flickr/diary.php?user=mvjantzen (or replace mvjantzen with any other user, such as thelittleidiot for Moby‘s photos).

The Flickr data is gotten from the Flickr API. I wrote my code in PHP using the phpFlickr library, but there are many other different options; use whatever language you’re comfortable with. I go through the paramaters in the query string and build the criteria that I send to flickr.photos.search (or flickr.photosets.getPhotos if the user specified a set).

So, it’s easy to display the relevant photos. The fun part is hooking up the data to Google’s marvelous mapping API and creating an on-the-fly map, with markers for each photo. For an example, look at mvjantzen.com/flickr/diary.php?user=mvjantzen&start=2011-9-23&end=2011-9-24. There should be 3 geotagged photos from that day. To create that accompanying map, all I have to do is include the coordinates in the URL, like so:

<img src=”http://maps.googleapis.com/maps/api/staticmap? markers = size:mid%7Ccolor:red%7C38.899656, -77.070787%7C38.906823, -77.073901%7C38.9016, -77.063664 &size=360×240 &sensor=false” width=360 height=240>

Note we’re using the Static Maps API (V2), not the more-complicated JavaScript API. The Static Maps API is less powerful, but also so much easier to use, because all you need to do is build up the URL in the IMG tag, and you’re done.

This particular call to the mapping service has 3 parameters: markers, where I pick the size, color, and the latitude & longitude values that I got from Flickr; size lets you pick the resolution of the image; sensor is a required field where you state whether you’re getting the location from a GPS or something similar. Google will figure out the map’s boundaries and zoom level based on the markers and the size you chose.

I think this is a fun way to demonstrate the power of combining Flickr’s treasure trove of geotagged images with Google’s super-easy mapping service.

Creating a Geographic Diary via Flickr

Leave a Reply