Geocodex v0.1.0 Geocodex View Source

Provides API wrappers for the Google Maps Geocoding API See: https://developers.google.com/maps/documentation/geocoding/start

Link to this section Summary

Functions

Returns address components for the given address

Returns address components for the given coordinates

Returns address components for the given place id, this functionality is only available if an API key or a client ID is provided

Sets an api key to enable Premium features

Link to this section Functions

Returns address components for the given address

Example

iex> Geocodex.address("1600 Amphitheatre Parkway, Mountain View, CA")
%{"results" => [%{"address_components" => [%{"long_name" => "Google Building 41",
        "short_name" => "Google Bldg 41", "types" => ["premise"]},
      %{"long_name" => "1600", "short_name" => "1600",
        "types" => ["street_number"]},
      %{"long_name" => "Amphitheatre Parkway",
        "short_name" => "Amphitheatre Pkwy", "types" => ["route"]},
      %{"long_name" => "Mountain View", "short_name" => "Mountain View",
        "types" => ["locality", "political"]},
      %{"long_name" => "Santa Clara County",
        "short_name" => "Santa Clara County",
        "types" => ["administrative_area_level_2", "political"]},
      %{"long_name" => "California", "short_name" => "CA",
        "types" => ["administrative_area_level_1", "political"]},
      %{"long_name" => "United States", "short_name" => "US",
        "types" => ["country", "political"]},
      %{"long_name" => "94043", "short_name" => "94043",
        "types" => ["postal_code"]}],
    "formatted_address" => "Google Bldg 41, 1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",
    "geometry" => %{"bounds" => %{"northeast" => %{"lat" => 37.4228642,
          "lng" => -122.0851557},
        "southwest" => %{"lat" => 37.4221145, "lng" => -122.0859841}},
      "location" => %{"lat" => 37.4224082, "lng" => -122.0856086},
      "location_type" => "ROOFTOP",
      "viewport" => %{"northeast" => %{"lat" => 37.4238383302915,
          "lng" => -122.0842209197085},
        "southwest" => %{"lat" => 37.4211403697085,
          "lng" => -122.0869188802915}}},
    "place_id" => "ChIJxQvW8wK6j4AR3ukttGy3w2s", "types" => ["premise"]}],
  "status" => "OK"}
Link to this function coordinates(latitude, longitude) View Source

Returns address components for the given coordinates

Example

iex> Geocodex.coordinates(40.714224,-73.961452)
%{"results" => [%{"address_components" => [%{"long_name" => "277",
        "short_name" => "277", "types" => ["street_number"]},
      %{"long_name" => "Bedford Avenue", "short_name" => "Bedford Ave",
        "types" => ["route"]},
      %{"long_name" => "Williamsburg", "short_name" => "Williamsburg",
        "types" => ["neighborhood", "political"]},
      %{"long_name" => "Brooklyn", "short_name" => "Brooklyn",
        "types" => ["political", "sublocality", "sublocality_level_1"]},
      %{"long_name" => "Kings County", "short_name" => "Kings County",
        "types" => ["administrative_area_level_2", "political"]},
      %{"long_name" => "New York", "short_name" => "NY",
        "types" => ["administrative_area_level_1", "political"]},
      %{"long_name" => "United States", "short_name" => "US",
        "types" => ["country", "political"]},
      %{"long_name" => "11211", "short_name" => "11211",
        "types" => ["postal_code"]}],
    "formatted_address" => "277 Bedford Ave, Brooklyn, NY 11211, USA",
    "geometry" => %{"location" => %{"lat" => 40.7142205, "lng" => -73.9612903},
      "location_type" => "ROOFTOP",
      "viewport" => %{"northeast" => %{"lat" => 40.71556948029149,
          "lng" => -73.95994131970849},
        "southwest" => %{"lat" => 40.7128715197085,
          "lng" => -73.9626392802915}}},
    "place_id" => "ChIJd8BlQ2BZwokRAFUEcm_qrcA",
    "types" => ["street_address"]},
  %{"address_components" => [%{"long_name" => "Grand St/Bedford Av",
        "short_name" => "Grand St/Bedford Av",
        "types" => ["bus_station", "establishment", "point_of_interest",
        "transit_station"]},
      %{"long_name" => "Williamsburg", "short_name" => "Williamsburg",
        "types" => ["neighborhood", "political"]},
      %{"long_name" => "Brooklyn", "short_name" => "Brooklyn",
        "types" => ["political", "sublocality", "sublocality_level_1"]},
      %{"long_name" => "Kings County", "short_name" => "Kings County",
        "types" => ["administrative_area_level_2", "political"]},
      %{"long_name" => "New York", "short_name" => "NY",
        "types" => ["administrative_area_level_1", "political"]},
      %{"long_name" => "United States", "short_name" => "US",
        "types" => ["country", "political"]},
      %{"long_name" => "11211", "short_name" => "11211",
        "types" => ["postal_code"]}],
    "formatted_address" => "Grand St/Bedford Av, Brooklyn, NY 11211, USA",
    "geometry" => %{"location" => %{"lat" => 40.714321, "lng" => -73.961151},
      "location_type" => "APPROXIMATE",
      "viewport" => %{"northeast" => %{"lat" => 40.71566998029149,
          "lng" => -73.95980201970849},
        "southwest" => %{"lat" => 40.7129720197085,
          "lng" => -73.96249998029151}}},
    "place_id" => "ChIJi27VXGBZwokRM8ErPyB91yk",
    "types" => ["bus_station", "establishment", "point_of_interest",
      "transit_station"]},
  %{"address_components" => [%{"long_name" => "Williamsburg",
        "short_name" => "Williamsburg",
        "types" => ["neighborhood", "political"]},
      %{"long_name" => "Brooklyn", "short_name" => "Brooklyn",
        "types" => ["political", "sublocality", "sublocality_level_1"]},
      %{"long_name" => "New York", "short_name" => "New York",
        "types" => ["locality", "political"]},
      %{"long_name" => "Kings County", "short_name" => "Kings County",
        "types" => ["administrative_area_level_2", "political"]},
      %{"long_name" => "New York", "short_name" => "NY",
        "types" => ["administrative_area_level_1", "political"]},
      %{"long_name" => "United States", "short_name" => "US",
        "types" => ["country", "political"]}],
    "formatted_address" => "Williamsburg, Brooklyn, NY, USA",
    "geometry" => %{"bounds" => %{"northeast" => %{"lat" => 40.7251773,
          "lng" => -73.936498},
        "southwest" => %{"lat" => 40.6979329, "lng" => -73.96984499999999}},
      "location" => %{"lat" => 40.7081156, "lng" => -73.9570696},
      "location_type" => "APPROXIMATE",
      "viewport" => %{"northeast" => %{"lat" => 40.7251773,
          "lng" => -73.936498},
        "southwest" => %{"lat" => 40.6979329, "lng" => -73.96984499999999}}},
    "place_id" => "ChIJQSrBBv1bwokRbNfFHCnyeYI",
    "types" => ["neighborhood", "political"]},
  %{"address_components" => [%{"long_name" => "Brooklyn",
        "short_name" => "Brooklyn",
        "types" => ["political", "sublocality", "sublocality_level_1"]},
      %{"long_name" => "New York", "short_name" => "New York",
        "types" => ["locality", "political"]},
      %{"long_name" => "Kings County", "short_name" => "Kings County",
        "types" => ["administrative_area_level_2", "political"]},
      %{"long_name" => "New York", "short_name" => "NY",
        "types" => ["administrative_area_level_1", "political"]},
      %{"long_name" => "United States", "short_name" => "US",
        "types" => ["country", "political"]}],
    "formatted_address" => "Brooklyn, NY, USA",
    "geometry" => %{"bounds" => %{"northeast" => %{"lat" => 40.739446,
          "lng" => -73.8333651},
        "southwest" => %{"lat" => 40.551042, "lng" => -74.05663}},
      "location" => %{"lat" => 40.6781784, "lng" => -73.9441579},
      "location_type" => "APPROXIMATE",
      "viewport" => %{"northeast" => %{"lat" => 40.739446,
          "lng" => -73.8333651},
        "southwest" => %{"lat" => 40.551042, "lng" => -74.05663}}},
    "place_id" => "ChIJCSF8lBZEwokRhngABHRcdoI",
    "types" => ["political", "sublocality", "sublocality_level_1"]},
  %{"address_components" => [%{"long_name" => "New York",
        "short_name" => "New York", "types" => ["locality", "political"]},
      %{"long_name" => "New York", "short_name" => "NY",
        "types" => ["administrative_area_level_1", "political"]},
      %{"long_name" => "United States", "short_name" => "US",
        "types" => ["country", "political"]}],
    "formatted_address" => "New York, NY, USA",
    "geometry" => %{"bounds" => %{"northeast" => %{"lat" => 40.9175771,
          "lng" => -73.70027209999999},
        "southwest" => %{"lat" => 40.4773991, "lng" => -74.25908989999999}},
      "location" => %{"lat" => 40.7127837, "lng" => -74.0059413},
      "location_type" => "APPROXIMATE",
      "viewport" => %{"northeast" => %{"lat" => 40.9152555,
          "lng" => -73.70027209999999},
        "southwest" => %{"lat" => 40.4960439, "lng" => -74.2557349}}},
    "place_id" => "ChIJOwg_06VPwokRYv534QaPC8g",
    "types" => ["locality", "political"]},
  %{"address_components" => [%{"long_name" => "11211", "short_name" => "11211",
        "types" => ["postal_code"]},
      %{"long_name" => "Brooklyn", "short_name" => "Brooklyn",
        "types" => ["political", "sublocality", "sublocality_level_1"]},
      %{"long_name" => "New York", "short_name" => "New York",
        "types" => ["locality", "political"]},
      %{"long_name" => "New York", "short_name" => "NY",
        "types" => ["administrative_area_level_1", "political"]},
      %{"long_name" => "United States", "short_name" => "US",
        "types" => ["country", "political"]}],
    "formatted_address" => "Brooklyn, NY 11211, USA",
    "geometry" => %{"bounds" => %{"northeast" => %{"lat" => 40.7280089,
          "lng" => -73.9207299},
        "southwest" => %{"lat" => 40.7008331, "lng" => -73.9644697}},
      "location" => %{"lat" => 40.7093358, "lng" => -73.9565551},
      "location_type" => "APPROXIMATE",
      "viewport" => %{"northeast" => %{"lat" => 40.7280089,
          "lng" => -73.9207299},
        "southwest" => %{"lat" => 40.7008331, "lng" => -73.9644697}}},
    "place_id" => "ChIJvbEjlVdZwokR4KapM3WCFRw", "types" => ["postal_code"]},
  %{"address_components" => [%{"long_name" => "Kings County",
        "short_name" => "Kings County",
        "types" => ["administrative_area_level_2", "political"]},
      %{"long_name" => "New York", "short_name" => "NY",
        "types" => ["administrative_area_level_1", "political"]},
      %{"long_name" => "United States", "short_name" => "US",
        "types" => ["country", "political"]}],
    "formatted_address" => "Kings County, NY, USA",
    "geometry" => %{"bounds" => %{"northeast" => %{"lat" => 40.739446,
          "lng" => -73.8333651},
        "southwest" => %{"lat" => 40.551042, "lng" => -74.05663}},
      "location" => %{"lat" => 40.6528762, "lng" => -73.95949399999999},
      "location_type" => "APPROXIMATE",
      "viewport" => %{"northeast" => %{"lat" => 40.7391407,
          "lng" => -73.83363179999999},
        "southwest" => %{"lat" => 40.5703742, "lng" => -74.0419592}}},
    "place_id" => "ChIJOwE7_GTtwokRs75rhW4_I6M",
    "types" => ["administrative_area_level_2", "political"]},
  %{"address_components" => [%{"long_name" => "New York-Northern New Jersey-Long Island, NY-NJ-PA",
        "short_name" => "New York-Northern New Jersey-Long Island, NY-NJ-PA",
        "types" => ["political"]},
      %{"long_name" => "United States", "short_name" => "US",
        "types" => ["country", "political"]}],
    "formatted_address" => "New York-Northern New Jersey-Long Island, NY-NJ-PA, USA",
    "geometry" => %{"bounds" => %{"northeast" => %{"lat" => 41.6018065,
          "lng" => -71.856214},
        "southwest" => %{"lat" => 39.49853299999999, "lng" => -75.3585939}},
      "location" => %{"lat" => 40.9590293, "lng" => -74.0300122},
      "location_type" => "APPROXIMATE",
      "viewport" => %{"northeast" => %{"lat" => 41.6018065,
          "lng" => -71.856214},
        "southwest" => %{"lat" => 39.49853299999999, "lng" => -75.3585939}}},
    "place_id" => "ChIJ3YJV4PRWwokRFFI21ZrHXtQ", "types" => ["political"]},
  %{"address_components" => [%{"long_name" => "New York Metropolitan Area",
        "short_name" => "New York Metropolitan Area", "types" => ["political"]},
      %{"long_name" => "United States", "short_name" => "US",
        "types" => ["country", "political"]}],
    "formatted_address" => "New York Metropolitan Area, USA",
    "geometry" => %{"bounds" => %{"northeast" => %{"lat" => 42.0809059,
          "lng" => -71.777491},
        "southwest" => %{"lat" => 39.475198, "lng" => -75.3587649}},
      "location" => %{"lat" => 40.7127761, "lng" => -74.0059544},
      "location_type" => "APPROXIMATE",
      "viewport" => %{"northeast" => %{"lat" => 42.0809059,
          "lng" => -71.777491},
        "southwest" => %{"lat" => 39.475198, "lng" => -75.3587649}}},
    "place_id" => "ChIJ-5Z24NaGwokRiMh4Rj8FNMo", "types" => ["political"]},
  %{"address_components" => [%{"long_name" => "New York", "short_name" => "NY",
        "types" => ["administrative_area_level_1", "establishment",
        "point_of_interest", "political"]},
      %{"long_name" => "United States", "short_name" => "US",
        "types" => ["country", "political"]}],
    "formatted_address" => "New York, USA",
    "geometry" => %{"bounds" => %{"northeast" => %{"lat" => 45.015865,
          "lng" => -71.777491},
        "southwest" => %{"lat" => 40.4773991, "lng" => -79.7625901}},
      "location" => %{"lat" => 43.2994285, "lng" => -74.21793260000001},
      "location_type" => "APPROXIMATE",
      "viewport" => %{"northeast" => %{"lat" => 45.0125923,
          "lng" => -71.8562029},
        "southwest" => %{"lat" => 40.4961036, "lng" => -79.761996}}},
    "place_id" => "ChIJqaUj8fBLzEwRZ5UY3sHGz90",
    "types" => ["administrative_area_level_1", "establishment",
      "point_of_interest", "political"]}], "status" => "OK"}

Returns address components for the given place id, this functionality is only available if an API key or a client ID is provided

Example

iex> Geocodex.set_api_key("AIzaSyDo0s6h_njYpqsqMO8w6A12Nrpc5bMVyEs")
:ok
iex> Geocodex.place_id("ChIJrTLr-GyuEmsRBfy61i59si0")
%{"results" => [%{"address_components" => [%{"long_name" => "Sydney",
        "short_name" => "Sydney",
        "types" => ["locality", "political"]},
      %{"long_name" => "New South Wales", "short_name" => "NSW",
        "types" => ["administrative_area_level_1", "political"]},
      %{"long_name" => "Australia", "short_name" => "AU",
        "types" => ["country", "political"]},
      %{"long_name" => "2000", "short_name" => "2000",
        "types" => ["postal_code"]}],
    "formatted_address" => "32 The Promenade, King Street Wharf 5, Sydney NSW 2000, Australia",
    "geometry" => %{"location" => %{"lat" => -33.867591,
        "lng" => 151.201196}, "location_type" => "APPROXIMATE",
      "viewport" => %{"northeast" => %{"lat" => -33.86624201970849,
          "lng" => 151.2025449802915},
        "southwest" => %{"lat" => -33.86893998029149,
          "lng" => 151.1998470197085}}},
    "place_id" => "ChIJrTLr-GyuEmsRBfy61i59si0",
    "types" => ["establishment", "food", "point_of_interest",
      "restaurant", "travel_agency"]}], "status" => "OK"}

Sets an api key to enable Premium features

Example

iex> Geocodex.set_api_key("AIzaSyDo0s6h_njYpqsqMO8w6A12Nrpc5bMVyEs")
:ok