Class: MapQuest::Services::Geocoding
- Defined in:
- lib/mapquest/services/geocoding.rb
Overview
The main class used for communicating with the MapQuest Geocoding API
Defined Under Namespace
Classes: Response, TooManyLocations
Constant Summary collapse
- API_LOCATION =
:geocoding
- VALID_OPTIONS =
[:location,:maxResults,:thumbMaps]
Instance Attribute Summary
Attributes inherited from Core
Instance Method Summary collapse
-
#address(location, options = {}) ⇒ Object
Allows you to search for a single location and returns a response object of the found locations.
-
#reverse(location, options = {}) ⇒ Object
Allows you to search for a location using lat/lng values and returns a response object of the found locations.
Methods inherited from Core
Constructor Details
This class inherits a constructor from MapQuest::Services::Core
Instance Method Details
#address(location, options = {}) ⇒ Object
Allows you to search for a single location and returns a response object of the found locations
Example: .address :location => "London, UK"
Required parameters
-
location [String] The location for which you wish to get data
Optional parameters
-
:maxResults [Integer] The number of results to limit the response to. Defaults to -1 (-1 indicates no limit)
-
:thumbMaps [Boolean] Return a URL to a static map thumbnail image for a location. Defaults to true
20 21 22 23 24 |
# File 'lib/mapquest/services/geocoding.rb', line 20 def address(location, = {}) raise ArgumentError, 'Method must receive a location (string)' unless location [:location] = location call_api self, 1, 'address', end |
#reverse(location, options = {}) ⇒ Object
Allows you to search for a location using lat/lng values and returns a response object of the found locations
Example: .reverse :location => ['40.0755','-76.329999']
Required parameters
-
location [Array] The lat, and lng to search for
Optional parameters
-
:maxResults [Integer] The number of results to limit the response to. Defaults to -1 (-1 indicates no limit)
-
:thumbMaps [Boolean] Return a URL to a static map thumbnail image for a location. Defaults to true
35 36 37 38 39 |
# File 'lib/mapquest/services/geocoding.rb', line 35 def reverse(location, = {}) raise ArgumentError, 'Method must receive a location (array)' unless location && location.kind_of?(Array) [:location] = location.join(',') call_api self, 1, 'reverse', end |