Skip to content

Latest commit

 

History

History
128 lines (66 loc) · 4.11 KB

Autocomplete.md

File metadata and controls

128 lines (66 loc) · 4.11 KB

See html formatted version

Autocomplete class

google.maps.places.Autocomplete class

A widget that provides Place predictions based on a user's text input. It attaches to an input element of type text, and listens for text entry in that field. The list of predictions is presented as a drop-down list, and is updated as text is entered.

This class extends MVCObject.

Library

places

Constructor

undefined

Autocomplete(inputField[, opts])

Parameters: 

Creates a new instance of Autocomplete that attaches to the specified input text field with the given options.

Methods

undefined

getBounds()

Parameters:  None

Return Value:  LatLngBounds optional

Returns the bounds to which predictions are biased.

undefined

getFields()

Parameters:  None

Return Value:  Array optional

Returns the fields to be included for the Place in the details response when the details are successfully retrieved. For a list of fields see PlaceResult.

undefined

getPlace()

Parameters:  None

Return Value:  PlaceResult

Returns the details of the Place selected by user if the details were successfully retrieved. Otherwise returns a stub Place object, with the name property set to the current value of the input field.

undefined

setBounds(bounds)

Parameters: 

Return Value:  None

Sets the preferred area within which to return Place results. Results are biased towards, but not restricted to, this area.

undefined

setComponentRestrictions(restrictions)

Parameters: 

Return Value:  None

Sets the component restrictions. Component restrictions are used to restrict predictions to only those within the parent component. For example, the country.

undefined

setFields(fields)

Parameters: 

  • fields:  Array optional

Return Value:  None

Sets the fields to be included for the Place in the details response when the details are successfully retrieved. For a list of fields see PlaceResult.

undefined

setOptions(options)

Parameters: 

Return Value:  None

undefined

setTypes(types)

Parameters: 

  • types:  Array

Return Value:  None

Sets the types of predictions to be returned. For a list of supported types, see the developer's guide. If no type is specified, all types will be returned. The setTypes method accepts a single element array.

Events

undefined

function()

Arguments:  None

This event is fired when a PlaceResult is made available for a Place the user has selected.
If the user enters the name of a Place that was not suggested by the control and presses the Enter key, or if a Place Details request fails, the PlaceResult contains the user input in the name property, with no other properties defined.