Localities Reference 2.0

Localities Javascript API Reference 2.0
  1. AutocompleteService class 
  2. AutocompleteRequest object Specification 
  3. AutocompleteResponse object Specification 
  4. AutocompleteResponseItem object Specification 
  5. ComponentRestrictions object Specification 
  6. DetailsResponseItem object Specification 
  7. ErrorAutocompleteCallback function definition 
  8. ErrorDetailsCallback function definition 
  9. MatchedElements object Specification 
  10. MatchedSubstring object Specification 
  11. SuccessAutocompleteCallback function definition 
  12. SuccessDetailsCallback function definition 

AutocompleteService class 🔗


woosmap.localities.AutocompleteService

Constructor
AutocompleteService(key:String)

Methods
autocomplete(params:AutocompleteRequest, callback:SuccessAutocompleteCallback, errorCallback:ErrorAutocompleteCallback, debounceTime:Number)

Get the suggestions array from an input value.

getDetails(public_id:String, callback:SuccessDetailsCallback, errorCallback:ErrorDetailsCallback)

Get the details of a Localities Item from its public_id.


AutocompleteRequest object Specification  🔗


Properties
input Type: String

User input

customDescription Type: String

This parameter allows to choose the description format for all or some of the suggestion types selected. The custom formats are described as follows : custom_description=type_A:"{field_1}, {field_2}, [...]"|type_B:"{field_1}, {field_2}, [...]" .

components Type: ComponentRestrictions

restricts suggestions to selected components

types Type: String|Array.<String>

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

data Type: String

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

extended Type: String

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

language Type: String

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


AutocompleteResponse object Specification  🔗


Properties
localities Type: AutocompleteResponseItem

Array with Autocomplete items


AutocompleteResponseItem object Specification  🔗


Properties
public_id Type: String

Item identifier

description Type: String

The suggested formatted answer

matched_substrings Type: Array

Contains an array with offset value and length. These describe the location of the entered term in the prediction result text, so that the term can be highlighted if desired.

type Type: String

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


ComponentRestrictions object Specification  🔗


Properties
country Type: String|Array.<String>

Restricts suggestions 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.


DetailsResponseItem object Specification  🔗


Properties
public_id Type: String

Item identifier

name Type: String

Item name

geometry Type: Object

Item geometry ({location:{lat, lng}, viewport: {northeast: {lat, lng}, southwest: {lat, lng}}})

formatted_address Type: String

String containing the human-readable address of this item.

types Type: Array

Types of the given item (like locality or postal_code)

address_components Type: Array

Array containing the separate components applicable to this address. Each component has a long name (full text description or name of the address component), a short name (abbreviated textual name for the address component, if available) and types (array indicating the type of the address component like locality, street_number…)


ErrorAutocompleteCallback function definition  🔗

ErrorAutocompleteCallback

Function
function(errorCode:Number,errorText:String)

Callback executed when autocomplete query fails

ErrorDetailsCallback function definition  🔗

ErrorDetailsCallback

Function
function(errorCode:Number,errorText:String)

Callback executed when details query fails

MatchedElements object Specification  🔗


Properties
description Type: [ 'Array' ].<MatchedSubstring>

(optional) A set of substrings that match the description field


MatchedSubstring object Specification  🔗


Properties
offset Type: Number

The offset to the substring’s start within the AutocompleteLocalities field string

length Type: Number

The length of the substring


SuccessAutocompleteCallback function definition  🔗

SuccessAutocompleteCallback

Function
function(autocompleteResponse:AutocompleteResponse)

Callback executed when autocomplete query is successful

SuccessDetailsCallback function definition  🔗

SuccessDetailsCallback

Function
function(autocompleteResponse:DetailsResponseItem)

Callback executed when details query is successful

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