Title: GoogleGeoCoder
Last modified: August 21, 2016

---

# GoogleGeoCoder

 *  Resolved [mountainTops](https://wordpress.org/support/users/mountaintops/)
 * (@mountaintops)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/googlegeocoder/)
 * Hey FS,
 * I spotted some differences between some previous code and current code on Github
   as it relates to the GoogleGeoCoder in the common_functions.php.
 * Can you explain the differences for why you updated the following lines of code:
 * function google_geocoder($address, $api) {
    $address = str_replace(‘ ‘, ‘+’, 
   $address); $XMLUrl = ‘[http://maps.google.com/maps/geo?q=&#8217](http://maps.google.com/maps/geo?q=&#8217);.
   $address.’&key=’.$api.’&sensor=false&output=xml&oe=utf8′;
 *  $XMLContents = file_get_contents($XMLUrl);
 *  $XML = new SimpleXMLElement($XMLContents);
 *  $Coords = explode(‘,’,$XML->Response->Placemark->Point->coordinates);
 *  return $Coords;
    }
 * and the current code:
 * function google_geocoder($address, $api) {
    $Coords = ”; $address = str_replace(‘‘,‘
   +’, $address); $XMLUrl = ‘[http://maps.googleapis.com/maps/api/geocode/xml?address=&#8217](http://maps.googleapis.com/maps/api/geocode/xml?address=&#8217);.
   $address.’&sensor=false’; $XMLContents = file_get_contents($XMLUrl); $XML = new
   SimpleXMLElement($XMLContents); if (isset($XML->result->geometry->location->lat)){
   $Coords[1] = $XML->result->geometry->location->lat; } if (isset($XML->result-
   >geometry->location->lng)) { $Coords[0] = $XML->result->geometry->location->lng;}
   return $Coords; }
 * And could there be issues with the older code?
 * Thanks.
 * [http://wordpress.org/plugins/fs-real-estate-plugin/](http://wordpress.org/plugins/fs-real-estate-plugin/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [FireStorm Plugins](https://wordpress.org/support/users/wfernley/)
 * (@wfernley)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/googlegeocoder/#post-4505172)
 * Hey, looks like that code was for using Version 2 of the Google Geocoder. The
   new code is for Version 3. The old code required each site to have an API and
   had less features. The new version is much better and no longer requires an API.
   Google no longer supports the old version as well.
 *  Thread Starter [mountainTops](https://wordpress.org/support/users/mountaintops/)
 * (@mountaintops)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/googlegeocoder/#post-4505201)
 * Ok thanks. I have a client that has an older version of the FS plugin and it 
   hasn’t been updated since I customized some of the code for them. Can I simply
   replace and update those lines of code in the common_functions.php file, or are
   there other dependences that make those lines work?
 *  Plugin Author [FireStorm Plugins](https://wordpress.org/support/users/wfernley/)
 * (@wfernley)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/googlegeocoder/#post-4505203)
 * It is worth a try – just keep a backup of the original code just in case. A lot
   has changed in the plugin since it used version 2 of the api however you might
   be able to just replace the geocoder function.
 *  Thread Starter [mountainTops](https://wordpress.org/support/users/mountaintops/)
 * (@mountaintops)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/googlegeocoder/#post-4505247)
 * Thanks. I’ll give it a try.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘GoogleGeoCoder’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/fs-real-estate-plugin_35739e.svg)
 * [FireStorm Professional Real Estate Plugin](https://wordpress.org/plugins/fs-real-estate-plugin/)
 * [Support Threads](https://wordpress.org/support/plugin/fs-real-estate-plugin/)
 * [Active Topics](https://wordpress.org/support/plugin/fs-real-estate-plugin/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/fs-real-estate-plugin/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/fs-real-estate-plugin/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [mountainTops](https://wordpress.org/support/users/mountaintops/)
 * Last activity: [12 years, 3 months ago](https://wordpress.org/support/topic/googlegeocoder/#post-4505247)
 * Status: resolved