npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-google-places-api

v0.2.12

Published

Custom your Google Autocomplete search

Downloads

3

Readme

vue-google-places-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-google-places-api
yarn add vue-google-places-api

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-google-places-api'

...

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.

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

<script>
import { BulmaDropdown } from 'vue-google-places-api'

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.

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

<script>
import { BootstrapDropdown } from 'vue-google-places-api'
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