Display Photo Location Using LEADTOOLS and Google Maps
Posted by Gabriel Smith
I recently took a 1,900 mile road trip with my son. We flew into Vegas, rented a convertible, and started to drive to Tulsa, OK via Route 66 with many stops on the way. During the trip, I took about 500 photos with my phone to save these important memories forever. Once I got home, I started going through all of the photos. (Why did I take so many?!) Trying to remember exactly where I was when I took a specific picture was sometimes difficult. To help me with this process, I used LEADTOOLS in a new little WinForms application project that pulls the GPS coordinates that my phone stored in the EXIF tags of the photos. Then it uses those coordinates with the Google Maps API to display a static map and a marker. As an extra bonus, I added a link to open Google Street View based on the photo coordinates in the default web browser and another link to open the location with interactive Google Maps in the application.
Points of Interest
Windows Forms Web Browser
WebBrowser control defaults to IE7.
Google Maps does not appreciate a web browser that old and will refuse to load the map, but there is a way to change the version by editing the registry. Check out the comments in
LabelStatusMapLink_Click event for more information. Even after the change, Google Street View refused to work properly in the
WebBrowser control, so I open it in the default browser instead of in the application.
The coordinates are stored as unsigned rationals in four tags. Two tags store the degrees, minutes, and seconds, while the other two store the hemisphere of the respective coordinate. For more information, check out the
ExifGpsToDoublefunction in the
Google Street View
Google Street View brings a couple of nifty features to the table. For one, going back and getting a context of the photo really brought back some good memories. Also, there are some places that you can actually go into buildings. Check out the street view link of the Mother Road Brewing photo in Flagstaff, AZ to see that. Finally, Google Street View has a way to see past images of a location so that now I can see how a location has changed over time. The Weatherford, OK photo has Google Street Views from before the Route 66 signs — the subject of my photo — were built.
Git the Code
Clone, Fork, or Download the code from GitHub: Git the Code
Ideas for Other Applications
- Web version that integrates Google Drive. I can automatically share a photo to Google Drive when it is taken, and a web version makes the application more accessible.
- Use SharpShell to create some Windows Explorer Preview Handler to show Google Map in Windows Explorer preview window.
- I noticed that some image files do not have the GPS coordinates because they were processed with Instagram or some other application. Create a Windows Explorer context menu handler to copy the GPS from one file into another.