Support » Plugin: Comprehensive Google Map Plugin » [Plugin: Comprehensive Google Map Plugin] Shortcode to automatically display images on a google map

  • Hi,

    First I would like to thank you for this great plugin. It is the best of this kind I found. Complete, easy to use and easy to hack, it rocks!

    I was looking for a plugin displaying automatically images of a post inside an embedded Google map according to their exif location. Unfortunately, I didn’t find one (I didn’t wanted to use custom fields, or special gallery). Then I found your plugin, and thought it will be easy to extend with my limited skills.

    And this is what I want to share with everyone.

    The result is quite easy to use, you just have to had the shortcode [autoimage] and the map displays the locations of all the images linked to your post. You can use all the options of the original plugin, as all it does is to extract exif locations of images, then to give them to the original plugin.


    To do this, I created a new plugin “cgmp-autoimage” (not available on It is 2 small files:

    * cgmp-autoimage.php
    * shortcode.php
    I wanted to add route between the markers but can’t figure how.

    I also wanted to customize the bubble to look like this:

    So I had to modify your own code like this (based on 7.0.27):

    * functions.php (to add new wiki patterns)
    * cgmp.framework.js (change bubble size and remove directions).

    I have not the skills, nor the time to maintain my code, so I give it to Alexander Zagniotov. You can do whatever you want with it.

    Thank you

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Contributor alexanderzagniotov


    Looks interesting. I will definitely look into what you did once I am in US.


    Plugin Contributor alexanderzagniotov


    Actually, i gave it a second more thorough look – this is great! Thanks!

    Plugin Contributor alexanderzagniotov



    I want to apologize – I have been busy with relocation and did not have a chance to incorporate your changes yet :/

    I have not forgotten your efforts.

    This is not a problem, take your time with your relocation 🙂

    Plugin Contributor alexanderzagniotov


    Your change will be the next todo for me

    It would be nice to be able to enter or edit the location of an image. Maybe that is already possible. I am looking for an easy way to display pics submitted from all over the world on a map and have them popup when clicked.

    Plugin Contributor alexanderzagniotov



    I was looking at your logic today and tried to spike it by merging in with my plugin. I am having trouble finding the images that would provide me with exif GPS information, just like you have in your paste:

    I have tried different pictures from digital cameras, and one GPS enabled digital camera, the exif metadata in my case never contained “GPS…” keys. It did however contain a bunch of other metadata

    When you took your pics, did you use any specific camera with any specific settings/abilities?

    I want to provide very clear instructions to users that explain when should they use this feature.

    Thank you

    I was researching this and found that you can easily add the gps data in the free google picture editor Picassa.


    I did nothing nor use specific settings, I just took shoots with my camera with GPS enabled. It’s a Sony HX9V.

    After reading your post, I tried with my phone, and indeed that doesn’t work. Seems there is no standard for storing location in pictures. I’ll try to make this work with my phone, maybe this will give us clues.

    @jostockton and @alexanderzagniotov

    I believe it is standard and Picassa is a great tool to see the exif data. I just took a pic with my iPhone with GPS enabled and the location shows up in two fields “GPS Latitude” and “GPS Longitude”.

    The nice thing about Picassa being a Google App is that if a picture has no GPS data in the exif, you can just drag the pic to a map within Picassa and it will add the coordinates into those two fields.

    Also, here is a wiki on the formatting of the data within the exif:

    Thanks for your work on this. I would like to add this functionality to my blog.

    I figured out the problem with my phone (Galaxy S2 with Cyanogenmod 9), the location was already computed, and stored in $exif[“GPSLatitude”][0] and $exif[“GPSLongitude”][0]. The other entries $exif[“GPSLatitude”][1] etc. are empty.

    I made this patch : and my code works with photos from my phone.

    But this is ugly, as it won’t work if $exif[“GPSLongitude”][1] (or the others) equals 0 for legit reason. This is unlikely, but we never know.


    I was trying to get your code up and running, but the cheap shared hosting I have runs php 5.2.9 so this line doesn’t work
    $date=date_create_from_format(‘Y:m:d H:i:s’, $img[‘date’]);

    Any ideas on making it work for 5.2.9?

    Thanks, I realize you don’t want to support this, but any help is appreciated.

    @oddcopter Try to Replace

    $date=date_create_from_format('Y:m:d H:i:s', $img['date']);
    $list_coord_gps.="#-".date_format($date,'d/m/Y H:i:s');


    $informat = '%Y:%m:%d %H:%M:%S';
    $ftime = strptime($img['date'],$informat);
    $unxTimestamp = mktime(
            $ftime['tm_yday'] + 1,
            $ftime['tm_year'] + 1900
    $date=date('d/m/Y H:i:s',$unxTimestamp);

    Edit : I’m french this is why I format the date d/m/Y. Change it as you want.
    Edit2 : this portion of code should work with php 5.1 or greater. All methods are PHP4/PHP5, except strptime PHP 5.1.

    Using date and time formats set in wordpress is better. Replace

    $list_coord_gps.="#-".date_format($date,'d/m/Y H:i:s');


    $date=date_i18n( get_option('date_format')." ".get_option('time_format'), date_timestamp_get($date));

    @oddcopter replace

    $date=date('d/m/Y H:i:s',$unxTimestamp);


    $date=date_i18n( get_option('date_format')." ".get_option('time_format'), $unxTimestamp);


    Thank you very much!

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘[Plugin: Comprehensive Google Map Plugin] Shortcode to automatically display images on a google map’ is closed to new replies.