@pderas/vue2-geocoder

A vue 2 plugin to interact with google maps api
18,717 14
Install
npm install @pderas/vue2-geocoder
Latest Version:1.1.0
License:MIT
Last Updated:Nov 19, 2020
Links: GitHub  ·  npm
Maintainer: reed-jones

Vue Geocoder

A vue.js plugin to interact with Google Maps API.

How to initialize Vue Geocoder

A vue 2 plugin to interact with google maps api that will query the google maps API to retrieve location results.

import Geocoder from "@pderas/vue2-geocoder";

Vue.use(Geocoder, {
    defaultCountryCode: null, // e.g. 'CA'
    defaultLanguage:    null, // e.g. 'en'
    defaultMode:        'address', // or 'lat-lng'
    googleMapsApiKey:   GOOGLE_MAPS_API_KEY
});

Usage

General usage: Vue.$geocoder.[FUNCTION_NAME]

Address Example
Vue.$geocoder.setDefaultMode('address');      // this is default
var addressObj = {
    address_line_1: '1600 Amphitheatre Parkway',
    address_line_2: '',
    city:           'Mountain View',
    state:          'CA',               // province also valid
    zip_code:       '94043',            // postal_code also valid
    country:        'United States'
}
Vue.$geocoder.send(addressObj, response => { console.log(response) });

Its important to note that even if your country is set in the address object to the specified country, it is still possible to pull results from other countries. If you want to limit the results to a specific country, you must set the country code in the geocoder.

Vue.$geocoder.setDefaultCountryCode('CA');

Click here for Country Codes

Lat Lng Example
Vue.$geocoder.setDefaultMode('lat-lng');
var latLngObj = {
    lat: 37.421512,
    lng: -122.084101
}
Vue.$geocoder.send(latLngObj, response => { console.log(response) });
Language

To get result in your language you should set language code in the geocoder

Vue.$geocoder.setDefaultLanguage('en') // this is default

License

This project is covered under the MIT License. Feel free to use it wherever you like.

Related Packages

vue2-modal

An easy to use vue 2 modal component for showing and hiding modals

3,938 5
googlemaps-vue3

Google Maps Javascript Library Api For Vue.js 3

2,235 17
mp-gmap

Vue google maps components library

969
vue-custom-google-autocomplete

Custom your Google Autocomplete search

1,777 32
vue-adsense

Google Adsense for Vue

1,329 77

Version History

Version Released License
1.1.0 MIT
1.0.2 MIT
1.0.1 MIT
1.0.0 MIT