Localities Widget Reference 1.0 (Deprecated)

Localities Javascript Widget Reference 1.0
  1. Autocomplete class
  2. AutocompleteLocalities Interface
  3. AutocompleteParameters Interface
  4. AutocompleteResponse Interface
  5. ComponentRestrictions Interface

Autocomplete class

woosmap.localities.Autocomplete
This class extends AutocompleteElementsHandler.

To instantiate the Localities Widget, build a new Autocomplete object.

Constructor
Autocomplete(inputId, customConfig?)
Parameters:
  • inputId: String id attribute for the input hosting the Autocomplete widget
  • customConfig: AutocompleteParameters config object

Methods
addListener(eventName, callback)
Parameters:
  • eventName: string name of the event
  • callback: Function executed through addEventListener
Return Type: Function

Adds an event listener to the widget Can be removed using removeListener() with the same arguments

removeListener(eventName, callback)
Parameters:
  • eventName: string name of the event
  • callback: Function callback to remove, exactly as added to addListener

Removes given event listener from the widget

getSelectedLocality()
Parameters: None
Return Type: AutocompleteLocalities | boolean

Returns the latest user-selected locality among search results, false when unavailable.

getLocalities()
Parameters: None

Returns the latest search results

setTypes(types)
Parameters:
  • types: String | String[] The types queried (example ‘locality’, ‘postal_code’, ‘country’ ; omit param for ‘locality’ + ‘postal_code’)

Sets the types to query

setComponentRestrictions(components)
Parameters:

Sets the component restrictions

setOptions(customConfig)
Parameters:

Sets new config options


AutocompleteLocalities Interface

Properties
Type: String

The country name associated to the prediction

Type: String

The area name associated to the prediction

Type: String

The suggested formatted answer

Type: LatLngLiteral

The location object

Type: String

The location name

Type: String | String[]

Array of postal codes for suggested location (only returned for localities predictions)

Type: String

The largest city (or the post office city) for a postal_code (only returned for postal_code predictions).

Type: String

requested prediction type (‘locality’, ‘postal_code’, ‘country’, ‘admin_level’, ‘train_station’, ‘metro_station’, ‘shopping’, ‘airport’, ‘museum’, ‘zoo’, ‘amusement_park’, ‘art_gallery’, ‘tourist_attraction’)

Type: LatLngBoundsLiteral

The preferred viewpoint when displaying this Locality on a map. This property will be null if the preferred viewport for the Locality is not known.


AutocompleteParameters Interface

Properties

restricts predictions to selected components

Type: String | String[]

Sets custom description using one or more response field (see AutocompleteLocalities object Specification). Selected field should be string or array of string. Field ‘description’ can not be selected.

Type: String

Defaults to ‘standard’, can be set to ‘advanced’ to retrieve postal codes outside western Europe

Type: Number

prevents autocomplete requests from being sent unnecessarily often. Default is no debounce.

Type: String

can be set to ‘postal_code’ to search localities by name or postal codes

Type: Number

all tabindexes in Autocomplete will start from that tabindex. Defaults to 0.

Type: String

expected response language. Default is the country local or browser language

Type: Number

Number of characters before sending request to Localities API

Type: String | String[]

The types queried (example ‘locality’, ‘postal_code’, ‘country’ ; omit param for ‘locality’ + ‘postal_code’)


AutocompleteResponse Interface

Properties

Array with Autocomplete Localities


ComponentRestrictions Interface

Properties
Type: String | String[]

Restricts predictions to the specified country (ISO 3166-1 Alpha-2 country code, case insensitive). For example, ‘fr’, ‘gb’, or ‘es’. You can provide a single one, or an array of country code strings.


Was this article helpful?
Have more questions? Submit a request