Google Autocomplete Vue Componet

Google Autocomplete

I am sharing this component because I was overwhelmed by complicated examples to achieve this simple job. So, I will try to be as simple as I can during my explanation.

Google Autocomplete component is no more than a Vue.js wrapper around the official Google Places API. In spite of the demo written in Vue.js, the Autocomplete object can be pulled in from any JS framework.

Requirements

You will have to install Vue & Vuemit:

npm install vue --save
npm install vuemit --save

The Vuemit library is used to manage the events between the google component and its parent one.

Note: If you happen to be using Vue 1.*, you will have to pull from the vue-1 branch.

Installation

To install this package you just need to open your console and type npm i google-autocomplete-vue --save. If there are any problems during the installation, you can try again using the force param: npm i -f google-autocomplete-vue --save

Getting started

First of all, you have to sign up on Google API Console to get your API key: https://console.developers.google.com Once this has been done, you will have to copy the API KEY given by google and paste it in your JS file entry point. Example:

  • Bootstrap File: bootstrap.js. You will have to require Vuemit in this file to have the events handler set globaly. As so: Example

  • Entry point file: demo.js

Note: Important keys have to be kept within an .env file, so be aware of this while pushing your code to your git control.

Second of all, you will have to import the component in your application entry point, so you can call it globally when needed. Example:

import GoogleAutocomplete from 'google-autocomplete-vue';

Validation on server side

Places validation is a laravel library that will help you out to handle your user addresses. Its aim is making sure addresses submitted by users are valid through 3rd party services, as google.

Take a look at its repository: Places Validation

Guide

  • First of all, you have to create an entry point to compile the component and generate your bundle file. An example is available here.

  • Second of all, you will have to create your vue object to control the component:

require('./bootstrap');

new Vue({

    el: '#demo',

    data:
    {
        output: {}, address: {}, sent: false, response: {}, config: {}
    },

    mounted()
    {
        //Set an event listener for 'setAddress'.
        Vuemit.listen('setAddress', this.onAddressChanged);
        Vuemit.listen('addressWasCleared', this.onAddressCleared);
    },

    methods:
    {
        /**
         * Submit the data to be evaluated.
         *
         * @return {Void}
         */
        submit()
        {
            this.sent = true;
            this.output = this.address;
            this.address = {};
        },

        /**
         * Checks whether the output data is valid.
         *
         * @return {Bool}
         */
        isValid()
        {
            return Object.keys(this.output).length > 0;
        },

        /**
         * Checks whether the output data is not valid.
         *
         * @return {Bool}
         */
        isNotValid()
        {
            return ! this.isValid();
        },

        /**
         * The callback fired when the autocomplete address change event is fired.
         *
         * @param {Object}
         * @return {Void}
         */
        onAddressChanged(payload)
        {
            if (Object.keys(paypload.place).length > 0) {
                this.address = payload.address;
                this.response = payload.response;
            }
        }

        /**
         * The callback fired when the autocomplete clear event is fired.
         *
         * @param {Object}
         * @return {Void}
         */
        onAddressCleared()
        {
            this.address = {};
            this.response = {};
        }
    }
});

See the example here.

  • Third of all, you have to compile these two files with browserify, webpack or laravel-elixir-vue-2 to make them readable for every browser. Example:
require('laravel-elixir-vue-2');
var elixir = require('laravel-elixir');

elixir.config.sourcemaps = false;
elixir.config.assetsPath = 'src';

elixir(function(mix)
{
    mix.webpack('demo.js', 'dist/demo.js');
});

See the example here

  • Finally, you can use the component in your HTML file using this syntax:
<google-autocomplete
    class = "input"
    input_id = "txtAutocomplete"
    :config = "{type: ['geocode']}"
    placeholder = "type your address"
>
</google-autocomplete>

:config is the config passed to the Autocomplete constructor of the places API. See the documentation. Config corresponds to the options argument in the doc.

See the example here.

Also, you can pass any css class through the “class” prop.

Contributing

Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.

License

The MIT License (MIT). Please see License File for more information.

How can I thank you?

Why not star the github repo? Share the link for this repository on Twitter? Spread the word!

Don’t forget to follow me on twitter!

Download Details:

Author: gocanto

Live Demo: https://gocanto.github.io/google-autocomplete/

GitHub: https://github.com/gocanto/google-autocomplete

#vuejs #javascript #vue-js

What is GEEK

Buddha Community

Google Autocomplete Vue Componet

I am Developer

1614263355

Google Places Autocomplete In PHP with Example

PHP 8 google address autocompletes without showing the map. In this tutorial, i will show youhow to create a google autocomplete address web app using google address APIs in PHP.

Note that, Google autocomplete address API will return address and as well as latitude, longitude, place code, state, city, country, etc. Using latitude and longitude of address, you can show markers location in google map dynamically in php.

This tutorial guide to you step by step how to implement google places autocomplete address web application without showing google maps in PHP.

For implementing the autocomplete address in php, you will have to get the key from google console app. So, just go to the link https://cloud.google.com and get the google API key.

https://www.tutsmake.com/php-google-places-autocomplete-example/

#autocomplete address google api php #google places autocomplete example in php #google places autocomplete example without map in php #php google places autocomplete jquery #php google places autocomplete jquery example

Ethan Hughes

Ethan Hughes

1578335505

Collection of Good Vue Autocomplete Components for Your Vue.js App

The Vue AutoComplete component helps users by providing a list of suggestions to select from as they type. It supports data binding, filtering, and more.

1. vue-suggestion

Suggestion list input for Vue.js, inspired by v-autocomplete.
Your search engine, your CSS, your everything…

vue-suggestion

Demo

Download


2. Accessible Autocomplete

Accessible autocomplete component for vanilla JavaScript and Vue.

Features

  • Accessible, with full support for ARIA attributes and keyboard interactions. Based on the WAI-ARIA Authoring Practices.
  • Available as a JavaScript or Vue component, with React coming soon.
  • Core package available if you want to bring your own rendering layer.
  • Customizable. Easily bring your own CSS, or take full control of the component rendering.
  • Support for asynchronous data fetching.

Autocomplete

Demo

Download


3. Select Auto-Complete

Provides a capability of auto-completed searching for results inside a select input field.

Select Auto-Complete

Download


4. vue-cool-select

Select with autocomplete, slots, bootstrap and material design themes.

Features

  • no dependencies
  • props (30) allow you to customize a component in a various ways
  • slots (13) allow content to be changed anywhere
  • events (8) will let you know about everything
  • autocomplete (you can use custom search, you can also disable the search input)
  • keyboard controls (not only through the arrows)
  • support on mobile devices
  • validation, state of error and success
  • disabled and readonly
  • small and large sizes (as in bootstrap)
  • the ability to set your styles, you can write theme from scratch. 2 themes: Bootstrap 4 (equal styles), Material Design
  • TypeScript support
  • tab navigation
  • SSR (Server-Side Rendering)
  • auto determine the suitable position for the menu if it goes beyond the viewport

vue-cool-select

Demo

Download


5. Vue Form Autocomplete - Simple

Vue Form Autocomplete Custom Component.

Able to use single or multiple select. Use scope slot to change the template

Vue Form Autocomplete - Simple

Demo and Download


6. Vue Tags Input

A simple tags input with typeahead built with Vue.js 2.

Vue Tags Input

Demo

Download


7. At.js for Vue.

At.js is An autocompletion library to autocomplete mentions, smileys etc.

  • Filter/Scroll/Insert/Delete
  • Keyboard/Mouse events
  • Plain-text based, no jQuery, no extra nodes
  • ContentEditable
  • Avatars, custom templates
  • Vue2
  • Vue1

At.js for Vue

Demo

Download


Thank for read!

#vue-autocomplete #autocomplete-component #autocomplete #vue-js #autocomplete-vue

Luna  Mosciski

Luna Mosciski

1600583123

8 Popular Websites That Use The Vue.JS Framework

In this article, we are going to list out the most popular websites using Vue JS as their frontend framework.

Vue JS is one of those elite progressive JavaScript frameworks that has huge demand in the web development industry. Many popular websites are developed using Vue in their frontend development because of its imperative features.

This framework was created by Evan You and still it is maintained by his private team members. Vue is of course an open-source framework which is based on MVVM concept (Model-view view-Model) and used extensively in building sublime user-interfaces and also considered a prime choice for developing single-page heavy applications.

Released in February 2014, Vue JS has gained 64,828 stars on Github, making it very popular in recent times.

Evan used Angular JS on many operations while working for Google and integrated many features in Vue to cover the flaws of Angular.

“I figured, what if I could just extract the part that I really liked about Angular and build something really lightweight." - Evan You

#vuejs #vue #vue-with-laravel #vue-top-story #vue-3 #build-vue-frontend #vue-in-laravel #vue.js

Jon  Gislason

Jon Gislason

1619247660

Google's TPU's being primed for the Quantum Jump

The liquid-cooled Tensor Processing Units, built to slot into server racks, can deliver up to 100 petaflops of compute.

The liquid-cooled Tensor Processing Units, built to slot into server racks, can deliver up to 100 petaflops of compute.

As the world is gearing towards more automation and AI, the need for quantum computing has also grown exponentially. Quantum computing lies at the intersection of quantum physics and high-end computer technology, and in more than one way, hold the key to our AI-driven future.

Quantum computing requires state-of-the-art tools to perform high-end computing. This is where TPUs come in handy. TPUs or Tensor Processing Units are custom-built ASICs (Application Specific Integrated Circuits) to execute machine learning tasks efficiently. TPUs are specific hardware developed by Google for neural network machine learning, specially customised to Google’s Machine Learning software, Tensorflow.

The liquid-cooled Tensor Processing units, built to slot into server racks, can deliver up to 100 petaflops of compute. It powers Google products like Google Search, Gmail, Google Photos and Google Cloud AI APIs.

#opinions #alphabet #asics #floq #google #google alphabet #google quantum computing #google tensorflow #google tensorflow quantum #google tpu #google tpus #machine learning #quantum computer #quantum computing #quantum computing programming #quantum leap #sandbox #secret development #tensorflow #tpu #tpus

Ethan Hughes

Ethan Hughes

1578913982

A Vue Autocomplete Component That Abbreviations

Abbreviation-Autocomplete

A Vue Autocomplete component that autocompletes abbreviations/acronyms by description rather than the abbreviation text.

Props

data

The autocomplete options

The options are an array of objects in the form

{
  a: "Abbreviation or Acronym",
  d: "Definition or Description"
}

e.g.

[
  {
    a: "ATL",
    d: "Hartsfield–Jackson Atlanta International Airport"
  },
  {
    a: "LAX",
    d: "Los Angeles International Airport"
  }
]

limit(Optional)

The autocomplete results limit
Infinity by default

min-input-length(Optional)

The minimum number of characters typed before autocomplete results are displayed
1 by default

JS
const autocomplete = new Vue({
  el: '#app',
  data: {
    abbreviations: [
      {
        a: 'AF',
        d: 'Afghanistan'
      },
      {
        a: 'AL',
        d: 'Albania'
      },
      {
        a: 'DZ',
        d: 'Algeria'
      },
      {
        a: 'AS',
        d: 'American Samoa'
      },
      {
        a: 'AD',
        d: 'Andorra'
      },
      {
        a: 'AO',
        d: 'Angola'
      },
      {
        a: 'AI',
        d: 'Anguilla'
      },
      {
        a: 'AQ',
        d: 'Antarctica'
      },
      {
        a: 'AG',
        d: 'Antigua and Barbuda'
      },
      {
        a: 'AR',
        d: 'Argentina'
      },
      {
        a: 'AM',
        d: 'Armenia'
      },
      {
        a: 'AW',
        d: 'Aruba'
      },
      {
        a: 'AU',
        d: 'Australia'
      },
      {
        a: 'AT',
        d: 'Austria'
      },
      {
        a: 'AZ',
        d: 'Azerbaijan'
      }
    ]
  }
})

Template
<abbreviation-autocomplete :data="abbreviations" :limit="10" :min-input-length="2"></abbreviation-autocomplete>

Demo

Download

#vue #vue-autocomplete #autocomplete-abbreviations #vue-js