Google Maps Api Common.js:154 Uncaught Typeerror: Cannot Read Property 'appendchild' of Undefined
Places Library
Overview
The functions in the Places Library, Maps JavaScript API enable your application to search for places (defined in this API as establishments, geographic locations, or prominent points of interest) independent inside a defined area, such as the bounds of a map, or around a stock-still point.
The Places API offers an autocomplete feature which yous can use to give your applications the type-ahead-search beliefs of the Google Maps search field. When a user starts typing an address, autocomplete volition fill in the residual. For more than data, run across the autocomplete documentation.
Getting started
If you lot are unfamiliar with the Maps JavaScript API or with JavaScript, we recommend reviewing JavaScript and Get an API Cardinal prior to getting started.
Enable APIs
Before using the Places library in the Maps JavaScript API, first ensure that the Places API is enabled in the Google Cloud Console, in the same project y'all gear up upwardly for the Maps JavaScript API.
To view your list of enabled APIs:
- Go to the Google Cloud Panel.
- Click the Select a project push, and so select the aforementioned project you ready for the Maps JavaScript API and click Open up.
- From the list of APIs on the Dashboard, look for Places API.
- If you see the Places API in the list, it'due south already enabled. If the API is not listed, enable it:
- At the summit of the folio, select ENABLE APIS AND SERVICES to brandish the Library tab. Alternatively, from the left side menu, select Library.
- Search for Places API, then select it from the results list.
- Select ENABLE. When the procedure finishes, Places API appears in the list of APIs on the Dashboard.
Loading the library
The Places service is a self-contained library, dissever from the primary Maps JavaScript API code. To use the functionality contained within this library, you must first load information technology using the libraries parameter in the Maps API bootstrap URL:
<script async src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY &libraries=places&callback=initMap"> </script> Come across the Libraries Overview for more data.
Add together Places API to the API fundamental's API restrictions listing
Applying API restrictions to your keys limits usage of the API key to one or more APIs or SDKs. Requests to an API or SDK associated with the API key will be processed. Requests to an API or SDK not associated with the API key will neglect. To restrict an API key for utilise with the Places Library, Maps JavaScript API:
- Go to the Google Deject Console.
- Click the project drop-down and select the project that contains the API cardinal you lot want to secure.
- Click the menu button
and select Google Maps Platform > Credentials. - On the Credentials page, click the proper name of the API central that you want to secure.
- On the Restrict and rename API key page, prepare the restrictions:
- API restrictions
- Select Restrict central.
- Click Select APIs and select both Maps JavaScript API and Places API.
(If either of the APIs is non listed, y'all need to enable it.)
- Click Save.
Usage limits and policies
Quotas
The Places Library, JavaScript API shares a usage quota with Places API as described in the Usage Limits documentation for Places API. The queries per second rate limit is practical per user session, regardless of how many users share the same project.*
Note: When you lot first load the API, you are allocated an initial quota of requests. Once you apply this quota, the API enforces rate limits on additional requests on a per-second basis. If too many requests are fabricated within a sure time period, the API returns an OVER_QUERY_LIMIT response code. The per-session charge per unit limit prevents the use of client-side services for batch requests. For batch requests, use our web service APIs.
Policies
Use of the Places Library, Maps JavaScript API must exist in accordance with the policies described for the Places API.
Place Searches
With the Places service you tin perform the following kinds of searches:
- Find Place from Query returns a identify based on a text query (for case, the proper noun or address of a place).
- Find Place from Telephone Number returns a place based on a phone number.
- Nearby Search returns a list of nearby places based on a user's location.
- Text Search returns a listing of nearby places based on a search string, eg. "Pizza".
- Place Details requests render more detailed information nigh a specific place, including user reviews.
The information returned tin can include establishments — such every bit restaurants, stores, and offices — as well as 'geocode' results, which bespeak addresses, political areas such equally towns and cities, and other points of interest.
Detect Place requests
A Find Place request lets you search for a identify either by text query or phone number. There are two types of Find Identify request:
- Find Place from Query
- Find Place from Phone Number
Find Place from Query
Detect Place from Query takes a text input and returns a place. The input tin be any kind of Identify data, for example a business concern name or accost. To make a Find Identify from Query request, call the PlaceService'due south findPlaceFromQuery() method, which takes the following parameters:
-
query(required) A text string on which to search. -
fields(required) One or more fields specifying the types of Place information to return. -
locationBias(optional) Coordinates defining the surface area to search. This can exist i of the following:- A set of lat/lng coordinates specified as LatLngLiteral or LatLng object
- Rectangular bounds (two lat/lng pairs, or a LatLngBounds object)
- Radius (in meters) centered on a lat/lng
You must also pass a callback method to findPlaceFromQuery(), to handle the results object and google.maps.places.PlacesServiceStatus response.
The following case shows a call to findPlaceFromQuery(), searching for "Museum of Contemporary Art Australia", and including the proper name and geometry fields.
var map; var service; var infowindow; part initMap() { var sydney = new google.maps.LatLng(-33.867, 151.195); infowindow = new google.maps.InfoWindow(); map = new google.maps.Map( document.getElementById('map'), {center: sydney, zoom: 15}); var request = { query: 'Museum of Contemporary Art Australia', fields: ['name', 'geometry'], }; var service = new google.maps.places.PlacesService(map); service.findPlaceFromQuery(asking, part(results, condition) { if (status === google.maps.places.PlacesServiceStatus.OK) { for (var i = 0; i < results.length; i++) { createMarker(results[i]); } map.setCenter(results[0].geometry.location); } }); } View case
Observe Place from Phone Number
Notice Place from Telephone Number takes a phone number and returns a place. To make a Notice Identify from Phone Number asking, call the PlaceService's findPlaceFromPhoneNumber() method, which takes the following parameters:
-
phoneNumber(required) A telephone number, in E.164 format. -
fields(required) One or more fields specifying the types of Place data to return. -
locationBias(optional) Coordinates defining the surface area to search. This tin be one of the following:- A set up of lat/lng coordinates specified equally LatLngLiteral or LatLng object
- Rectangular bounds (four lat/lng points, or a LatLngBounds object)
- Radius (in meters) centered on a lat/lng
You must too pass a callback method to findPlaceFromPhoneNumber(), to handle the results object and google.maps.places.PlacesServiceStatus response.
Fields (Find Identify methods)
Use the fields parameter to specify an assortment of place data types to return. For example: fields: ['formatted_address', 'opening_hours', 'geometry']. Use a dot when specifying compound values. For example: opening_hours.weekday_text.
Fields correspond to Place Search results, and are divided into three billing categories: Bones, Contact, and Atmosphere. Basic fields are billed at base of operations rate, and incur no additional charges. Contact and Temper fields are billed at a higher rate. Come across the pricing sheet for more information. Attributions (html_attributions) are e'er returned with every call, regardless of whether the field has been requested.
Basic
The Bones category includes the following fields:
business_status, formatted_address, geometry, icon,icon_mask_base_uri, icon_background_color, name, permanently_closed (deprecated), photos, place_id, plus_code, types
Contact
The Contact category includes the following field: opening_hours
(deprecated in the Places Library, Maps JavaScript API. Use a Place Details request to get the opening_hours results).
Temper
The Atmosphere category includes the following fields: price_level, rating, user_ratings_total
The findPlaceFromQuery() and findPlaceFromPhoneNumber() methods each take the same set of fields, and tin can return the same fields in their respective responses.
Gear up location bias (Find Place methods)
Use the locationBias parameter to make Find Place favor results in a detail surface area. Yous tin set locationBias in the following ways:
Bias results to a specific surface area:
locationBias: {lat: 37.402105, lng: -122.081974} Ascertain a rectangular expanse to search:
locationBias: {n: 37.41, southward: 37.40, east: -122.08, west: -122.09} You can likewise use a LatLngBounds.
Define a radius to search (in meters), centered on a particular surface area:
locationBias: {radius: 100, center: {lat: 37.402105, lng: -122.081974}} Nearby Search Requests
A Nearby Search lets y'all search for places within a specified expanse past keyword or type. A Nearby Search must always include a location, which can be specified in 1 of ii means:
- a
LatLngBounds. - a round surface area divers equally the combination of the
locationbelongings — specifying the center of the circle as aLatLngobject — and a radius, measured in meters.
A Places Nearby search is initiated with a call to the PlacesService'due south nearbySearch() method, which volition return an assortment of PlaceResult objects. Note that the nearbySearch() method replaces the search() method every bit of version 3.ix.
service = new google.maps.places.PlacesService(map); service.nearbySearch(asking, callback);
This method takes a request with the post-obit fields:
- Either of:
-
bounds, which must be agoogle.maps.LatLngBoundsobject defining the rectangular search area; or - a
locationand aradius; the onetime takes agoogle.maps.LatLngobject, and the latter takes a simple integer, representing the circle's radius in meters. The maximum allowed radius is fifty 000 meters. Notation that whenrankByis prepare to DISTANCE, yous must specify alocationbut y'all cannot specify aradiusorbounds.
-
-
keyword(optional) — A term to be matched against all available fields, including just not limited to name, type, and accost, also as client reviews and other third-party content. -
minPriceLevelandmaxPriceLevel(optional) — Restricts results to simply those places inside the specified range. Valid values range between 0 (almost affordable) to 4 (most expensive), inclusive. -
name(optional) — A term to be matched against the names of places. Results will be restricted to those containing the passed name value. Annotation that a identify may have additional names associated with information technology, beyond its listed name. The API will try to lucifer the passednamevalue against all of these names; as a result, places may be returned in the results whose listed names exercise non friction match the search term, merely whose associated names do. -
openNow(optional) — A boolean value, indicating that the Places service should only return those places that are open for business organisation at the fourth dimension the query is sent. Places that do not specify opening hours in the Google Places database volition non be returned if you include this parameter in your query. SettingopenNowtofauxhas no effect. -
rankBy(optional) — Specifies the order in which results are listed. Possible values are:-
google.maps.places.RankBy.PROMINENCE(default). This selection 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 tin can be affected by a place's ranking in Google's alphabetize, global popularity, and other factors. Whengoogle.maps.places.RankBy.PROMINENCEis specified, theradiusparameter is required. -
google.maps.places.RankBy.Altitude. This option sorts results in ascending order past their altitude from the specifiedlocation(required). Note that you cannot specify a customboundsand/orradiusif you specifyRankBy.DISTANCE. When you specifyRankBy.DISTANCE, one or more ofkeyword,name, ortypeis required.
-
-
type— Restricts the results to places matching the specified type. Just one type may be specified (if more than 1 blazon is provided, all types following the starting time entry are ignored). See the list of supported types.
You must also pass a callback method to nearbySearch(), to handle the results object and google.maps.places.PlacesServiceStatus response.
var map; var service; var infowindow; part initialize() { var pyrmont = new google.maps.LatLng(-33.8665433,151.1956316); map = new google.maps.Map(document.getElementById('map'), { center: pyrmont, zoom: 15 }); var request = { location: pyrmont, radius: '500', type: ['eating house'] }; service = new google.maps.places.PlacesService(map); service.nearbySearch(asking, callback); } function callback(results, status) { if (status == google.maps.places.PlacesServiceStatus.OK) { for (var i = 0; i < results.length; i++) { createMarker(results[i]); } } } View instance
Text Search Requests
The Google Places 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". The service responds with a list of places matching the text string and any location bias that has been set. The search response volition include a listing of places. Yous can transport a Place Details request for more information nigh any of the places in the response.
Text Searches are initiated with a call to the PlacesService's textSearch() method.
service = new google.maps.places.PlacesService(map); service.textSearch(request, callback);
This method takes a request with the following fields:
-
query(required) The text cord on which to search, for example: "eating house". The Places service will return candidate matches based on this string and order the results based on their perceived relevance. This parameter becomes optional if thetypeparameter is as well used in the search request. - Optionally:
-
openNow— A boolean value, indicating that the Places service should merely render those places that are open for business organization at the fourth dimension 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. SettingopenNowtofalsehas no consequence. -
minPriceLevelandmaxPriceLevel— Restricts results to only those places inside the specified price level. Valid values are in the range from 0 (most affordable) to iv (nigh expensive), inclusive. - Either of:
-
premises— Agoogle.maps.LatLngBoundsobject defining the rectangle in which to search; or - a
locationand aradius— Y'all may bias results to a specified circle past passing alocationand aradiusparameter. This volition instruct the Places service to adopt showing results within that circle. Results outside the defined area may notwithstanding be displayed. The location takes agoogle.maps.LatLngobject, and the radius takes a simple integer, representing the circumvolve's radius in meters. The maximum allowed radius is 50 000 meters.
-
-
type— Restricts the results to places matching the specified blazon. Only one type may be specified (if more than 1 blazon is provided, all types following the first entry are ignored). Encounter the listing of supported types.
-
You must as well pass a callback method to textSearch(), to handle the results object and a google.maps.places.PlacesServiceStatus response.
var map; var service; var infowindow; function initialize() { var pyrmont = new google.maps.LatLng(-33.8665433,151.1956316); map = new google.maps.Map(document.getElementById('map'), { heart: pyrmont, zoom: fifteen }); var asking = { location: pyrmont, radius: '500', query: 'eating house' }; service = new google.maps.places.PlacesService(map); service.textSearch(request, callback); } role callback(results, status) { if (condition == google.maps.places.PlacesServiceStatus.OK) { for (var i = 0; i < results.length; i++) { var place = results[i]; createMarker(results[i]); } } } Search Responses
Status Codes
The PlacesServiceStatus response object contains the condition of the asking, and may contain debugging information to aid you lot track down why the identify asking failed. Possible status values are:
-
INVALID_REQUEST: This asking was invalid. -
OK: The response contains a valid result. -
OVER_QUERY_LIMIT: The webpage has gone over its request quota. -
REQUEST_DENIED: The webpage is non immune to use the PlacesService. -
UNKNOWN_ERROR: The PlacesService request could not exist processed due to a server mistake. The request may succeed if yous try once again. -
ZERO_RESULTS: No effect was institute for this request.
Place Search Results
The findPlace(), nearbySearch() and textSearch() functions return an array of PlaceResult objects.
Each PlaceResult object may include the post-obit properties:
-
business_statusindicates the operational status of the place, if it is a business. It can comprise one of the following values:-
OPERATIONAL -
CLOSED_TEMPORARILY -
CLOSED_PERMANENTLY
business_statusis not returned. -
-
formatted_addressis a string containing the human-readable address of this place. Theformatted_addressproperty is only returned for a Text Search.Often this address is equivalent to the postal accost. Note that some countries, such as the United Kingdom, exercise non allow distribution of true postal addresses due to licensing restrictions.
The formatted address is logically composed of one or more than address components. For example, the address "111 8th Avenue, New York, NY" consists of the following components: "111" (the street number), "8th Avenue" (the road), "New York" (the city) and "NY" (the Usa country).
Do not parse the formatted address programmatically. Instead y'all should apply the individual accost components, which the API response includes in addition to the formatted address field.
-
geometry: The place'due south geometry-related data. This includes:-
locationprovides the latitude and longitude of the place. -
viewportdefines the preferred viewport on the map when viewing this identify.
-
-
permanently_closed(deprecated) is a boolean flag indicating whether the place has close downwardly either permanently or temporarily (valuetrue). Do not usepermanently_closed. Instead, usebusiness_statusto get the operational condition of businesses. -
plus_code(see Open Location Code and plus codes) is an encoded location reference, derived from latitude and longitude coordinates, that represents an surface area: 1/8000th of a degree by one/8000th of a degree (about 14m x 14m at the equator) or smaller. Plus codes tin can be used as a replacement for street addresses in places where they practise not exist (where buildings are not numbered or streets are not named).The plus code is formatted as a global code and a chemical compound code:
-
global_codeis a 4 character surface area code and 6 graphic symbol or longer local code (849VCWC8+R9). -
compound_codeis a half dozen character or longer local code with an explicit location (CWC8+R9, Mountain View, CA, United states of america). Practise not programmatically parse this content.
-
-
html_attributions: An array of attributions that you should brandish when displaying the search results. Each entry in the array contains the HTML text for a single attribution. Note: This is an aggregation of all the attributions for the entire search response. AllPlaceResultobjects in the response therefore contain identical attribution lists. -
iconreturns the URL for a colored 71px x 71px PNG icon. -
icon_mask_base_urireturns the base URL for a non-colored icon, minus the .svg or .png extension. -
icon_background_colorreturns the default HEX colour code for the place'due south category. -
proper noun: The identify's name. -
opening_hoursmay contain the following information:-
open_nowis a boolean value indicating if the identify is open at the current time (Deprecated in the Places Library, Maps JavaScript API, useutc_offset_minutesinstead).
-
-
place_idis a textual identifier that uniquely identifies a place. To call back information about the place, laissez passer this identifier in the Place Details asking. Larn more about how to reference a place with a place ID. -
ratingcontains the place's rating, from 0.0 to five.0, based on aggregated user reviews. -
typesAn assortment of types for this place (e.g.,["political", "locality"]or["eating house", "lodging"]). This assortment may comprise multiple values, or may exist empty. New values may be introduced without prior find. See the listing of supported types. -
vicinity: A simplified address for the place, including the street name, street number, and locality, but non the province/state, postal code, or country. For example, Google'due south Sydney, Australia role has avicinityvalue of5/48 Pirrama Road, Pyrmont.
Accessing Additional Results
Past default, each place search returns up to 20 results per query. However, each search can render equally many every bit sixty results, split across three pages. Additional pages are available via the PlaceSearchPagination object. In order to access boosted pages y'all must capture the PlaceSearchPagination object via a callback office. The PlaceSearchPagination object is defined as:
-
hasNextPagea boolean holding that indicates if further results are available.truthfulwhen there is an additional results page. -
nextPage()a function that will return the side by side ready of results. Afterward executing a search, you must look 2 seconds earlier the next page of results will be available.
To see the next ready of results, call nextPage. Each page of results must be displayed before displaying the next page of results. Note that each search counts as a single request against your usage limits.
The example below demonstrates how to alter your callback function to capture the PlaceSearchPagination object, so that you tin issue multiple search requests.
Place Details
In addition to providing a list of places inside an area, the Places service can besides render detailed data most a specific place. Once a place has been returned in a place search response, its place ID can be used to request boosted details near that place, such as its complete address, telephone number, user rating and reviews, etc.
Identify Details Requests
Place Details are requested with a call to the service's getDetails() method.
service = new google.maps.places.PlacesService(map); service.getDetails(request, callback);
This method takes a request, containing the desired place's placeId, and fields indicating which types of Places data to return. Learn more well-nigh how to reference a identify with a place ID.
It also takes a callback method, which needs to handle the condition code passed in the google.maps.places.PlacesServiceStatus response, besides as the google.maps.places.PlaceResult object.
var asking = { placeId: 'ChIJN1t_tDeuEmsRUsoyG83frY4', fields: ['name', 'rating', 'formatted_phone_number', 'geometry'] }; service = new google.maps.places.PlacesService(map); service.getDetails(request, callback); function callback(place, status) { if (condition == google.maps.places.PlacesServiceStatus.OK) { createMarker(place); } } View example
Fields (Place details)
The fields parameter takes an array of strings (field names).
Utilise the fields parameter to specify an array of place data types to return. For example: fields: ['address_component', 'opening_hours', 'geometry']. Use a dot when specifying compound values. For instance: opening_hours.weekday_text.
Fields represent to Identify Details results, and are divided into three billing categories: Basic, Contact, and Temper. Bones fields are billed at base rate, and incur no boosted charges. Contact and Atmosphere fields are billed at a higher rate. See the pricing sheet for more than data. Attributions (html_attributions) are e'er returned with every phone call, regardless of whether it has been requested.
Basic
The Basic category includes the post-obit fields:
address_component, adr_address, business_status, formatted_address, geometry, icon, icon_mask_base_uri, icon_background_color,proper name, permanently_closed (deprecated), photo, place_id, plus_code, type, url, utc_offset (deprecated in the Places Library, Maps JavaScript API), utc_offset_minutes, vicinity
Contact
The Contact category includes the post-obit fields:
formatted_phone_number, international_phone_number, opening_hours, website
Temper
The Atmosphere category includes the following fields: price_level, rating, review, user_ratings_total
Acquire more than virtually place fields. For more information nigh how Place data requests are billed, encounter Usage and Billing.
Place Details Responses
Condition Codes
The PlacesServiceStatus response object contains the status of the request, and may comprise debugging information to help y'all track down why the Place Details request failed. Possible status values are:
-
INVALID_REQUEST: This request was invalid. -
OK: The response contains a valid upshot. -
OVER_QUERY_LIMIT: The webpage has gone over its request quota. -
NOT_FOUNDThe referenced location was non institute in the Places database. -
REQUEST_DENIED: The webpage is not immune to utilise the PlacesService. -
UNKNOWN_ERROR: The PlacesService request could not exist candy due to a server fault. The request may succeed if you endeavor again. -
ZERO_RESULTS: No upshot was found for this request.
Place Details Results
A successful getDetails() call returns a PlaceResult object with the following properties:
-
address_components: An array containing the split up components applicable to this address.Each address component typically contains the post-obit fields:
-
types[]is an assortment indicating the type of the accost component. See the list of supported types. -
long_nameis the full text clarification or name of the address component as returned by the Geocoder. -
short_nameis an abbreviated textual name for the accost component, if available. For example, an address component for the state of Alaska may take along_nameof "Alaska" and ashort_nameof "AK" using the 2-alphabetic character postal abbreviation.
Annotation the post-obit facts most the
address_components[]array:- The array of address components may contain more components than the
formatted_address. - The array does non necessarily include all the political entities that contain an accost, apart from those included in the
formatted_address. To call up all the political entities that contain a specific accost, you should use opposite geocoding, passing the latitude/longitude of the address as a parameter to the request. - The format of the response is not guaranteed to remain the same between requests. In particular, the number of
address_componentsvaries based on the address requested and can modify over time for the aforementioned accost. A component can modify position in the array. The type of the component can alter. A particular component may be missing in a later response.
-
-
business_statusindicates the operational condition of the place, if it is a business. It tin can contain one of the following values:-
OPERATIONAL -
CLOSED_TEMPORARILY -
CLOSED_PERMANENTLY
business_statusis not returned. -
-
formatted_address: The human-readable address of this identify.Frequently this accost is equivalent to the postal accost. Note that some countries, such as the U.k., do non allow distribution of truthful postal addresses due to licensing restrictions.
The formatted address is logically equanimous of i or more address components. For example, the address "111 8th Artery, New York, NY" consists of the post-obit components: "111" (the street number), "8th Artery" (the road), "New York" (the city) and "NY" (the US state).
Do non parse the formatted accost programmatically. Instead y'all should employ the individual address components, which the API response includes in addition to the formatted address field.
-
formatted_phone_number: The identify'southward telephone number, formatted according to the number's regional convention. -
geometry: The identify's geometry-related information. This includes:-
locationprovides the latitude and longitude of the place. -
viewportdefines the preferred viewport on the map when viewing this place.
-
-
permanently_closed(deprecated) is a boolean flag indicating whether the place has close down either permanently or temporarily (valuetruthful). Do not usepermanently_closed. Instead, usebusiness_statusto get the operational status of businesses. -
plus_code(see Open up Location Code and plus codes) is an encoded location reference, derived from breadth and longitude coordinates, that represents an area: i/8000th of a degree by 1/8000th of a degree (about 14m x 14m at the equator) or smaller. 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 non named).The plus code is formatted as a global code and a compound code:
-
global_codeis a 4 graphic symbol area code and 6 character or longer local code (849VCWC8+R9). -
compound_codeis a 6 graphic symbol or longer local code with an explicit location (CWC8+R9, Mount View, CA, U.s.a.). Do not programmatically parse this content.
-
-
html_attributions: Attribution text to exist displayed for this place result. -
icon: URL to an image resource that can exist used to represent this identify's blazon. -
international_phone_numbercontains the place's phone number in international format. International format includes the land code, and is prefixed with the plus (+) sign. For example, theinternational_phone_numberfor Google'southward Sydney, Australia office is+61 2 9374 4000. -
proper noun: The place'south name. -
utc_offsetDeprecated in the Places Library, Maps JavaScript API, useutc_offset_minutesinstead. -
utc_offset_minutescontains the number of minutes this identify'southward current timezone is offset from UTC. For instance, for places in Sydney, Commonwealth of australia during daylight saving time this would be 660 (+11 hours from UTC), and for places in California outside of daylight saving time this would be -480 (-8 hours from UTC). -
opening_hourscontains the following information:-
open_now(Deprecated in the Places Library, Maps JavaScript API; use opening_hours.isOpen() instead. See this video for how to useisOpenwith Place Details.) is a boolean value indicating whether the place is open at the current time. -
periods[]is an array of opening periods covering seven days, starting from Sunday, in chronological order. Each catamenia contains:-
opencontains a pair of solar day and time objects describing when the place opens:-
twenty-four hour perioda number from 0–6, corresponding to the days of the week, starting on Sunday. For case, two means Tuesday. -
timemay comprise a time of day in 24-hour hhmm format (values are in the range 0000–2359). Thetimewill be reported in the place's timezone.
-
-
closemay incorporate a pair of 24-hour interval and fourth dimension objects describing when the place closes. Note: If a place is always open, theclosesection will exist missing from the response. Applications can rely on ever-open being represented every bit anopen upperiod containingtwenty-four hour periodwith value 0 andtimewith value 0000, and noshut.
-
-
weekday_textis an array of 7 strings representing the formatted opening hours for each twenty-four hours of the week. If alanguageparameter was specified in the Place Details request, the Places Service will format and localize the opening hours appropriately for that linguistic communication. The ordering of the elements in this array depends on thelanguageparameter. Some languages offset the calendar week on Monday while others kickoff on Sunday.
-
-
permanently_closed(deprecated) is a boolean flag indicating whether the identify has shut down either permanently or temporarily (valuetrue). Do not applypermanently_closed. Instead, utilizebusiness_statusto get the operational condition of businesses. -
photos[]: an array ofPlacePhotoobjects. APlacePhototin can be used to obtain a photo with thegetUrl()method, or you tin inspect the object for the following values:-
meridian: the maximum meridian of the image, in pixels. -
width: the maximum width of the image, in pixels. -
html_attributions: Attribution text to be displayed with this place photo.
-
-
place_id: A textual identifier that uniquely identifies a place and tin can be used to think information about the place via a Place Details asking. Learn more about how to reference a place with a place ID. -
rating: The identify's rating, from 0.0 to 5.0, based on aggregated user reviews. -
reviewsan assortment of up to five reviews. Each review consists of several components:-
aspects[]contains an array ofPlaceAspectRatingobjects, each of which provides a rating of a single attribute of the establishment. The first object in the array is considered the primary attribute. EachPlaceAspectRatingis defined as:-
typethe proper noun of the aspect that is being rated. The following types are supported:entreatment,atmosphere,decor,facilities,food,overall,qualityandservice. -
ratingthe user's rating for this particular aspect, from 0 to 3.
-
-
author_namethe name of the user who submitted the review. Bearding reviews are attributed to "A Google user". If a language parameter was set, and then the phrase "A Google user" will render a localized string. -
author_urlthe URL to the users Google+ contour, if available. -
languagean IETF language code indicating the language used in the user'southward review. This field contains the chief language tag merely, and not the secondary tag indicating land or region. For example, all the English reviews are tagged as 'en', and not 'en-AU' or 'en-Britain' and so on. -
ratingthe user's overall rating for this place. This is a whole number, ranging from 1 to 5. -
textthe user's review. When reviewing a location with Google Places, text reviews are considered optional; therefore, this field may by empty.
-
-
typesAn array of types for this identify (e.g.,["political", "locality"]or["restaurant", "lodging"]). This array may incorporate multiple values, or may be empty. New values may be introduced without prior find. See the list of supported types. -
url: URL of the official Google folio for this place. This is the Google-owned folio that contains the best available information about the identify. Applications must link to or embed this page on any screen that shows detailed results about the place to the user. -
vicinity: A 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'south Sydney, Australia function has avicinityvalue ofv/48 Pirrama Road, Pyrmont. Thevicinityproperty is only returned for a Nearby Search. -
websitelists the administrative website for this place, such as a business' homepage.
Note: Multidimensional ratings may not be available for all locations. If there are too few reviews then the details response will either include a legacy rating on a 0.0 to five.0 scale (if available) or no rating at all.
Referencing a Identify with a Identify ID
A place ID is a unique reference to a place on a Google Map. Place IDs are bachelor for well-nigh locations, including businesses, landmarks, parks, and intersections.
To use a identify ID in your app you must starting time expect up the ID, which is available in PlaceResult of a Place Search or Details request. Y'all can and then employ this identify ID to look upward Place Details.
Place IDs are exempt from the caching restrictions stated in Section 3.two.iii(a) of the Google Maps Platform Terms of Service. Yous can therefore store identify ID values for later use. For best practises when storing place IDs, see the identify ID overview.
var map; function initialize() { // Create a map centered in Pyrmont, Sydney (Australia). map = new google.maps.Map(document.getElementById('map'), { center: {lat: -33.8666, lng: 151.1958}, zoom: 15 }); // Search for Google's office in Australia. var request = { location: map.getCenter(), radius: '500', query: 'Google Sydney' }; var service = new google.maps.places.PlacesService(map); service.textSearch(request, callback); } // Checks that the PlacesServiceStatus is OK, and adds a marker // using the identify ID and location from the PlacesService. function callback(results, status) { if (status == google.maps.places.PlacesServiceStatus.OK) { var marking = new google.maps.Marking({ map: map, place: { placeId: results[0].place_id, location: results[0].geometry.location } }); } } google.maps.event.addDomListener(window, 'load', initialize); Place Photos
The Place Photo characteristic allows you to add loftier quality photographic content to your site. The Photo service gives yous access to the millions of photos stored in the Places and Google+ Local database. When you lot get place information using a Identify Details request, photo references will be returned for relevant photographic content. The Nearby Search and Text Search requests also return a single photograph reference per place, when relevant. Using the Photo service you tin can then access the referenced photos and resize the prototype to the optimal size for your application.
An array of PlacePhoto objects will be returned equally role of the PlaceResult object for any getDetails(), textSearch() or nearbySearch() request made against a PlacesService.
Note: The number of photos returned varies by asking.
- A Nearby Search or a Text Search volition return at nigh one
PlacePhotoobject. - A Details request will return up to ten
PlacePhotoobjects.
You tin can asking the URL for the associated prototype by calling the PlacePhoto.getUrl() method, and passing a valid PhotoOptions object. The PhotoOptions object allows yous to specify the maximum desired elevation and width of the paradigm. If y'all specify a value for both maxHeight and a maxWidth, the photo service will resize the paradigm to the smaller of the 2 sizes, while maintaining the original aspect ratio.
The following code snippet accepts a place object, and adds a marker to the map if a photo exists. The default marker image is replaced by a minor version of the photo.
part createPhotoMarker(place) { var photos = place.photos; if (!photos) { return; } var marker = new google.maps.Marker({ map: map, position: place.geometry.location, title: identify.name, icon: photos[0].getUrl({maxWidth: 35, maxHeight: 35}) }); } Photos returned by the Photograph service are sourced from a variety of locations, including business owners and user contributed photos. In about cases, these photos tin be used without attribution, or will have the required attribution included every bit a office of the image. However, if the returned photograph element includes a value in the html_attributions field, you must include the additional attribution in your application wherever you display the image.
Except equally otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Coffee is a registered trademark of Oracle and/or its affiliates.
Concluding updated 2022-02-28 UTC.
Source: https://developers.google.com/maps/documentation/javascript/places
0 Response to "Google Maps Api Common.js:154 Uncaught Typeerror: Cannot Read Property 'appendchild' of Undefined"
Post a Comment