22 September 2008
The Panoramio web site has a great collection of photos from all over the world, and they also have a very convenient web API. I thought it would be a lot of fun to use Android to access this content while you are out walking around – and especially to have Android find interesting photos based on your current location. The resulting open source application is now available in the apps-for-android project.
The application starts by showing your current location in a custom MapView. You can pan and zoom this map to choose the area you want to search.
Once you have selected a search area, the application downloads thumbnails of the most popular photos taken within that area:
You can tap on an item to see more details.
From here you can use the menu to find more pictures by the same photographer or to see the original photo on the Panoramio site. My two favorite features, though, help you find the location of the photo in the real world. You can show the location on the map along with your current location:
Or, you can bring up a radar view that uses the compass and GPS to show you the location of the photo in relation to your own location:
I thought that other applications might want to use the radar view for their own purposes ("find me the nearest taqueria"), so I split that into its own package. You can find the source for that in the Radar project. Of course, you don't need the source in order to use this feature. Because of Android's component architecture, all you need to do us use an Intent:
Intent i = new Intent("com.google.android.radar.SHOW_RADAR");
i.putExtra("latitude", 37.422f);
i.putExtra("longitude", -122.084f);
startActivity(i);
The code for these applications is not very long, but they are a good example of how to use a number of Android's location APIs: