Been hitting my head against a wall for a couple weeks... I'm working on modifying a geotagging Wordpress plugin called Thesography. I have notified the developer of my past enhancements, and they are OK with it because this plugin is licensed under the terms of the GNU General Public License.
Currently the plugin will return a mini popup Google map for a single post, with a single image. I am looking to expand upon it to have another function which will display 1 large Google Map. This larger map will have all my geotagged images as pinpoints Then, using the Google Maps API, also display a thumbnail and post title for the specific image and pinpoint.
Onto the code:
Here is a snippet of the current code from the plugin. This snippet which retrieves the image data from the database for the specific image. As you can see, this code works for the current post. How can it be modified to include all images from all posts?
if (is_null($imgID)) {
$images = get_children(array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'numberposts' => 1,
'post_mime_type' => 'image',
'orderby' => 'ID',
'order' => 'ASC'
));
if ($images) {
foreach ($images as $image) {
$imgID = $image->ID;
}
}
}
$imgmeta = wp_get_attachment_metadata($imgID);
if ($imgmeta)
{
if ($imgmeta['image_meta']['latitude'])
$latitude = $imgmeta['image_meta']['latitude'];
if ($imgmeta['image_meta']['longitude'])
$longitude = $imgmeta['image_meta']['longitude'];
if ($imgmeta['image_meta']['latitude_ref'])
$lat_ref = $imgmeta['image_meta']['latitude_ref'];
if ($imgmeta['image_meta']['longitude_ref'])
$lng_ref = $imgmeta['image_meta']['longitude_ref'];
$lat = geo_single_fracs2dec($latitude);
$lng = geo_single_fracs2dec($longitude);
if ($lat_ref == 'S') { $neg_lat = '-'; } else { $neg_lat = ''; }
if ($lng_ref == 'W') { $neg_lng = '-'; } else { $neg_lng = ''; }
$latlng = $neg_lat . number_format($lat,6) . ',' . $neg_lng . number_format($lng, 6);
And here's a sample snippet of the Google Maps API that I need to fit this latitude, longitude into. It will contain the latitude, longitude, the image source URL and the title of the post it displays in. That way someone can hover over a pinpoint, see the image, then click it to read more.
var point = new GLatLng(43.91892,-78.89231);
var marker = createMarker(point,'<a href="http://#>The Title of the Page</a><br><img src="http://image.jpg" width=150 height=100>')
map.addOverlay(marker);
It's a fun one! I have been hitting my head against the wall and have come up blank each time I try.