Method: GoogleLocationsClient#api_get_google_location_data

Defined in:
lib/whos_using_what/api_clients/google_locations_client.rb

#api_get_google_location_data(zip_code) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/whos_using_what/api_clients/google_locations_client.rb', line 15

def api_get_google_location_data zip_code

  params = "q=" << zip_code
  "&output=json"
  "&key=" << @google_api_key


  @geo_code_api_url_base = "http://maps.google.com/maps/geo?"

  begin
    rawHtml = RestClient.get(@geo_code_api_url_base << params)
  rescue Exception => e
    puts e
  end

  json_resp = JSON.parse(rawHtml.body)

  resp_map = nil
  begin
    resp_map = json_resp["Placemark"][0]
  rescue

  end

  if !resp_map
    return nil
  end
  resp_map
end