1.0.85 • Published 3 years ago

portal-google-autocomplete v1.0.85

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

portal-google-autocomplete

Package installation

yarn add portal-google-autocomplete

Start package

import PortalGoogleAutocomplete from 'portal-google-autocomplete'

customElements.define('portal-google-autocomplete', PortalGoogleAutocomplete)

Set API host

<portal-google-autocomplete host="https://example.com/api" />

The package does not load Google maps API.

The Google maps script is expected to be loaded by your application.

You should wait for Google maps script has been loaded before you start to use the package:

data
mapIsReady: false
mounted hook
function waitForGoogleMapsScript () {
  if (!window.google) window.requestAnimationFrame(waitForGoogleMapsScript.bind(this))
  else this.mapIsReady = true
}

window.requestAnimationFrame(waitForGoogleMapsScript.bind(this))
Catch events

Submit button event:

window.addEventListener('new-address-data', function (event) {
  console.log(event.detail) /* replace this with your code */
})

During checking the address, a number of requests will be made to remote server.

Every request can fail.

window.addEventListener('server-error', function (event) {
  console.log(event.detail) /* { error: true, errorType: String, errorMessage: String } */
})
mounted hook
window.addEventListener('new-address-data', this.catchEvent)
beforeDestroy hook
window.removeEventListener('new-address-data', this.catchEvent)
1.0.84

3 years ago

1.0.81

3 years ago

1.0.85

3 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.71

4 years ago

1.0.74

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago