The recently released Google maps API v3 returns geocoding info in json
format as shown below.  I am sure there is an elegant way to extract the
lat/lng but I have failed to find it after many attempts - can anyone
help?  Thanks in advance.

{
  "status": "OK",
  "results": [ {
    "types": [ "point_of_interest", "establishment" ],
    "formatted_address": "Buckingham Palace, Westminster, London, UK",
    "address_components": [ {
      "long_name": "Buckingham Palace",
      "short_name": "Buckingham Palace",
      "types": [ "point_of_interest", "establishment" ]
    }, {
      "long_name": "London",
      "short_name": "London",
      "types": [ "locality", "political" ]
    }, {
      "long_name": "Westminster",
      "short_name": "Westminster",
      "types": [ "administrative_area_level_3", "political" ]
    }, {
      "long_name": "Greater London",
      "short_name": "Gt Lon",
      "types": [ "administrative_area_level_2", "political" ]
    }, {
      "long_name": "England",
      "short_name": "England",
      "types": [ "administrative_area_level_1", "political" ]
    }, {
      "long_name": "United Kingdom",
      "short_name": "GB",
      "types": [ "country", "political" ]
    } ],
    "geometry": {
      "location": {
        "lat": 51.5007890,
        "lng": -0.1422640
      },
      "location_type": "APPROXIMATE",
      "viewport": {
        "southwest": {
          "lat": 51.4938426,
          "lng": -0.1582714
        },
        "northeast": {
          "lat": 51.5077344,
          "lng": -0.1262566
        }
      }
    }
  } ]
}
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to