Places Service (deprecated)
PlacesService class
google.maps.places.PlacesService
class
Contains methods related to searching for places and retrieving details about a place.
Access by calling const {PlacesService} = await google.maps.importLibrary("places").
See Libraries in the Maps JavaScript API.
Constructor | |
|---|---|
PlacesService |
Parameters:
Creates a new instance of the |
Methods | |
|---|---|
findPlaceFromPhoneNumber |
Parameters:
Return Value: None Retrieves a list of places based on a phone number. In most cases there should be just one item in the result list, however if the request is ambiguous more than one result may be returned. The |
findPlaceFromQuery |
Parameters:
Return Value: None Retrieves a list of places based on a query string. In most cases there should be just one item in the result list, however if the request is ambiguous more than one result may be returned. The |
getDetails |
Parameters:
Return Value: None Retrieves details about the place identified by the given |
nearbySearch |
Parameters:
Return Value: None Retrieves a list of places near a particular location, based on keyword or type. Location must always be specified, either by passing a |
textSearch |
Parameters:
Return Value: None Retrieves a list of places based on a query string (for example, "pizza in New York", or "shoe stores near Ottawa"). Location parameters are optional; when the location is specified, results are only biased toward nearby results rather than restricted to places inside the area. Use |
PlaceDetailsRequest interface
google.maps.places.PlaceDetailsRequest
interface
A Place details query to be sent to the PlacesService.
Properties | |
|---|---|
placeId |
Type: The Place ID of the Place for which details are being requested. |
fields optional |
Type: Fields to be included in the details response, which will be billed for. If no fields are specified or |
language optional |
Type: A language identifier for the language in which details should be returned. See the list of supported languages. |
region optional |
Type: A region code of the user's region. This can affect which photos may be returned, and possibly other things. The region code accepts a ccTLD ("top-level domain") 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" ( |
sessionToken optional |
Type: Unique reference used to bundle the details request with an autocomplete session. |
FindPlaceFromPhoneNumberRequest interface
google.maps.places.FindPlaceFromPhoneNumberRequest
interface
A find place from text search request to be sent to PlacesService.findPlaceFromPhoneNumber.
Properties | |
|---|---|
fields |
Type: Fields to be included in the response, which will be billed for. If |
phoneNumber |
Type: The phone number of the place to look up. Format must be E.164. |
language optional |
Type: A language identifier for the language in which names and addresses should be returned, when possible. See the list of supported languages. |
locationBias optional |
Type: The bias used when searching for Place. The result will be biased towards, but not restricted to, the given |
FindPlaceFromQueryRequest interface
google.maps.places.FindPlaceFromQueryRequest
interface
A find place from text search request to be sent to PlacesService.findPlaceFromQuery.
Properties | |
|---|---|
fields |
Type: Fields to be included in the response, which will be billed for. If |
query |
Type: The request's query. For example, the name or address of a place. |
language optional |
Type: A language identifier for the language in which names and addresses should be returned, when possible. See the list of supported languages. |
locationBias optional |
Type: The bias used when searching for Place. The result will be biased towards, but not restricted to, the given |
PlaceSearchRequest interface
google.maps.places.PlaceSearchRequest
interface
A Place search query to be sent to the PlacesService.
Properties | |
|---|---|
bounds optional |
Type: The bounds within which to search for Places. Both |
keyword optional |
Type: A term to be matched against all available fields, including but not limited to name, type, and address, as well as customer reviews and other third-party content. |
language optional |
Type: A language identifier for the language in which names and addresses should be returned, when possible. See the list of supported languages. |
location optional |
Type: The location around which to search for Places. |
maxPriceLevel optional |
Type: Restricts results to only those places at the specified price level or lower. Valid values are in the range from 0 (most affordable) to 4 (most expensive), inclusive. Must be greater than or equal to |
minPriceLevel optional |
Type: Restricts results to only those places at the specified price level or higher. Valid values are in the range from 0 (most affordable) to 4 (most expensive), inclusive. Must be less than or equal to |
|
Type: Equivalent to |
openNow optional |
Type: Restricts results to only those places that are open right now. |
radius optional |
Type: The distance from the given location within which to search for Places, in meters. The maximum allowed value is 50 000. |
rankBy optional |
Type: Default: Specifies the ranking method to use when returning results. Note that when |
type optional |
Type: Searches for places of the given type. The type is translated to the local language of the request's target location and used as a query string. If a query is also provided, it is concatenated to the localized type string. Results of a different type are dropped from the response. Use this field to perform language and region independent categorical searches. Valid types are given here. |
TextSearchRequest interface
google.maps.places.TextSearchRequest
interface
A text search request to be sent to the PlacesService.
Properties | |
|---|---|
bounds optional |
Type: Bounds used to bias results when searching for Places (optional). Both |
language optional |
Type: A language identifier for the language in which names and addresses should be returned, when possible. See the list of supported languages. |
location optional |
Type: The center of the area used to bias results when searching for Places. |
query optional |
Type: The request's query term. For example, the name of a place ('Eiffel Tower'), a category followed by the name of a location ('pizza in New York'), or the name of a place followed by a location disambiguator ('Starbucks in Sydney'). |
radius optional |
Type: The radius of the area used to bias results when searching for Places, in meters. |
region optional |
Type: A region code to bias results towards. The region code accepts a ccTLD ("top-level domain") 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" ( |
type optional |
Type: Searches for places of the given type. The type is translated to the local language of the request's target location and used as a query string. If a query is also provided, it is concatenated to the localized type string. Results of a different type are dropped from the response. Use this field to perform language and region independent categorical searches. Valid types are given here. |
RankBy constants
google.maps.places.RankBy
constants
Ranking options for a PlaceSearchRequest.
Access by calling const {RankBy} = await google.maps.importLibrary("places").
See Libraries in the Maps JavaScript API.
Constants | |
|---|---|
DISTANCE |
Ranks place results by distance from the location. |
PROMINENCE |
Ranks place results by their prominence. |
LocationRestriction typedef
google.maps.places.LocationRestriction
typedef
A LocationRestriction represents a strict boundary to use when searching for Places.
PlacesServiceStatus constants
google.maps.places.PlacesServiceStatus
constants
The status returned by the PlacesService on the completion of its searches. Specify these by value, or by using the constant's name. For example, 'OK' or google.maps.places.PlacesServiceStatus.OK.
Access by calling const {PlacesServiceStatus} = await google.maps.importLibrary("places").
See Libraries in the Maps JavaScript API.
Constants | |
|---|---|
INVALID_REQUEST |
This request was invalid. |
NOT_FOUND |
The place referenced was not found. |
OK |
The response contains a valid result. |
OVER_QUERY_LIMIT |
The application has gone over its request quota. |
REQUEST_DENIED |
The application is not allowed to use the PlacesService. |
UNKNOWN_ERROR |
The PlacesService request could not be processed due to a server error. The request may succeed if you try again. |
ZERO_RESULTS |
No result was found for this request. |
google.maps.places.PlaceSearchPagination
interface
An object used to fetch additional pages of Places results.
Properties | |
|---|---|
hasNextPage |
Type: Indicates if further results are available. |
Methods | |
|---|---|
nextPage |
Parameters: None Return Value: Fetches the next page of results. Uses the same callback function that was provided to the first search request. |
PlaceResult interface
google.maps.places.PlaceResult
interface
Defines information about a Place.
Properties | |
|---|---|
address_components optional |
Type: The collection of address components for this Place’s location. Only available with |
adr_address optional |
Type: The representation of the Place’s address in the adr microformat. Only available with |
aspects optional |
Type: The rated aspects of this Place, based on Google and Zagat user reviews. The ratings are on a scale of 0 to 30. |
business_status optional |
Type: A flag indicating the operational status of the Place, if it is a business (indicates whether the place is operational, or closed either temporarily or permanently). If no data is available, the flag is not present in search or details responses. |
formatted_address optional |
Type: The Place’s full address. |
formatted_phone_number optional |
Type: The Place’s phone number, formatted according to the number's regional convention. Only available with |
geometry optional |
Type: The Place’s geometry-related information. |
html_attributions optional |
Type: Attribution text to be displayed for this Place result. Available |
icon optional |
Type: URL to an image resource that can be used to represent this Place’s category. |
icon_background_color optional |
Type: Background color for use with a Place's icon. See also |
icon_mask_base_uri optional |
Type: A truncated URL to an icon mask. Access different icon types by appending a file extension to the end (i.e. |
international_phone_number optional |
Type: The Place’s phone number in international format. International format includes the country code, and is prefixed with the plus (+) sign. Only available with |
name optional |
Type: The Place’s name. Note: In the case of user entered Places, this is the raw text, as typed by the user. Please exercise caution when using this data, as malicious users may try to use it as a vector for code injection attacks (See http://en.wikipedia.org/wiki/Code_injection). |
opening_hours optional |
Type: Defines when the Place opens or closes. |
|
Type: A flag indicating whether the Place is closed, either permanently or temporarily. If the place is operational, or if no data is available, the flag is absent from the response. |
photos optional |
Type: Photos of this Place. The collection will contain up to ten |
place_id optional |
Type: A unique identifier for the Place. |
plus_code optional |
Type: Defines Open Location Codes or "plus codes" for the Place. |
price_level optional |
Type: The price level of the Place, on a scale of 0 to 4. Price levels are interpreted as follows:
|
rating optional |
Type: A rating, between 1.0 to 5.0, based on user reviews of this Place. |
reviews optional |
Type: A list of reviews of this Place. Only available with |
types optional |
Type: An array of types for this Place (for example, |
url optional |
Type: URL of the official Google page for this place. This is the Google-owned page that contains the best available information about the Place. Only available with |
user_ratings_total optional |
Type: The number of user ratings which contributed to this Place’s |
|
Type: The offset from UTC of the Place’s current timezone, in minutes. For example, Sydney, Australia in daylight savings is 11 hours ahead of UTC, so the |
utc_offset_minutes optional |
Type: The offset from UTC of the Place’s current timezone, in minutes. For example, Sydney, Australia in daylight savings is 11 hours ahead of UTC, so the |
vicinity optional |
Type: The simplified address for the Place, including the street name, street number, and locality, but not the province/state, postal code, or country. For example, Google's Sydney, Australia office has a vicinity value of |
website optional |
Type: The authoritative website for this Place, such as a business' homepage. Only available with |
PlaceAspectRating interface
google.maps.places.PlaceAspectRating
interface
Defines information about an aspect of the place that users have reviewed.
Properties | |
|---|---|
rating |
Type: The rating of this aspect. For individual reviews this is an integer from 0 to 3. For aggregated ratings of a place this is an integer from 0 to 30. |
type |
Type: The aspect type. For example, |
BusinessStatus constants
google.maps.places.BusinessStatus
constants
The operational status of the Place, if it is a business, returned in a PlaceResult (indicates whether the place is operational, or closed either temporarily or permanently). Specify these by value, or the constant's name (example: 'OPERATIONAL' or google.maps.places.BusinessStatus.OPERATIONAL).
Access by calling const {BusinessStatus} = await google.maps.importLibrary("places").
See Libraries in the Maps JavaScript API.
Constants | |
|---|---|
CLOSED_PERMANENTLY |
The business is closed permanently. |
CLOSED_TEMPORARILY |
The business is closed temporarily. |
OPERATIONAL |
The business is operating normally. |
PlaceGeometry interface
google.maps.places.PlaceGeometry
interface
Defines information about the geometry of a Place.
Properties | |
|---|---|
location optional |
Type: The Place’s position. |
viewport optional |
Type: The preferred viewport when displaying this Place on a map. This property will be |
PlaceOpeningHours interface
google.maps.places.PlaceOpeningHours
interface
Defines information about the opening hours of a Place.
Properties | |
|---|---|
|
Type: Whether the Place is open at the current time. |
periods optional |
Type: Opening periods covering for each day of the week, starting from Sunday, in chronological order. Days in which the Place is not open are not included. Only available with |
weekday_text optional |
Type: An array of seven strings representing the formatted opening hours for each day of the week. The Places Service will format and localize the opening hours appropriately for the current language. The ordering of the elements in this array depends on the language. Some languages start the week on Monday while others start on Sunday. Only available with |
Methods | |
|---|---|
isOpen |
Parameters:
Return Value: Check whether the place is open now (when no date is passed), or at the given date. If this place does not have |
PlaceOpeningHoursPeriod interface
google.maps.places.PlaceOpeningHoursPeriod
interface
Defines structured information about the opening hours of a Place. Note: If a Place is always open, the close section will be missing from the response. Clients can rely on always-open being represented as an open period containing day with value 0 and time with value "0000", and no close.
Properties | |
|---|---|
open |
Type: The opening time for the Place. |
close optional |
Type: The closing time for the Place. |
PlaceOpeningHoursTime interface
google.maps.places.PlaceOpeningHoursTime
interface
Defines when a Place opens or closes.
Properties | |
|---|---|
day |
Type: The days of the week, as a number in the range [ |
hours |
Type: The hours of the |
minutes |
Type: The minutes of the |
time |
Type: The time of day in 24-hour "hhmm" format. Values are in the range [ |
nextDate optional |
Type: The timestamp (as milliseconds since the epoch, suitable for use with |
PlacePlusCode interface
google.maps.places.PlacePlusCode
interface
Defines Open Location Codes or "plus codes" for a Place. Plus codes can be used as a replacement for street addresses in places where they do not exist (where buildings are not numbered or streets are not named).
Properties | |
|---|---|
global_code |
Type: A plus code with a 1/8000th of a degree by 1/8000th of a degree area. For example, |
compound_code optional |
Type: A plus code with a 1/8000th of a degree by 1/8000th of a degree area where the first four characters (the area code) are dropped and replaced with a locality description. For example, |
PlacePhoto interface
google.maps.places.PlacePhoto
interface
Represents a photo element of a Place.
Properties | |
|---|---|
height |
Type: The height of the photo in pixels. |
html_attributions |
Type: Attribution text to be displayed for this photo. |
width |
Type: The width of the photo in pixels. |
Methods | |
|---|---|
getUrl |
Parameters:
Return Value: Returns the image URL corresponding to the specified options. |
PhotoOptions interface
google.maps.places.PhotoOptions
interface
Defines photo-requesting options.
Properties | |
|---|---|
maxHeight optional |
Type: The maximum height in pixels of the returned image. |
maxWidth optional |
Type: The maximum width in pixels of the returned image. |
PlaceReview interface
google.maps.places.PlaceReview
interface
Represents a single review of a place.
Properties | |
|---|---|
language |
Type: An IETF language code indicating the language in which this review is written. Note that this code includes only the main language tag without any secondary tag indicating country or region. For example, all the English reviews are tagged as |
profile_photo_url |
Type: A URL to the reviwer's profile image. |
relative_time_description |
Type: A string of formatted recent time, expressing the review time relative to the current time in a form appropriate for the language and country. For example |
text |
Type: The text of a review. |
time |
Type: Timestamp for the review, expressed in seconds since epoch. |
|
Type: The aspects rated by the review. The ratings on a scale of 0 to 3. |
author_url optional |
Type: A URL to the reviewer's profile. This will be |
rating optional |
Type: The rating of this review, a number between 1.0 and 5.0 (inclusive). |