Module: GoogleMapsService::Apis::Geocoding
- Included in:
- Client
- Defined in:
- lib/google_maps_service/apis/geocoding.rb
Overview
Performs requests to the Google Maps Geocoding API.
Instance Method Summary collapse
-
#geocode(address, components: nil, bounds: nil, region: nil, language: nil) ⇒ Array
Geocoding is the process of converting addresses (like
"1600 Amphitheatre Parkway, Mountain View, CA"
) into geographic coordinates (like latitude 37.423021 and longitude -122.083739), which you can use to place markers or position the map. -
#reverse_geocode(latlng, location_type: nil, result_type: nil, language: nil) ⇒ Array
Reverse geocoding is the process of converting geographic coordinates into a human-readable address.
Instance Method Details
#geocode(address, components: nil, bounds: nil, region: nil, language: nil) ⇒ Array
Geocoding is the process of converting addresses
(like "1600 Amphitheatre Parkway, Mountain View, CA"
) into geographic
coordinates (like latitude 37.423021 and longitude -122.083739), which you
can use to place markers or position the map.
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/google_maps_service/apis/geocoding.rb', line 41 def geocode(address, components: nil, bounds: nil, region: nil, language: nil) params = {} params[:address] = address if address params[:components] = GoogleMapsService::Convert.components(components) if components params[:bounds] = GoogleMapsService::Convert.bounds(bounds) if bounds params[:region] = region if region params[:language] = language if language return get('/maps/api/geocode/json', params)[:results] end |
#reverse_geocode(latlng, location_type: nil, result_type: nil, language: nil) ⇒ Array
Reverse geocoding is the process of converting geographic coordinates into a human-readable address.
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/google_maps_service/apis/geocoding.rb', line 72 def reverse_geocode(latlng, location_type: nil, result_type: nil, language: nil) params = { latlng: GoogleMapsService::Convert.latlng(latlng) } params[:result_type] = GoogleMapsService::Convert.join_list('|', result_type) if result_type params[:location_type] = GoogleMapsService::Convert.join_list('|', location_type) if location_type params[:language] = language if language return get('/maps/api/geocode/json', params)[:results] end |