Reverse Geocoding With The Google Maps API

October 26th, 2009

I’ve been playing a lot with Geocoding over the past few months and caius helped me put some code together that I think you might like (if you’ve come here from Google searching for reverse geocoding with the google maps api)

class ReverseGeocode
{
public static function get( $latitude, $longitude,$apikey )
{
$url = “http://maps.google.com/maps/geo?”;
$url .= http_build_query(array(“oe” => “utf8″,”output” => “json”,”sensor” => “false”, “key” => $apikey)) . “&q={$latitude},{$longitude}”;
$raw_data = file_get_contents($url);
$data = json_decode($raw_data);
return $data;
}
}

class ReverseGeocode

{

public static function get( $latitude, $longitude,$apikey )

{

$url = “http://maps.google.com/maps/geo?”;

$url .= http_build_query(array(“oe” => “utf8″,”output” => “json”,”sensor” => “false”, “key” => $apikey)) . “&q={$latitude},{$longitude}”;

$raw_data = file_get_contents($url);

$data = json_decode($raw_data);

return $data;

}

}

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • Faves
  • Netvouz
  • Ping.fm
  • Reddit
  • Technorati
  • TwitThis

Related posts:

  1. Google, are you taking the piss? Found on the Google Profile page..   Google has a...
  2. Google Showing “Skip Intro” Link? Am I missing something or has google always done this...
  3. The Google Curse? Google has a habit of buying companies and trashing them…...

2 Comments

  1. Caius says:

    And because I’m a complete code nazi (yes, even with PHP) I tidied it up over at http://gist.github.com/219157

    It may even embed properly:

    • Caius says:

      Or not.

Leave a Comment

If you are using programs like Authority Loophole to spam this blog please piss off and die, comments are moderated and your comment will not get through... so don't bother (you've a better chance of getting your comment accepted if you actually use your real name

  • * denotes a required field

© 2008 - Dominic "The Hodge" Hodgson. Powered by WordPress. Designed by Ryan Taylor (Havoc Inspired)