WordPress – Google Maps GeoCoder

Download WPGMG

Okay, I couldn’t find a plugin that would easily Geocode my posts. So here it is, plugin # 3,181 on WordPress.org, and one very dear to my heart. WPGMG Why, GeoCode to custom fields? 1. Google only allows 10,000 geocodes per URL per day. 2. Calculate distances based on lattitude and longitude. Anyhow, this is version 0.1. Simply replaces the XXXXXXXX’s with your Google Maps API key and your ready to role. I guess you want to know how to make it work? Just released, WPGMG ver 0.2. I’ve noticed people are actually downloading the plugin from WordPress.org, so I added a settings menu to make it easier to input your Google Maps API Key, and enable/disable the plugin. WPGMG looks for four custom field keys: street address, city,state, zip WPGMG queries Google Maps API for the latitude and longitude, from that it will create 2 new custom fields for that post: lat & lng ‘lat’ obviously being Latitude and ‘lng’ being Longitude. You will need a Google Maps API Key, you can get here: http://code.google.com/apis/maps/signup.html As you can see the code is very simple, and easily manipulated. It’s licensed under DWIWYW (Do with it what you will). I hope this helps you as much as it could have helped me if someone would have done it first. Please feel free to leave any suggestions or complaints, a donation would be greatly appreciated by my wife.

Download WPGMG


New OSM Plugin support WPGMG: Shortcode : [osm_map import="WPGMG"] Render map: [osm_map marker_all_posts=*"WPGMG"*]* Configurable – Check it out:

OSM Pluginpage:
http://www.Fotomobil.at/wp-osm-plugin

OSM & WPGMG:
http://www.Fotomobil.at/wp-osm-plugin-how-to-import-data


  • #1 written by Michael
    about 2 years ago

    Hi Karl,

    Noticed that version 0.69 is out now, just wondering if you could let me know what the changes were, just in case I happened to have edited your plugin code.

    Is this a critical release? I’m running 0.2 right now.

    Thanks…

    Michael
    http://halfhourworkweek.com

  • #2 written by admin
    about 2 years ago

    Version .69 changes nothing in the function as far as the geocoding/geotagging is concerned. All that I’ve done is add a function & shortcode for mapping. For future reference Michael, anything with the # 69 in it, is never critical.

    You can setup and size map, it will adjust automatically the controls if the map is too small. It has the GoogleEarth plugin control on the map which is pretty cool for users with GoogleEarth. You can see it in use at BanditTrackerChicago.com, I’ve added a small map function in the sidebar.php – if(is_single) { show_wpgmg(300,350); }, then I’ve added another template page to the theme with just the header, content as show_wpgmg(940,720); footer, and setup a blank page post named ‘Map’ from there.

    I did some customization for the use on the BanditTrackerChicago.com site so that it would pull the KML files from other sites (pretty easy change and I’ll include this in the next release so you can pull KML from any site and include it in your map). I also customized the icons – upcoming release depending on demand for it.

    Karl

  • #3 written by Travis
    about 2 years ago

    One note: In this post, you say ‘WPGMG looks for four custom field keys: street, city,state, zip.’ I believe it looks for ‘address’ instead of ‘street.’ Granted, I may be guilty of not reading the readme before jumping straight in. Thanks for the great plugin, it helps a lot.

  • #4 written by Darren
    about 2 years ago

    Hi,

    How can I use the plugin to show just one geo location per page? E.g. I’ve a directory set up in WP which offers businesses one page each. On the page is there details, address etc and a Google Map of their location. However when I use your brilliant plugin it pulls in all the addresses into the map from all the businesses I have on WP and centers on the most recent one. I’d like to be able to just show the map of the relevant business on their page based on their address. Any thoughts on whether this is possible? Thanks in advance

  • #5 written by admin
    about 2 years ago

    Darren, this is possible but will require a minor tweak of the plugin… I’ll add a shortcode and function to the plugin and the new release will allow this….. it should be easy enough to have done by later today….

    Good thought…. Thanks!

  • #6 written by admin
    about 2 years ago

    [showmap]

  • #7 written by Darren
    about 2 years ago

    Hi again,

    I’ve got version 1.0 (is this the latest version?) running and the short code works however what I’m after is having the map show just the address details on the current post.

    If you take a look at the test page I’m working on: http://www.homes-interiors.com/pages/?p=267 You’ll see the address is there but the map shows multiple geo locations from other posts. Is it possible to have each post show just 1 locations (the one relevant to that post)?

    Loving the plugin and really hope you can help with this.

    Thanks in advance,
    Darren

  • #8 written by admin
    about 2 years ago

    Hi Darren,

    I didn’t know how well this would work outside of the US, I guess I really didn’t plan on it but Google apparently figured out your addresses.

    I have updated the plugin to allow for single posts, [showmapsingle] (works the same as previous shortcode) It will check to make sure it is a single post. You can still use the [showmap] on category or other pages as well.

    When WordPress updates the SVN you should see WPGMG version 1.1 available as an update.

    Please donate if you can, donations keep the open-source community building!

  • #9 written by Darren
    about 2 years ago

    Genius, thank you very much for the fix, works like a dream. I’ve just made a donation so please keep up the good work! Thanks again.

    Darren

  • #10 written by Harris
    about 2 years ago

    Nice plugin, however I can’t use it yet since the marker info window does not show anything. Just blank. I checked the one at your sidebar and has the same problem. Do you know how we can display the post title inside the info window? or at least add any text so it is not a blank window?

    I saw that Darren was able to accomplish that on his site: http://www.homes-interiors.com/pages/?p=267

    Thanks.

  • #11 written by Harris
    about 2 years ago

    By the way. @Darren. If in case you are still seeing replies from this post, I have a client that wants a similar site to http://www.homes-interiors.com/pages/?p=267. Let me know if you are interested and I will tell her to contact you directly.

    Harris

  • #12 written by admin
    about 2 years ago

    Harris – I have it customized quite a bit for my application (http://BanditTrackerChicago.com), but I will change it to add the title in the info window if a custom field (yet to be named) is left blank.

    Thanks.
    Karl

  • #13 written by ChrisJ
    about 2 years ago

    Hi Karl,
    I’m getting error output from [showmap] as follows:

    [code]} // display a warning if the browser was not compatible else { alert("Sorry, the Google Maps API is not compatible with this browser"); } var ge; function getEarthInstanceCB(pluginInstance) { ge = pluginInstance; // you can now manipulate ge using the full Google Earth API. } //]]> [/code]

    Any ideas why?

  • #14 written by Alexander
    about 2 years ago

    I’m having the same error when trying it myself. Which is a shame, as my boss is eager to check out the new maps I’ve said to fix :P

  • #15 written by Dan Huynh
    about 2 years ago

    Hi Karl,

    What’s the best way to map out distance between two points for example, the post address and my house with your plug-in? Thanks for all the work!

    -Dan

  • #16 written by Michael
    about 2 years ago

    Hello Karl!

    I finally went ahead and upgraded from the first release and noticed there might be a geocoding error that occurs, due to a possible problem in the new code.

    Check out line 149 in geocoder.php and see if the variable $street is actually asking for the wrong meta data from WP ($address) — as all my posts are ending up with incorrect lat/lng as of the 1.1 release.

    I’ll download the 1.2 and see if the same problem occurs.

    Thanks,

    Michael

  • #17 written by Jonas
    about 2 years ago

    Hi, seems pretty straightforward to install but I seem to fail with the below errormessage. I just registered for an API key with the specific URL, but when I edit a page and choose SAVE it gives me the below errormessage. If I disable Google Maps Geocoding I don’t get this error.

    Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /home/mydir/public_html/dev1/wp-content/plugins/google-maps-geocoder/geocoder.php on line 158

    Warning: file_get_contents(http://maps.google.com/maps/geo?output=csv&key=ABQIAAAAjtAjDN7uzPLYc5F-t2CUghSHBhBgnXZyY0LfKL_Z03A1Rk1S4BTinMTVc5ah5abwka17t9DA270lzQ&q=%2C%2C%2C) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /home/mydir/public_html/dev1/wp-content/plugins/google-maps-geocoder/geocoder.php on line 158
    url not loading

  • #18 written by Darren
    about 2 years ago

    @Harris, If you see this and your client is still after a site like Homes and Interiors please feel free to contact me via my site: http://www.darrenlangley.com.

    @Karl sorry to digress from your great plug-in, hope you don’t mind.

    cheers,

    Darren

  • #19 written by Jonas
    about 2 years ago

    On my comment on 29th – I think I solved it. See this link for more info:
    http://www.learnphponline.com/errors/url-file-access-is-disabled-in-the-server-configuration

    Since the php.ini way didn’t go my way, I tried to edit the 158 line from:
    $csv = file_get_contents($request_url) or die(“url not loading”);
    …to what we have on line 157:
    $csv = “http://maps.google.com/maps/geo?output=csv&key=”.$wpgmgapikey.”&q=” . urlencode($address) or die(“url not loading”);

    No error when saving after that!

    However, now when I view a page with [showmap] I get same problem as ChrisJ above.

    } // display a warning if the browser was not compatible else { alert(“Sorry, the Google Maps API is not compatible with this browser”); } var ge; function getEarthInstanceCB(pluginInstance) { ge = pluginInstance; // you can now manipulate ge using the full Google Earth API. } //]]>

    And of course, I’ve tried it in several browsers.

  • #20 written by Resh
    about 1 year ago

    Hi Jonas

    Just installed the plugin myself. I had a similar problem and fixed it with:

    //$csv = file_get_contents($request_url) or die(“url not loading”);

    $request = new WP_Http;
    $csv = $request->request( $request_url);
    //var_dump($csv);
    $csvSplit = split(“,”, $csv['body']);

    Hope this helps. How do I get the plugin to show unique maps for each attraction location (individual posts) on my site? Will hopefully sort it before I get a response… :-)

    Resh

  • #21 written by Luke
    about 11 months ago

    Hey Carl,

    Great plugin.

    One little problem right now:
    The full map (using the theme php call, not the shortcode) is returning this:
    } // display a warning if the browser was not compatible else { alert(“Sorry, the Google Maps API is not compatible with this browser”); } var ge; function getEarthInstanceCB(pluginInstance) { ge = pluginInstance; // you can now manipulate ge using the full Google Earth API. } //]]>

    Any ideas on what I might have done wrong? Thanks. The plugin is successfully geocoding posts on save.

    Cheers,
    Luke

No trackbacks yet.
  • My latest tweets

    Follow me on Twitter!