Hack 45. Share Pictures with Your Community
Use Flickrcity to set up a collaborative photo map.
Putting geolocated photos on a map is something geo-hackers have worked on for a long time. Now, using Flickr, Google Maps, and a little piece of glue called Flickrcity (http://anti-mega.com/flickrcity/), anyone can do this easily.
I started work on Flickrcity because I wanted to create a restaurant review site for Helsinki that anyone could contribute to. Flickr was the natural place to store photos and information; sites such as Geobloggers (http://www.geobloggers.com/) were using Flickr as a data source and had already created a standard for geotagging photos.
Flickrcity automatically filters on a tag of the name of the city and the tag geotagged. Using additional tags, or specifying a particular user, you can use Flickrcity for a variety of purposes.
To see all geotagged photos in a city, you can just go to the URL of the Flickrcity installatione.g., for Helsinki, http://anti-mega.com/flickrcity/helsinki.city, as shown in Figure 5-15.
Figure 5-15. Photos geotagged in Helsinki
If you wanted to set up a collaborative restaurant review site for Helsinki, you would need to tag photos in Flickr with, say, "helsinki," "food," "geotagged," and the two location geotags [Hack #46]. Then you would construct a URL that would return these images with this tag query, such as http://anti-mega.com/flickrcity/helsinki.city?tags=food. Figure 5-16 shows what this looks like.
If you just wanted to see all of my Helsinki photos, you would use a user query such as http://anti-mega.com/flickrcity/helsinki.city?user=chrisdodo, as Figure 5-17 demonstrates.
Of course, you can combine the two, to show just my food photos, as in http://anti-mega.com/flickrcity/helsinki.city?tags=food&user=chrisdodo.
If you're using the map for yourself, use a different tag for each project you want to create. If you want to set up a collaborative map, pick a tag name that isn't being used in Flickr and tell all your photographers to add that tag. Of course, others may see it and start using the tag tooFlickrcity gets even better with more geotagged photos.
I've set up Flickrcity installations for a few cities, and others have set up even more, but you can also download the code and set up Flickrcity for wherever you want. To do this, you will need a web server with Perl, some Perl modules (see the installation instructions on the web page for the list), and a little bit of webmaster knowledge.
Figure 5-16. Photos tagged with food in Helsinki
Figure 5-17. Photos taken by chrisdodo in Helsinki
You will need to change a few things in the script (mainly the name of the city and the default Google map coordinates and zoom level), and a directory on the server to store cache files. Then put the script in a directory on your server suitable for housing CGI scripts, make the script executable, and it should work.
The script relies on the Flickr and Google Maps APIs, and if either service is slow or down, there may be problems. The first time you run the script, it will create a cache of data from Flickr, which will be slow, but it will run more quickly after that.
Chris Heathcote