Google Map Shortcode Version 1.1

The new version of Google Map Shortcode is ready, some bugs were fixed and new features included.

The first release was based on “address”, then to include a point on the maps new instance of google geocoder was need, but google limits the number of this kind of request, read more here.

In this version new custom field “google-map-sc-latlng” was included to save the (Latitude,Longitude) for each address entered:


Now, you can include points on your maps using one of this custom fields considering this:

  • If you use “google-map-sc-address”, the first time that you display a point, the “google-map-sc-latlng” value will be generated automatically.
  • In order to use “google-map-sc-latlng” you need to include the latitude and longitude separated by comma.
  • If you update “google-map-sc-address” you must delete the “google-map-sc-latlng” cause this point will be located based on the previews address.
  • You can use “google-map-sc-latlng” only.
  • If you are planning to display large number of point is better to use “google-map-sc-latlng” or generate them one by one to avoid large number of address requests at the same time. You can generate latitude and longitude using for instance: http://www.batchgeocode.com/lookup/
  • You can attache more than one point per post/page but based on address or (latitude,longitude) see the example bellow.
  • If you are displaying all the points under specific category, just the first costum field of each post will be used.

The shortcode options can be found in the first release.

Examples

This example shows the points attached to the posts under the category 42 cat=”42″ and display the links to the points at the bottom of the map, external_links=”true”.

In this example the map displays some points on South Florida:

and the custom fields looks like this:

Using the post “id” id = “335”.

Using specific address option in the sortcode (not the custom field) address=”3501 S.W. 130th Ave., Davie 33330″,width=”250″, height=”250″ and zoom=”8″.

Notes

The Info Window is showed when you are displaying post on your maps for example the posts under a category or when you use the post ID, just in these cases make sense to display the the title, thumbnail and excerpt of your posts.

You can change the html and the css of the Info Windows to cutomize it.

The shortcode name is google-map-sc

Download

google-map-shortcode

Add your suggestions, support the plugin.


91 thoughts on “Google Map Shortcode Version 1.1”

  1. Now it works for me after doing what Zafrir Ron suggest a couple of comments below to change on: google-map-shortcode.php line 649

    Works with both custom fields and if I add the address to shortcode.

    Alain: This might be something to change to in version 1.2?

  2. @Jonas: have you managed to solve the issue with the map not showing up? I have the same problem.

    Over here it works when ignoring the custom field and just adding the full address as parameter to [google-map-sc]. But this didn’t work for you either, did it?

  3. hi,
    just ran into a problem when I set my blog to be in the root folder of my website but kept the wordpress installation in a folder other than the root folder.
    “google-map-shortcode.php” gets the URL of the site by calling “get_bloginfo(‘url’)” at lines 25 and 26 but it should call “get_bloginfo(‘wpurl’)” to get the actual URL of the installation. making this change fixed the problem.

    fyi.

  4. @Zafrir Ron

    in order to fix this on hosting without access to php.ini use wp_remote_fopen function;

    change:
    google-map-shortcode.php line 649

    comment out:

    //if (!($fp = @ fopen($url, ‘rb’)))
    //{
    // return array ();
    //}
    //while (!feof($fp))
    //{
    // $contents .= fread($fp, 8192);
    //}
    //fclose($fp);

    replace with

    $contents = wp_remote_fopen($url);

  5. Just one more small bug found:

    the plugin javascript includes is using bloginfo(‘url’) it should change to ‘mpurl’
    the bug is cousing map not displayed on blogs that installation folder is dofferent from blog home url (looking on wrong js folder location);

    change in google-map-shortcode.php lines 25,26

  6. After spending few hours trying to find why Maps are not displyed reading some comments here about the problem.
    debuggin the plugin code..
    I suggest to add a cleare requrement direction to make sure that the server PHP ini option allow_url_fopen is set to true.
    If not the script can not open google map XML responce and will not display anything with no warning nothing will be displayed.

    hope saved some headackes for you guys…
    Zafi

  7. Mike Walsh :I am running into an issue with the plugin which I can’t seem to resolve.
    On my archive pages which make use of the “the_excerpt()” tag, I am getting Javascript output as text in my post content. Any idea why? I looked through your plugin code and it appears that you have a filter to process shortcodes in the the_excerpt() but that function is never getting called.
    It appears that the shortcode is partially being processed as the Javascript to produce the map canvas is generated but the DIV and SCRIPT tags that surround it are not in the output.

    After further digging this appears to be an incompatibility with EC3 Event Calendar plugin: http://wpcal.firetree.net/ I am not sure which is wrong but bout EC3 and GMSC are “emulating” the_excerpt().

  8. I am running into an issue with the plugin which I can’t seem to resolve.

    On my archive pages which make use of the “the_excerpt()” tag, I am getting Javascript output as text in my post content. Any idea why? I looked through your plugin code and it appears that you have a filter to process shortcodes in the the_excerpt() but that function is never getting called.

    It appears that the shortcode is partially being processed as the Javascript to produce the map canvas is generated but the DIV and SCRIPT tags that surround it are not in the output.

  9. Yes, but if you check the actual post in the admin interface, you’ll see that I’ve written:

    START Google map with address in Custom Fields.

    [google-map-sc]

    END Google map

    and on the other active post:

    START Google map with address in Shortcode:

    [google-map-sc address="33 W 55th St, New York, NY 10019, USA"]

    END Google map

  10. @Jonas
    I dont see the shortcode there. Just:

    START Google map with address in Shortcode:

    END Google map

    you need something like:

    [google-map-sc ....options]

Leave a Reply

Your email address will not be published. Required fields are marked *