vue-gmaps
Version:
Vue.js plugin that allow search address and places using Google Maps API
85 lines (57 loc) • 2.43 kB
Markdown
# Vue-Gmaps
> Search address and places using Google Maps API
[](https://travis-ci.org/Ridermansb/vue-gmaps)
[](https://www.bithound.io/github/Ridermansb/vue-gmaps) [](https://github.com/semantic-release/semantic-release) [](http://commitizen.github.io/cz-cli/)
[](https://nodei.co/npm/vue-gmaps?downloads=true&stars=true)

## Installation
```bash
npm i -S vue-gmaps
```
And in your `main.js` ...
```javascript
// main.js
import VueGmaps from 'vue-gmaps'
Vue.use(VueGmaps, {
key: '<your api here>'
})
```
Options are:
* **key** <Required!>,
* **libraries** <Default= [ 'places' ]>,
* **client**
* **version** <Default='3'>,
* **loadGoogleApi** <Default=true>
libraries: ['places'],
version: '3'****
## Basic usage
Add the directive `v-gmaps-searchbox` into your input
```html
<input v-model=vm.searchPlace v-gmaps-searchbox=vm>
```
This will popule your `vm.place` object with details about selected place.
## Features
### Specify property
By default, `vm.place` is used, you can change this passing an argument to directive e.g `:anotherProperty`
```html
<input v-gmaps-searchbox:myProperty=vm>
```
So `vm.myProperty` will be filled with details about selected place
### Specify whats fields
All information about place is put is filled, to determinate whats fields should be use, you can specify a modifiers like this `.name.website.formatted_address.geometry`
```html
<input v-gmaps-searchbox:myProperty.name.website.formatted_address.geometry=vm>
```
So your `vm` will set property `myProperty` like this
```javascript
{
myProperty: {
name: <value_from_result>,
website: <value_from_result>,
formatted_address: <value_from_result>,
geometry: <value_from_result>,
}
}
```
*[Click here to subscribe and get more about Vue.js][0]*
[0]: https://www.getrevue.co/profile/ridermansb