Monday, 14th December 2009 at 11:11 pm | 10 Comments »

A minor update to the WP Geo plugin.

  • Updated Danish, French and German translations.
  • Google Maps locale is set based on WordPress locale.
  • Added template tags wpgeo_longitude() and wpgeo_latitude().

So what’s changed?

The Google Map is now loaded in the same locale as WordPress. Thanks to Alain Messin (who also updated the French translation) for the code to do that.

Also, I have added 2 templates tags so you can display the longitude and latitude in your WordPress templates. These template tags will display values for the current post in the loop. Alternatively you can pass a post ID as a parameter to use the value for a specific post.


You can also use get_wpgeo_longitude() and get_wpgeo_latitude() to get the values without displaying them.

$my_latitude = get_wpgeo_latitude();
$other_latitude = get_wpgeo_latitude(27);

You can download the latest version of WP Geo here…

10 Responses to “WP Geo 3.1.1”

  1. Matt Facer says:

    Hi – I notice you mention that the locale is set to the same as wordpress. Maybe it’s just me, but sometimes my searches when creating a new post end up in the states.

    I’ve tried changing the code to force “en-GB” (changing line 683 in wp-geo.php to read:)

    $l = apply_filters(‘wp_geo_locale’, ‘en-GB’); //forced to UK

    but if I do a search for “M34 6AD” it will take me to some freeway in the states (called M34).

    “M34, Manchester” works OK… is there a way to absolutely 100% FORCE the api to ONLY return UK results? The way my site is designed, there’s no way it would need a location outside of the UK.

    Thanks (and again, great plugin.. I’ve changed a fair bit now like getting the town returned where ever the pin is dropped)

  2. Ben says:

    Hmm, will have a look.

    When I say the locale is set by WordPress, this refers to the language of the map controls, not a geographic location.

    • Matt Facer says:

      Aaah I see. Is there a way to force ANY query to return the UK?

      Thinking about it, I could get the string from the textfield, then simply check if it contains “UK”… or just add that to the end… so

      string + “, uk”

      would always return a uk query.

  3. Matt Facer says:

    I can confirm that in the JS function wp_geo_showAddress() does work nicely if you add UK to the end of the search string.

    geocoder.getLatLng(address + ” UK”, function(point) { … });

    m346ad used to fail – but now correctly locates to denton, manchester
    m34 6ad used to take you to america – now correctly locates

    and tried with a search for “Austin” which previously MAY have taken you to texas (I think?!) … now finds somewhere near Birmingham.

    Have you thought about setting up a forum for this site? I feel like I have lots to possibly share, but don’t want to bombard the comments board!!

  4. Matt Facer says:

    Cool – cheers. I’ve been making a few changes to the core code, so chances are I may never upgrade (so long as it’s working as I need!)

    I’m now trying to create the search function. I have some SQL which works out the distance from given lat and lon coords… but I’m not sure where to put it in your code. I’ve spent ages trying to find where you make the DB calls. the function “get_post_meta()” I just cannot find!! Any tips??

    I am putting the code in get_content() so when the map is drawn on a post, it will then go to see what other posts are nearby.

    • Ben says:

      Matt, at the moment the plugin does not make any database calls. It only displays a map based on data already available on the current page.

      I’m currently working on an interface to display maps based on specific queries but have not yet got very far…

      The idea would be to insert a google map on the page then load the points via another script which queries the database, maybe returning the data as XML or as a GeoRSS or KML feed.

      PS. I have also set up a WP Geo forum which I’ll add links to around the site

  5. mattfacer says:

    thanks for setting up the forum – I’ll probably be posting in there a fair bit!

  6. Was wondering if you had anything new news on this? Thanks!

Leave a Reply