Module: GoogleMapsService::Apis::Places
- Included in:
- Client
- Defined in:
- lib/google_maps_service/apis/places.rb
Overview
Performs requests to the Google Maps Places API.
Instance Method Summary collapse
-
#place(place_id, language: nil) ⇒ Object
Comprehensive details for an individual place.
-
#places(query, location: nil, radius: nil, language: nil, min_price: nil, max_price: nil, open_now: false, type: nil, page_token: nil) ⇒ Hash
Places search.
-
#places_nearby(location: nil, radius: nil, keyword: nil, language: nil, min_price: nil, max_price: nil, name: nil, open_now: false, rank_by: nil, type: nil, page_token: nil) ⇒ Hash
Performs nearby search for places.
-
#places_photo(photo_reference, max_width: nil, max_height: nil) ⇒ Object
Photo URL from the Places API.
Instance Method Details
#place(place_id, language: nil) ⇒ Object
Comprehensive details for an individual place.
@param place_id A textual identifier that uniquely identifies a
place, returned from a Places search.
@param language The language in which to return results. @return Hash with the following keys:
result: dict containing place details
html_attributions: set of attributions which must be displayed
95 96 97 98 99 |
# File 'lib/google_maps_service/apis/places.rb', line 95 def place(place_id, language: nil) params = {placeid: place_id} params[:language] = language if language get("/maps/api/place/details/json", params) end |
#places(query, location: nil, radius: nil, language: nil, min_price: nil, max_price: nil, open_now: false, type: nil, page_token: nil) ⇒ Hash
Places search.
30 31 32 33 34 35 36 |
# File 'lib/google_maps_service/apis/places.rb', line 30 def places(query, location: nil, radius: nil, language: nil, min_price: nil, max_price: nil, open_now: false, type: nil, page_token: nil) _places("text", query: query, location: location, radius: radius, language: language, min_price: min_price, max_price: max_price, open_now: open_now, type: type, page_token: page_token) end |
#places_nearby(location: nil, radius: nil, keyword: nil, language: nil, min_price: nil, max_price: nil, name: nil, open_now: false, rank_by: nil, type: nil, page_token: nil) ⇒ Hash
Performs nearby search for places.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/google_maps_service/apis/places.rb', line 68 def places_nearby(location: nil, radius: nil, keyword: nil, language: nil, min_price: nil, max_price: nil, name: nil, open_now: false, rank_by: nil, type: nil, page_token: nil) if rank_by == "distance" if !(keyword || name || type) raise ArgumentError, "either a keyword, name, or type arg is " \ "required when rank_by is set to distance" elsif radius raise ArgumentError, "radius cannot be specified when rank_by " \ "is set to distance" end end _places("nearby", location: location, radius: radius, keyword: keyword, language: language, min_price: min_price, max_price: max_price, name: name, open_now: open_now, rank_by: rank_by, type: type, page_token: page_token) end |
#places_photo(photo_reference, max_width: nil, max_height: nil) ⇒ Object
Photo URL from the Places API.
@param photo_reference A string identifier that uniquely
identifies a photo, as provided by either a Places search or Places
detail request.
@param max_width Specifies the maximum desired width, in pixels. @param max_height Specifies the maximum desired height, in pixels. @return String URL of the photo or nil upon error.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/google_maps_service/apis/places.rb', line 109 def places_photo(photo_reference, max_width: nil, max_height: nil) unless max_width || max_height raise ArgumentError, "a max_width or max_height arg is required" end params = {photoreference: photo_reference} params[:maxwidth] = max_width if max_width params[:maxheight] = max_height if max_height image_response_decoder = ->(response) { response["location"] } get("/maps/api/place/photo", params, custom_response_decoder: image_response_decoder) end |