Gallery2 plugin – displaying googlemaps with GPS coordinates from EXIF
Thursday, August 31st, 2006After resuming my geotaggin script (see this post), I decided to do something useful with it. We’re using gallery2 to store our photos and with a [googlemap plugin](http://codex.gallery2.org/index.php/Gallery2:Modules:Map), but found it useful only for displaying a single pointer per album (see [here](http://gallery.ibao.net/Map/)). For a more fine-grained selection we needed something else.
Therefore, I decided to write my own plugin (yeah, there are already two out there, why not write my own?
) and also learn Gallery2 API. The idea is to display a google map at the bottom of each photo, showing exactly where the photo was taken. Yes, it photo-specific and there’s only one pointer on the map. I find it nonetheless very useful.
Here’s a [sample output](http://gallery.ibao.net/travel/Switzerland/melchsee/IMG_2991.JPG.html) (you can also admire the beautiful scenery of Melchsee
). The plugin adds a new “block” in the template (therefore can be configured using a standard block management tool in Gallery2).
The position of the current photo is always in the middle (although you can move the map around, change the map type, zoom in and out etc.). The changes you make are stored as session cookies, and preserved between consecutive photo loads. Also, the whole panel can be hidden to speed up load and only shown on demand (show map|hide map).
Any comments? suggestions? ideas?
The plugin is currently in _alpha_ stage, I will release it in a week or two (I want to create a webpage for it as well). In the meantime, if you’re interested in trying it out, drop me a line
BTW: I also found out that when iPhoto edits a photo, it converts Exif from Intel to Motorola (little endian -> big endian). There was a bug in [exifer](http://www.offsky.com/software/exif/index.php) used in gallery, which corrpted the tags. The patch is only two lines long and can be found here (I also emailed the author):
--- gps.inc.orig 2006-08-31 10:25:27.000000000 +0200
+++ gps.inc 2006-08-31 10:36:37.000000000 +0200
@@ -116,13 +116,24 @@
$minutes = GPSRational(substr($data,16,16),$intel);
$hour = GPSRational(substr($data,32,16),$intel);
+ /* now we need a hack, since the whole data has been flipped in :103
+ * the order here is sec:min:hour. However, in the motorla mode the data
+ * has not been flipped and the order is h:m:s. This breaks compatibility
+ * with Motorola exif. (Tadek) */
+ if($intel==1)
$data = $hour+$minutes/60+$seconds/3600;
+ else
+ $data = $seconds+$minutes/60+$hour/3600;
} else if($tag=="0007") { //Time
$seconds = GPSRational(substr($data,0,16),$intel);
$minutes = GPSRational(substr($data,16,16),$intel);
$hour = GPSRational(substr($data,32,16),$intel);
+ /* I guess the same HACK as above. Tadek */
+ if ($intel==1)
$data = $hour.":".$minutes.":".$seconds;
+ else
+ $data = $seconds.":".$minutes.":".$hour;
} else {
if($bottom!=0) $data=$top/$bottom;
else if($top==0) $data = 0;