Socket
Book a DemoInstallSign in
Socket

dgtek-google-autocomplete

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dgtek-google-autocomplete

###### Vue, Vuetify

latest
Source
npmnpm
Version
1.4.1
Version published
Maintainers
1
Created
Source

dgtek-google-autocomplete

Vue, Vuetify

Package installation

yarn add dgtek-google-autocomplete && rm -r node_modules/dgtek-google-autocomplete/dist/node_modules
package.json for auto-depoy (CI/CD):

for vue-cli:

"scripts": {
  ...
  "serve": "yarn add dgtek-google-autocomplete && rm -r node_modules/dgtek-google-autocomplete/node_modules && vue-cli-service serve",
  "build": "yarn add dgtek-google-autocomplete && rm -r node_modules/dgtek-google-autocomplete/node_modules && vue-cli-service build",
  ...
}

Start package

import 'dgtek-google-autocomplete/dist/dgtek-google-autocomplete.css'
/* ... other imports here */
const { DgtekGoogleAutocomplete } = require('dgtek-google-autocomplete').default

Set API host

window.dispatchEvent(new CustomEvent('set-api-host', {
  detail: {
    host: 'https://example.com' /* API host url must be here */
  }
}))

You should wait for Google maps script has been loaded in your component

data
data: () => ({
  mapIsReady: false,
  /* ... other variables here */
})
Catch event

You can change the name of this method (catchEvent) to your own

methods: {
  /* your own methods here */,
  catchEvent () {
    const { address, addressComponents, status, url, coordinates, buildingId, error } = event.detail
    ... /* your code will be here */
  }
}

During checking the address, a number of requests will be made to remote server.
Every request can fail.
error field value should be null otherwise this field contains error message

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

  window.requestAnimationFrame(waitForGoogleMapsScript.bind(this))

  window.addEventListener('new-address-data', this.catchEvent)
}
beforeDestroy hook
beforeDestroy () {
  ...
  window.removeEventListener('new-address-data', this.catchEvent)
}

And then insert this package to your component template:

<DgtekGoogleAutocomplete v-if="mapIsReady" />

FAQs

Package last updated on 28 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.