Class: GoogleMapsPlatform::PlacesApiController
- Inherits:
-
BaseController
- Object
- BaseController
- GoogleMapsPlatform::PlacesApiController
- Defined in:
- lib/google_maps_platform/controllers/places_api_controller.rb
Overview
PlacesApiController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#autocomplete(input, radius, sessiontoken: nil, components: nil, strictbounds: nil, offset: nil, origin: nil, location: nil, locationbias: nil, locationrestriction: nil, types: nil, language: Language::EN, region: Region::EN) ⇒ ApiResponse
The Place Autocomplete service is a web service that returns place predictions in response to an HTTP request.
-
#find_place_from_text(input, inputtype, fields: nil, locationbias: nil, language: Language::EN) ⇒ ApiResponse
A Find Place request takes a text input and returns a place.
-
#nearby_search(location, radius, keyword: nil, maxprice: nil, minprice: nil, name: nil, opennow: nil, pagetoken: nil, rankby: nil, type: nil, language: Language::EN) ⇒ ApiResponse
A Nearby Search lets you search for places within a specified area.
-
#place_details(place_id, fields: nil, sessiontoken: nil, language: Language::EN, region: Region::EN, reviews_sort: nil, reviews_no_translations: nil) ⇒ ApiResponse
The Places API is a service that returns information about places using HTTP requests.
-
#place_photo(photo_reference, maxheight: nil, maxwidth: nil) ⇒ ApiResponse
The Place Photo service, part of the Places API, is a read- only API that allows you to add high quality photographic content to your application.
-
#query_autocomplete(input, radius, offset: nil, location: nil, language: Language::EN) ⇒ ApiResponse
The Query Autocomplete service can be used to provide a query prediction for text-based geographic searches, by returning suggested queries as you type.
-
#text_search(query, radius, location: nil, maxprice: nil, minprice: nil, opennow: nil, pagetoken: nil, type: nil, language: Language::EN, region: Region::EN) ⇒ ApiResponse
The Google Places API Text Search Service is a web service that returns information about a set of places based on a string — for example “pizza in New York” or “shoe stores near Ottawa” or “123 Main Street”.
Methods inherited from BaseController
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from GoogleMapsPlatform::BaseController
Instance Method Details
#autocomplete(input, radius, sessiontoken: nil, components: nil, strictbounds: nil, offset: nil, origin: nil, location: nil, locationbias: nil, locationrestriction: nil, types: nil, language: Language::EN, region: Region::EN) ⇒ ApiResponse
The Place Autocomplete service is a web service that returns place predictions in response to an HTTP request. The request specifies a textual search string and optional geographic bounds. The service can be used to provide autocomplete functionality for text-based geographic searches, by returning places such as businesses, addresses and points of interest as a user types. <div class=“note”>Note: You can use Place Autocomplete even without a map. If you do show a map, it must be a Google map. When you display predictions from the Place Autocomplete service without a map, you must include the [‘Powered by Google’](developers.google.com/maps/documentation/places/web-servi ce/policies#logo_requirementsdevelopers.google.com/maps/documentat ion/places/web-service/policies#logo_requirements) logo.</div> The Place Autocomplete service can match on full words and substrings, resolving place names, addresses, and plus codes. Applications can therefore send queries as the user types, to provide on-the-fly place predictions. The returned predictions are designed to be presented to the user to aid them in selecting the desired place. You can send a [Place Details](developers.google.com/maps/documentation/places/web-servi ce/details#PlaceDetailsRequests) request for more information about any of the places which are returned. search. The Place Autocomplete service will return candidate matches based on this string and order results based on their perceived relevance. within which to return place results. You may bias results to a specified circle by passing a location and a radius parameter. Doing so instructs the Places service to prefer showing results within that circle; results outside of the defined area may still be displayed. The radius will automatically be clamped to a maximum value depending on the type of search and other parameters. * Autocomplete: 50,000 meters * Nearby Search: * with keyword or name: 50,000 meters * without keyword or name * Up to 50,000 meters, adjusted dynamically based on area density, independent of rankby parameter. * When using ‘rankby=distance`, the radius parameter will not be accepted, and will result in an INVALID_REQUEST. * Query Autocomplete: 50,000 meters * Text Search: 50,000 meters identifies an autocomplete [session](developers.google.com/maps/documentation/places/web-serv ice/details#session_tokens) for billing purposes. The session begins when the user starts typing a query, and concludes when they select a place and a call to Place Details is made. Each session can have multiple queries, followed by one place selection. The API key(s) used for each request within a session must belong to the same Google Cloud Console project. Once a session has concluded, the token is no longer valid; your app must generate a fresh token for each session. If the sessiontoken parameter is omitted, or if you reuse a session token, the session is charged as if no session token was provided (each request is billed separately). We recommend the following guidelines: - Use session tokens for all autocomplete sessions. - Generate a fresh token for each session. Using a version 4 UUID is recommended. - Ensure that the API key(s) used for all Place Autocomplete and Place Details requests within a session belong to the same Cloud Console project. - Be sure to pass a unique session token for each new session. Using the same token for more than one session will result in each request being billed individually. which you would like to restrict your results. Currently, you can use components to filter by up to 5 countries. Countries must be passed as a two character, ISO 3166-1 Alpha-2 compatible country code. For example: `components=country:fr` would restrict your results to places within France. Multiple countries must be passed as multiple country:XX filters, with the pipe character `|` as a separator. For example: `components=country:us|country:pr|country:vi|country:gu|country:mp` would restrict your results to places within the United States and its unincorporated organized territories. <div class=“note”><strong>Note:</strong> If you receive unexpected results with a country code, verify that you are using a code which includes the countries, dependent territories, and special areas of geographical interest you intend. You can find code information at <a href=“en.wikipedia.org/wiki/List_of_ISO_3166_country_codes” target=“blank” class=“external”>Wikipedia: List of ISO 3166 country codes</a> or the <a href=“www.iso.org/obp/ui/#search” target=“blank” class=“external”>ISO Online Browsing Platform</a>.</div> only those places that are strictly within the region defined by location and radius. This is a restriction, rather than a bias, meaning that results outside this region will not be returned even if they match the user input. of the last character that the service uses to match predictions. For example, if the input is Google and the offset is 3, the service will match on Goo. The string determined by the offset is matched against the first word in the input term only. For example, if the input term is `Google abc` and the offset is 3, the service will attempt to match against `Goo abc`. If no offset is supplied, the service will use the whole term. The offset should generally be set to the position of the text caret. calculate straight-line distance to the destination (returned as distance_meters). If this value is omitted, straight-line distance will not be returned. Must be specified as `latitude,longitude`. retrieve place information. This must be specified as `latitude,longitude`. The radius parameter must also be provided when specifying a location. If radius is not provided, the location parameter is ignored. <div class=“note”>When using the Text Search API, the location parameter may be overriden if the query contains an explicit location such as `Market in Barcelona`.</div> specified area, by specifying either a radius plus lat/lng, or two lat/lng pairs representing the points of a rectangle. If this parameter is not specified, the API uses IP address biasing by default. - IP bias: Instructs the API to use IP address biasing. Pass the string ipbias (this option has no additional parameters). - Circular: A string specifying radius in meters, plus lat/lng in decimal degrees. Use the following format: `circle:radius@lat,lng`. - Rectangular: A string specifying two lat/lng pairs in decimal degrees, representing the south/west and north/east points of a rectangle. Use the following format:`rectangle:south,west|north,east`. Note that east/west values are wrapped to the range -180, 180, and north/south values are clamped to the range -90, 90. to a specified area, by specifying either a radius plus lat/lng, or two lat/lng pairs representing the points of a rectangle. - Circular: A string specifying radius in meters, plus lat/lng in decimal degrees. Use the following format: `circle:radius@lat,lng`. - Rectangular: A string specifying two lat/lng pairs in decimal degrees, representing the south/west and north/east points of a rectangle. Use the following format:`rectangle:south,west|north,east`. Note that east/west values are wrapped to the range -180, 180, and north/south values are clamped to the range -90, 90. Place Autocomplete request to be of a certain type by passing the types parameter. This parameter specifies a type or a type collection, as listed in [Place Types](/maps/documentation/places/web-service/supported_types). If nothing is specified, all types are returned. For the value of the types parameter you can specify either: * Up to five values from [Table 1](/maps/documentation/places/web-service/supported_types#table1) or [Table 2](/maps/documentation/places/web-service/supported_types#table2). For multiple values, separate each value with a `|` (vertical bar). For example: `types=book_store|cafe` * Any supported filter in [Table 3](/maps/documentation/places/web-service/supported_types#table3). You can safely mix the geocode and establishment types. You cannot mix type collections (address, `(cities)` or `(regions)`) with any other type, or an error occurs. The request will be rejected with an INVALID_REQUEST error if: * More than five types are specified. * Any unrecognized types are present. * Any types from in [Table 1](/maps/documentation/places/web-service/supported_types#table1) or [Table 2](/maps/documentation/places/web-service/supported_types#table2) are mixed with any of the filters in [Table 3](/maps/documentation/places/web-service/supported_types#table3). return results. * See the [list of supported languages](developers.google.com/maps/faq#languagesupport). Google often updates the supported languages, so this list may not be exhaustive.
-
If
languageis not supplied, the API attempts to use the preferred
language as specified in the Accept-Language header. * The API does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses are returned in the preferred language. Address components are all returned in the same language, which is chosen from the first component. * If a name is not available in the preferred language, the API uses the closest match. * The preferred language has a small influence on the set of results that the API chooses to return, and the order in which they are returned. The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another. For example, utca and _tér_ are synonyms for street in Hungarian. [ccTLD (“top-level domain”)](en.wikipedia.org/wiki/List_of_Internet_top-level_domains #Country_code_top-level_domains) two-character value. Most ccTLD codes are identical to ISO 3166-1 codes, with some notable exceptions. For example, the United Kingdom’s ccTLD is “uk” (.co.uk) while its ISO 3166-1 code is “gb” (technically for the entity of “The United Kingdom of Great Britain and Northern Ireland”).
825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 |
# File 'lib/google_maps_platform/controllers/places_api_controller.rb', line 825 def autocomplete(input, radius, sessiontoken: nil, components: nil, strictbounds: nil, offset: nil, origin: nil, location: nil, locationbias: nil, locationrestriction: nil, types: nil, language: Language::EN, region: Region::EN) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/maps/api/place/autocomplete/json', Server::DEFAULT) .query_param(new_parameter(input, key: 'input') .is_required(true)) .query_param(new_parameter(radius, key: 'radius') .is_required(true)) .query_param(new_parameter(sessiontoken, key: 'sessiontoken')) .query_param(new_parameter(components, key: 'components')) .query_param(new_parameter(strictbounds, key: 'strictbounds')) .query_param(new_parameter(offset, key: 'offset')) .query_param(new_parameter(origin, key: 'origin')) .query_param(new_parameter(location, key: 'location')) .query_param(new_parameter(locationbias, key: 'locationbias')) .query_param(new_parameter(locationrestriction, key: 'locationrestriction')) .query_param(new_parameter(types, key: 'types')) .query_param(new_parameter(language, key: 'language')) .query_param(new_parameter(region, key: 'region')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('ApiKeyAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(PlacesAutocompleteResponse.method(:from_hash)) .is_api_response(true)) .execute end |
#find_place_from_text(input, inputtype, fields: nil, locationbias: nil, language: Language::EN) ⇒ ApiResponse
A Find Place request takes a text input and returns a place. The input can be any kind of Places text data, such as a name, address, or phone number. The request must be a string. A Find Place request using non-string data such as a lat/lng coordinate or plus code generates an error. <div class=“note”>Note: If you omit the fields parameter from a Find Place request, only the place_id for the result will be returned.</div> search, for example: “restaurant” or “123 Main Street”. This must be a place name, address, or category of establishments. Any other types of input can generate errors and are not guaranteed to return valid results. The Places API will return candidate matches based on this string and order the results based on their perceived relevance. can be one of either textquery or phonenumber. Phone numbers must be in international format (prefixed by a plus sign (“+”), followed by the country code, then the phone number itself). See [E.164 ITU recommendation](en.wikipedia.org/wiki/E.164) for more information. Caution: Place Search requests and Place Details requests do not return the same fields. Place Search requests return a subset of the fields that are returned by Place Details requests. If the field you want is not returned by Place Search, you can use Place Search to get a place_id, then use that Place ID to make a Place Details request. For more information on the fields that are unavailable in a Place Search request, see <a href=“developers.google.com/maps/documentation/places/web-service/ place-data-fields#places-api-fields-support”>Places API fields support</a>.</div> Use the fields parameter to specify a comma-separated list of place data types to return. For example: ‘fields=formatted_address,name,geometry`. Use a forward slash when specifying compound values. For example: opening_hours/open_now. Fields are divided into three billing categories: Basic, Contact, and Atmosphere. Basic fields are billed at base rate, and incur no additional charges. Contact and Atmosphere fields are billed at a higher rate. See the [pricing sheet](developers.google.com/maps/documentation/places/web-service /usage-and-billing/) for more information. Attributions, html_attributions, are always returned with every call, regardless of whether the field has been requested. Basic The Basic category includes the following fields: address_components, adr_address, business_status, formatted_address, geometry, icon, icon_mask_base_uri, icon_background_color, name, permanently_closed ([deprecated](developers.google.com/maps/deprecations)), photo, place_id, plus_code, type, url, utc_offset, vicinity, wheelchair_accessible_entrance. Contact The Contact category includes the following fields: current_opening_hours, formatted_phone_number, international_phone_number, opening_hours, secondary_opening_hours, website Atmosphere The Atmosphere category includes the following fields: curbside_pickup, delivery, dine_in, editorial_summary, price_level, rating, reservable, reviews, serves_beer, serves_breakfast, serves_brunch, serves_dinner, serves_lunch, serves_vegetarian_food, serves_wine, takeout, user_ratings_total. specified area, by specifying either a radius plus lat/lng, or two lat/lng pairs representing the points of a rectangle. If this parameter is not specified, the API uses IP address biasing by default. - IP bias: Instructs the API to use IP address biasing. Pass the string ipbias (this option has no additional parameters). - Circular: A string specifying radius in meters, plus lat/lng in decimal degrees. Use the following format: `circle:radius@lat,lng`. - Rectangular: A string specifying two lat/lng pairs in decimal degrees, representing the south/west and north/east points of a rectangle. Use the following format:`rectangle:south,west|north,east`. Note that east/west values are wrapped to the range -180, 180, and north/south values are clamped to the range -90, 90. return results. * See the [list of supported languages](developers.google.com/maps/faq#languagesupport). Google often updates the supported languages, so this list may not be exhaustive.
-
If
languageis not supplied, the API attempts to use the preferred
language as specified in the Accept-Language header. * The API does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses are returned in the preferred language. Address components are all returned in the same language, which is chosen from the first component. * If a name is not available in the preferred language, the API uses the closest match. * The preferred language has a small influence on the set of results that the API chooses to return, and the order in which they are returned. The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another. For example, utca and _tér_ are synonyms for street in Hungarian.
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/google_maps_platform/controllers/places_api_controller.rb', line 235 def find_place_from_text(input, inputtype, fields: nil, locationbias: nil, language: Language::EN) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/maps/api/place/findplacefromtext/json', Server::DEFAULT) .query_param(new_parameter(input, key: 'input') .is_required(true)) .query_param(new_parameter(inputtype, key: 'inputtype') .is_required(true)) .query_param(new_parameter(fields, key: 'fields')) .query_param(new_parameter(locationbias, key: 'locationbias')) .query_param(new_parameter(language, key: 'language')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('ApiKeyAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(PlacesFindPlaceFromTextResponse.method(:from_hash)) .is_api_response(true)) .execute end |
#nearby_search(location, radius, keyword: nil, maxprice: nil, minprice: nil, name: nil, opennow: nil, pagetoken: nil, rankby: nil, type: nil, language: Language::EN) ⇒ ApiResponse
A Nearby Search lets you search for places within a specified area. You can refine your search request by supplying keywords or specifying the type of place you are searching for. retrieve place information. This must be specified as ‘latitude,longitude`. within which to return place results. You may bias results to a specified circle by passing a location and a radius parameter. Doing so instructs the Places service to prefer showing results within that circle; results outside of the defined area may still be displayed. The radius will automatically be clamped to a maximum value depending on the type of search and other parameters. * Autocomplete: 50,000 meters * Nearby Search: * with keyword or name: 50,000 meters * without keyword or name * Up to 50,000 meters, adjusted dynamically based on area density, independent of rankby parameter. * When using `rankby=distance`, the radius parameter will not be accepted, and will result in an INVALID_REQUEST. * Query Autocomplete: 50,000 meters * Text Search: 50,000 meters search, for example: “restaurant” or “123 Main Street”. This must be a place name, address, or category of establishments. Any other types of input can generate errors and are not guaranteed to return valid results. The Google Places service will return candidate matches based on this string and order the results based on their perceived relevance. Explicitly including location information using this parameter may conflict with the location, radius, and rankby parameters, causing unexpected results. If this parameter is omitted, places with a business_status of CLOSED_TEMPORARILY or CLOSED_PERMANENTLY will not be returned. those places within the specified range. Valid values range between 0 (most affordable) to 4 (most expensive), inclusive. The exact amount indicated by a specific value will vary from region to region. those places within the specified range. Valid values range between 0 (most affordable) to 4 (most expensive), inclusive. The exact amount indicated by a specific value will vary from region to region. in this field are combined with values in the keyword field and passed as part of the same search string. those places that are open for business at the time the query is sent. Places that do not specify opening hours in the Google Places database will not be returned if you include this parameter in your query. from a previously run search. Setting a pagetoken parameter will execute a search with the same parameters used previously — all parameters other than pagetoken will be ignored. results are listed. Possible values are: - prominence (default). This option sorts results based on their importance. Ranking will favor prominent places within the set radius over nearby places that match but that are less prominent. Prominence can be affected by a place’s ranking in Google’s index, global popularity, and other factors. When prominence is specified, the radius parameter is required. - distance. This option biases search results in ascending order by their distance from the specified location. When distance is specified, one or more of keyword, name, or type is required and radius is disallowed. matching the specified type. Only one type may be specified. If more than one type is provided, all types following the first entry are ignored. * ‘type=hospital|pharmacy|doctor` becomes `type=hospital` * `type=hospital,pharmacy,doctor` is ignored entirely See the list of [supported types](developers.google.com/maps/documentation/places/web-service /supported_types). <div class=“note”>Note: Adding both keyword and type with the same value (`keyword=cafe&type=cafe` or `keyword=parking&type=parking`) can yield ZERO_RESULTS.</div> return results. * See the [list of supported languages](developers.google.com/maps/faq#languagesupport). Google often updates the supported languages, so this list may not be exhaustive.
-
If
languageis not supplied, the API attempts to use the preferred
language as specified in the Accept-Language header. * The API does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses are returned in the preferred language. Address components are all returned in the same language, which is chosen from the first component. * If a name is not available in the preferred language, the API uses the closest match. * The preferred language has a small influence on the set of results that the API chooses to return, and the order in which they are returned. The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another. For example, utca and _tér_ are synonyms for street in Hungarian.
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
# File 'lib/google_maps_platform/controllers/places_api_controller.rb', line 349 def nearby_search(location, radius, keyword: nil, maxprice: nil, minprice: nil, name: nil, opennow: nil, pagetoken: nil, rankby: nil, type: nil, language: Language::EN) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/maps/api/place/nearbysearch/json', Server::DEFAULT) .query_param(new_parameter(location, key: 'location') .is_required(true)) .query_param(new_parameter(radius, key: 'radius') .is_required(true)) .query_param(new_parameter(keyword, key: 'keyword')) .query_param(new_parameter(maxprice, key: 'maxprice')) .query_param(new_parameter(minprice, key: 'minprice')) .query_param(new_parameter(name, key: 'name')) .query_param(new_parameter(opennow, key: 'opennow')) .query_param(new_parameter(pagetoken, key: 'pagetoken')) .query_param(new_parameter(rankby, key: 'rankby')) .query_param(new_parameter(type, key: 'type')) .query_param(new_parameter(language, key: 'language')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('ApiKeyAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(PlacesNearbySearchResponse.method(:from_hash)) .is_api_response(true)) .execute end |
#place_details(place_id, fields: nil, sessiontoken: nil, language: Language::EN, region: Region::EN, reviews_sort: nil, reviews_no_translations: nil) ⇒ ApiResponse
The Places API is a service that returns information about places using HTTP requests. Places are defined within this API as establishments, geographic locations, or prominent points of interest. uniquely identifies a place, returned from a [Place Search](developers.google.com/maps/documentation/places/web-servic e/search). For more information about place IDs, see the [place ID overview](developers.google.com/maps/documentation/places/web-serv ice/place-id). Caution: Place Search requests and Place Details requests do not return the same fields. Place Search requests return a subset of the fields that are returned by Place Details requests. If the field you want is not returned by Place Search, you can use Place Search to get a place_id, then use that Place ID to make a Place Details request. For more information on the fields that are unavailable in a Place Search request, see <a href=“developers.google.com/maps/documentation/places/web-service/ place-data-fields#places-api-fields-support”>Places API fields support</a>.</div> Use the fields parameter to specify a comma-separated list of place data types to return. For example: ‘fields=formatted_address,name,geometry`. Use a forward slash when specifying compound values. For example: opening_hours/open_now. Fields are divided into three billing categories: Basic, Contact, and Atmosphere. Basic fields are billed at base rate, and incur no additional charges. Contact and Atmosphere fields are billed at a higher rate. See the [pricing sheet](developers.google.com/maps/documentation/places/web-service /usage-and-billing/) for more information. Attributions, html_attributions, are always returned with every call, regardless of whether the field has been requested. Basic The Basic category includes the following fields: address_components, adr_address, business_status, formatted_address, geometry, icon, icon_mask_base_uri, icon_background_color, name, permanently_closed ([deprecated](developers.google.com/maps/deprecations)), photo, place_id, plus_code, type, url, utc_offset, vicinity, wheelchair_accessible_entrance. Contact The Contact category includes the following fields: current_opening_hours, formatted_phone_number, international_phone_number, opening_hours, secondary_opening_hours, website Atmosphere The Atmosphere category includes the following fields: curbside_pickup, delivery, dine_in, editorial_summary, price_level, rating, reservable, reviews, serves_beer, serves_breakfast, serves_brunch, serves_dinner, serves_lunch, serves_vegetarian_food, serves_wine, takeout, user_ratings_total. identifies an autocomplete [session](developers.google.com/maps/documentation/places/web-serv ice/details#session_tokens) for billing purposes. The session begins when the user starts typing a query, and concludes when they select a place and a call to Place Details is made. Each session can have multiple queries, followed by one place selection. The API key(s) used for each request within a session must belong to the same Google Cloud Console project. Once a session has concluded, the token is no longer valid; your app must generate a fresh token for each session. If the sessiontoken parameter is omitted, or if you reuse a session token, the session is charged as if no session token was provided (each request is billed separately). We recommend the following guidelines: - Use session tokens for all autocomplete sessions. - Generate a fresh token for each session. Using a version 4 UUID is recommended. - Ensure that the API key(s) used for all Place Autocomplete and Place Details requests within a session belong to the same Cloud Console project. - Be sure to pass a unique session token for each new session. Using the same token for more than one session will result in each request being billed individually. return results. * See the [list of supported languages](developers.google.com/maps/faq#languagesupport). Google often updates the supported languages, so this list may not be exhaustive.
-
If
languageis not supplied, the API attempts to use the preferred
language as specified in the Accept-Language header. * The API does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses are returned in the preferred language. Address components are all returned in the same language, which is chosen from the first component. * If a name is not available in the preferred language, the API uses the closest match. * The preferred language has a small influence on the set of results that the API chooses to return, and the order in which they are returned. The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another. For example, utca and _tér_ are synonyms for street in Hungarian. [ccTLD (“top-level domain”)](en.wikipedia.org/wiki/List_of_Internet_top-level_domains #Country_code_top-level_domains) two-character value. Most ccTLD codes are identical to ISO 3166-1 codes, with some notable exceptions. For example, the United Kingdom’s ccTLD is “uk” (.co.uk) while its ISO 3166-1 code is “gb” (technically for the entity of “The United Kingdom of Great Britain and Northern Ireland”). when returning reviews. Can be set to most_relevant (default) or newest. - For most_relevant (default), reviews are sorted by relevance; the service will bias the results to return reviews originally written in the preferred language. - For newest, reviews are sorted in chronological order; the preferred language does not affect the sort order. Google recommends that you display how the reviews are being sorted to the end user. parameter: Specify ‘reviews_no_translations=true` to disable translation of reviews; specify `reviews_no_translations=false` to enable translation of reviews. Reviews are returned in their original language. If omitted, or passed with no value, translation of reviews is enabled. If the language parameter was specified in the request, use the specified language as the preferred language for translation. If language is omitted, the API attempts to use the Accept-Language header as the preferred language.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/google_maps_platform/controllers/places_api_controller.rb', line 119 def place_details(place_id, fields: nil, sessiontoken: nil, language: Language::EN, region: Region::EN, reviews_sort: nil, reviews_no_translations: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/maps/api/place/details/json', Server::DEFAULT) .query_param(new_parameter(place_id, key: 'place_id') .is_required(true)) .query_param(new_parameter(fields, key: 'fields')) .query_param(new_parameter(sessiontoken, key: 'sessiontoken')) .query_param(new_parameter(language, key: 'language')) .query_param(new_parameter(region, key: 'region')) .query_param(new_parameter(reviews_sort, key: 'reviews_sort')) .query_param(new_parameter(reviews_no_translations, key: 'reviews_no_translations')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('ApiKeyAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(PlacesDetailsResponse.method(:from_hash)) .is_api_response(true)) .execute end |
#place_photo(photo_reference, maxheight: nil, maxwidth: nil) ⇒ ApiResponse
The Place Photo service, part of the Places API, is a read- only API that allows you to add high quality photographic content to your application. The Place Photo service gives you access to the millions of photos stored in the Places database. When you get place information using a Place Details request, photo references will be returned for relevant photographic content. Find Place, Nearby Search, and Text Search requests also return a single photo reference per place, when relevant. Using the Photo service you can then access the referenced photos and resize the image to the optimal size for your application. Photos returned by the Photo service are sourced from a variety of locations, including business owners and user contributed photos. In most cases, these photos can be used without attribution, or will have the required attribution included as a part of the image. However, if the returned photo element includes a value in the html_attributions field, you will have to include the additional attribution in your application wherever you display the image. that uniquely identifies a photo. Photo references are returned from either a Place Search or Place Details request. height, in pixels, of the image. If the image is smaller than the values specified, the original image will be returned. If the image is larger in either dimension, it will be scaled to match the smaller of the two dimensions, restricted to its original aspect ratio. Both the maxheight and maxwidth properties accept an integer between 1 and 1600. width, in pixels, of the image. If the image is smaller than the values specified, the original image will be returned. If the image is larger in either dimension, it will be scaled to match the smaller of the two dimensions, restricted to its original aspect ratio. Both the maxheight and maxwidth properties accept an integer between 1 and 1600.
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 |
# File 'lib/google_maps_platform/controllers/places_api_controller.rb', line 548 def place_photo(photo_reference, maxheight: nil, maxwidth: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/maps/api/place/photo', Server::DEFAULT) .query_param(new_parameter(photo_reference, key: 'photo_reference') .is_required(true)) .query_param(new_parameter(maxheight, key: 'maxheight')) .query_param(new_parameter(maxwidth, key: 'maxwidth')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('ApiKeyAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:dynamic_deserializer)) .is_api_response(true)) .execute end |
#query_autocomplete(input, radius, offset: nil, location: nil, language: Language::EN) ⇒ ApiResponse
The Query Autocomplete service can be used to provide a query prediction for text-based geographic searches, by returning suggested queries as you type. The Query Autocomplete service allows you to add on-the-fly geographic query predictions to your application. Instead of searching for a specific location, a user can type in a categorical search, such as “pizza near New York” and the service responds with a list of suggested queries matching the string. As the Query Autocomplete service can match on both full words and substrings, applications can send queries as the user types to provide on-the-fly predictions. search. The Place Autocomplete service will return candidate matches based on this string and order results based on their perceived relevance. within which to return place results. You may bias results to a specified circle by passing a location and a radius parameter. Doing so instructs the Places service to prefer showing results within that circle; results outside of the defined area may still be displayed. The radius will automatically be clamped to a maximum value depending on the type of search and other parameters. * Autocomplete: 50,000 meters * Nearby Search: * with keyword or name: 50,000 meters * without keyword or name * Up to 50,000 meters, adjusted dynamically based on area density, independent of rankby parameter. * When using ‘rankby=distance`, the radius parameter will not be accepted, and will result in an INVALID_REQUEST. * Query Autocomplete: 50,000 meters * Text Search: 50,000 meters of the last character that the service uses to match predictions. For example, if the input is Google and the offset is 3, the service will match on Goo. The string determined by the offset is matched against the first word in the input term only. For example, if the input term is `Google abc` and the offset is 3, the service will attempt to match against `Goo abc`. If no offset is supplied, the service will use the whole term. The offset should generally be set to the position of the text caret. retrieve place information. This must be specified as `latitude,longitude`. <div class=“note”>The location parameter may be overriden if the query contains an explicit location such as Market in Barcelona. Using quotes around the query may also influence the weight given to the location and radius.</div> return results. * See the [list of supported languages](developers.google.com/maps/faq#languagesupport). Google often updates the supported languages, so this list may not be exhaustive.
-
If
languageis not supplied, the API attempts to use the preferred
language as specified in the Accept-Language header. * The API does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses are returned in the preferred language. Address components are all returned in the same language, which is chosen from the first component. * If a name is not available in the preferred language, the API uses the closest match. * The preferred language has a small influence on the set of results that the API chooses to return, and the order in which they are returned. The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another. For example, utca and _tér_ are synonyms for street in Hungarian.
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 |
# File 'lib/google_maps_platform/controllers/places_api_controller.rb', line 629 def query_autocomplete(input, radius, offset: nil, location: nil, language: Language::EN) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/maps/api/place/queryautocomplete/json', Server::DEFAULT) .query_param(new_parameter(input, key: 'input') .is_required(true)) .query_param(new_parameter(radius, key: 'radius') .is_required(true)) .query_param(new_parameter(offset, key: 'offset')) .query_param(new_parameter(location, key: 'location')) .query_param(new_parameter(language, key: 'language')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('ApiKeyAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(PlacesQueryAutocompleteResponse.method(:from_hash)) .is_api_response(true)) .execute end |
#text_search(query, radius, location: nil, maxprice: nil, minprice: nil, opennow: nil, pagetoken: nil, type: nil, language: Language::EN, region: Region::EN) ⇒ ApiResponse
The Google Places API Text Search Service is a web service that returns information about a set of places based on a string — for example “pizza in New York” or “shoe stores near Ottawa” or “123 Main Street”. The service responds with a list of places matching the text string and any location bias that has been set. The service is especially useful for making [ambiguous address](developers.google.com/maps/documentation/geocoding/best-p ractices) queries in an automated system, and non-address components of the string may match businesses as well as addresses. Examples of ambiguous address queries are incomplete addresses, poorly formatted addresses, or a request that includes non-address components such as business names. The search response will include a list of places. You can send a Place Details request for more information about any of the places in the response. search, for example: “restaurant” or “123 Main Street”. This must a place name, address, or category of establishments. Any other types of input can generate errors and are not guaranteed to return valid results. The Google Places service will return candidate matches based on this string and order the results based on their perceived relevance. within which to return place results. You may bias results to a specified circle by passing a location and a radius parameter. Doing so instructs the Places service to prefer showing results within that circle; results outside of the defined area may still be displayed. The radius will automatically be clamped to a maximum value depending on the type of search and other parameters. * Autocomplete: 50,000 meters * Nearby Search: * with keyword or name: 50,000 meters * without keyword or name * Up to 50,000 meters, adjusted dynamically based on area density, independent of rankby parameter. * When using ‘rankby=distance`, the radius parameter will not be accepted, and will result in an INVALID_REQUEST. * Query Autocomplete: 50,000 meters * Text Search: 50,000 meters retrieve place information. This must be specified as `latitude,longitude`. <div class=“note”>The location parameter may be overriden if the query contains an explicit location such as Market in Barcelona. Using quotes around the query may also influence the weight given to the location and radius.</div> those places within the specified range. Valid values range between 0 (most affordable) to 4 (most expensive), inclusive. The exact amount indicated by a specific value will vary from region to region. those places within the specified range. Valid values range between 0 (most affordable) to 4 (most expensive), inclusive. The exact amount indicated by a specific value will vary from region to region. those places that are open for business at the time the query is sent. Places that do not specify opening hours in the Google Places database will not be returned if you include this parameter in your query. from a previously run search. Setting a pagetoken parameter will execute a search with the same parameters used previously — all parameters other than pagetoken will be ignored. matching the specified type. Only one type may be specified. If more than one type is provided, all types following the first entry are ignored. * `type=hospital|pharmacy|doctor` becomes `type=hospital` * `type=hospital,pharmacy,doctor` is ignored entirely See the list of [supported types](developers.google.com/maps/documentation/places/web-service /supported_types). <div class=“note”>Note: Adding both keyword and type with the same value (`keyword=cafe&type=cafe` or `keyword=parking&type=parking`) can yield ZERO_RESULTS.</div> return results. * See the [list of supported languages](developers.google.com/maps/faq#languagesupport). Google often updates the supported languages, so this list may not be exhaustive.
-
If
languageis not supplied, the API attempts to use the preferred
language as specified in the Accept-Language header. * The API does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses are returned in the preferred language. Address components are all returned in the same language, which is chosen from the first component. * If a name is not available in the preferred language, the API uses the closest match. * The preferred language has a small influence on the set of results that the API chooses to return, and the order in which they are returned. The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another. For example, utca and _tér_ are synonyms for street in Hungarian. [ccTLD (“top-level domain”)](en.wikipedia.org/wiki/List_of_Internet_top-level_domains #Country_code_top-level_domains) two-character value. Most ccTLD codes are identical to ISO 3166-1 codes, with some notable exceptions. For example, the United Kingdom’s ccTLD is “uk” (.co.uk) while its ISO 3166-1 code is “gb” (technically for the entity of “The United Kingdom of Great Britain and Northern Ireland”).
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
# File 'lib/google_maps_platform/controllers/places_api_controller.rb', line 481 def text_search(query, radius, location: nil, maxprice: nil, minprice: nil, opennow: nil, pagetoken: nil, type: nil, language: Language::EN, region: Region::EN) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/maps/api/place/textsearch/json', Server::DEFAULT) .query_param(new_parameter(query, key: 'query') .is_required(true)) .query_param(new_parameter(radius, key: 'radius') .is_required(true)) .query_param(new_parameter(location, key: 'location')) .query_param(new_parameter(maxprice, key: 'maxprice')) .query_param(new_parameter(minprice, key: 'minprice')) .query_param(new_parameter(opennow, key: 'opennow')) .query_param(new_parameter(pagetoken, key: 'pagetoken')) .query_param(new_parameter(type, key: 'type')) .query_param(new_parameter(language, key: 'language')) .query_param(new_parameter(region, key: 'region')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('ApiKeyAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(PlacesTextSearchResponse.method(:from_hash)) .is_api_response(true)) .execute end |