All Projects → damienroche → vue-custom-google-autocomplete

damienroche / vue-custom-google-autocomplete

Licence: other
🔍 Google Place Autocomplete Search - Renderless component + Wrappers for Bulma, Bootstrap and more...

Programming Languages

typescript
32286 projects
Vue
7211 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to vue-custom-google-autocomplete

Blazorise
Blazorise is a component library built on top of Blazor with support for CSS frameworks like Bootstrap, Bulma, AntDesign, and Material.
Stars: ✭ 2,103 (+6683.87%)
Mutual labels:  bulma, bootstrap4
Formr
Create and Validate PHP Forms in Seconds.
Stars: ✭ 163 (+425.81%)
Mutual labels:  bulma, bootstrap4
Bootstrap Autocomplete
Bootstrap Autocomplete
Stars: ✭ 121 (+290.32%)
Mutual labels:  autocomplete, bootstrap4
cuida
A design system built by Sysvale, using storybook and Vue components
Stars: ✭ 16 (-48.39%)
Mutual labels:  bootstrap4
elm-selectize
selectize-like dropdown menu with autocompletion in elm
Stars: ✭ 28 (-9.68%)
Mutual labels:  autocomplete
techloop-w-plus
Archives of webdev sessions
Stars: ✭ 21 (-32.26%)
Mutual labels:  bootstrap4
love-atom
Smart autocompletion for the LÖVE framework in Atom.
Stars: ✭ 34 (+9.68%)
Mutual labels:  autocomplete
vue-loopback
A Vue project template with Loopback framework optionally with Vuex, Vue-router, and Auth boilerplaite
Stars: ✭ 52 (+67.74%)
Mutual labels:  bootstrap4
bulma-admin
Free admin panel template based on bulma css
Stars: ✭ 28 (-9.68%)
Mutual labels:  bulma
autocomplete
Laravel redis autocomplete
Stars: ✭ 27 (-12.9%)
Mutual labels:  autocomplete
angularjs-es6-starter-kit
Basic AngularJS, ES6, Webpack Starter Kit Project which includes Bootstrap 4 also. This is a boilerplate for AngularJS SPA with Bootstrap 4.
Stars: ✭ 28 (-9.68%)
Mutual labels:  bootstrap4
gatsby-reactstrap
Adding Bootstrap 4 to an Gatsby React App and serve generated the static site with Express.js
Stars: ✭ 25 (-19.35%)
Mutual labels:  bootstrap4
django-tables2-column-shifter
Simple extension for django-tables2 can dynamically show or hide columns. Using JQuery, Bootstrap 3, Bootstrap 4, Bootstrap 5 and Django >=1.9
Stars: ✭ 17 (-45.16%)
Mutual labels:  bootstrap4
webpack-bootstrap
Bootstrap 4 template based on Webpack
Stars: ✭ 48 (+54.84%)
Mutual labels:  bootstrap4
luya-module-admin
Administration base module for all LUYA admin modules
Stars: ✭ 45 (+45.16%)
Mutual labels:  bootstrap4
django-yaaac
Ajax Autocomplete Django application
Stars: ✭ 13 (-58.06%)
Mutual labels:  autocomplete
angular-cli-skeleton
angular-cli skeleton to quickly start a new project with advanced features and best practices. All features are described in README.md.
Stars: ✭ 32 (+3.23%)
Mutual labels:  bootstrap4
graphX
A simple blog based on Nuxt and graphQL
Stars: ✭ 19 (-38.71%)
Mutual labels:  bulma
bootstrap-starter-template
Bootstrap Starter Template for Brackets
Stars: ✭ 33 (+6.45%)
Mutual labels:  bootstrap4
startbootstrap-business-frontpage
A Bootstrap HTML business homepage template created by Start Bootstrap
Stars: ✭ 177 (+470.97%)
Mutual labels:  bootstrap4

vue-custom-google-autocomplete

Custom Google Autcomplete using Place API

Installation

You need Vue.js version 2.0+ and an Google PLACE API key. This plugin is a renderless component. It comes without any css as the main goal is to use it with differents frameworks.

If you looking for framework oriented components, you can import them separately (see pre-configured section) PR are welcome for other components

Install via npm

npm install vue-custom-google-autocomplete
yarn add vue-custom-google-autocomplete

Import and use

Note: if you want a specific preconfigured component, skit this step and import it as a simple component (see pre-configured section)

import Vue from 'vue'
import CustomGoogleAutocomplete from 'vue-custom-google-autocomplete'

...

Vue.use(CustomGoogleAutocomplete)
<template>
  <custom-google-autocomplete :options="options" @select="selected = $event)")
    <div slot-scope="{ inputAttrs, inputEvents, loading, results, query, selectPrediction, hasResults }">
      <input type="search" v-bind="inputAttrs" v-on="inputEvents" />
      <div v-for="(prediction, index) in results" :key="'prediction-' + index" @click="selectPrediction(prediction)">
        {{ prediction.description }}
      </div>
    </div>
  </custom-google-autocomplete>
</template>

<script>
export default {
  data() {
    return {
      selected: null
    }
  }
}
</script>

Props

Name Type Default Description
options Object see options section Plugin options (see options section)

You can also pass all props available on an input (placeholder, name..)

Options

options = {
  apiKey: YOUR_API_KEY,
  deepSearch: true,
  cors: false,
  params: {},
  focus: false
}
Name Type Default Description
apiKey String null Your Google PLACE Api key (REQUIRED)
deepSearch Boolean false Get more informations about selected place (geometry etc..)
cors Boolean false Set to true when project is running locally
params Object {} Google Autocomplete optional parameters
focus Boolean false Focus input
debounceTime Number 400 Time in ms before trigger a new Google api call

Params object is useful to refine predictions, for example if you want to get first predictions near to a location within a radius distance in a certain language you can set params like this :

params = {
  location: `${lat},${lng}`,
  radius: 1000,
  language: 'fr'
}

See Optional parameters section for more informations

Events

@select event is triggered when a prediction is selected. It send an object with datas about the location

Template and slot-scope

In order to be more flexbile, you are able to make your own results template with slot-scope.

props = {
  inputAttrs: Object,
  inputEvents: Object,
  query: String,
  results: Array,
  loading: Boolean,
  selectPrediction: Function,
  hasResults: Boolean
}

Pre-configured Components

Bulma dropdown markup.

Custom Google Autcomplete Example with Bulma Dropdown

<template>
  <bulma-dropdown(:options="options" @select="selected = $event") placeholder="Search"/>
</template>

<script>
import { BulmaDropdown } from 'vue-custom-google-autocomplete'

export default {
  components: {
    BulmaDropdown
  },
  data() {
    return {
      selected: null,
      options: {
        apiKey: process.env.VUE_APP_PLACE_API_KEY,
        deepSearch: true,
        cors: true,
        focus: false,
        params: {
          location: '43.3,5.4',
          radius: 1000,
          language: 'fr'
        }
      }
    }
  }
}
</script>

To customize loading text and no results text, two slots are availables : loading and empty. Input is binded with $attrs

Bootstrap dropdown.

Custom Google Autcomplete Example with Bootstrap Dropdown

<template>
  <bootstrap-dropdown(:options="options" @select="selected = $event") name="input-name"/>
</template>

<script>
import { BootstrapDropdown } from 'vue-custom-google-autocomplete'
export default {
  components: {
    BootstrapDropdown
  },
  data() {
    return {
      selected: null,
      options: any = {
        apiKey: process.env.VUE_APP_PLACE_API_KEY,
        deepSearch: true,
        cors: true,
        focus: false,
        params: {
          location: '45.52345,-122.67621',
          radius: 1000,
          language: 'en'
        }
      }
    }
  }
}
</script>

To customize loading text and no results text, two slots are availables : loading and empty. Input is binded with $attrs

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].