Skip to content

WilliamDASILVA/nuxt-google-maps-module

Repository files navigation

Nuxt Google Maps Module

npm (scoped with tag) npm js-airbnb-style

A NuxtJS module to import Google maps script

Table of Contents

Requirements

  • npm
  • NuxtJS
  • NodeJS

Install

$ npm install --save nuxt-google-maps-module

Getting Started

Add nuxt-google-maps-module to modules section of nuxt.config.js.

{
  modules: [
    // Simple usage
    'nuxt-google-maps-module',

    // With options
    ['nuxt-google-maps-module', {
      /* module options */
      key: 'GOOGLE MAPS KEY', // Default
    }],
 ]
}

or even

{
  modules: [
    'nuxt-google-maps-module',
  ],
  maps: {
    key: 'GOOGLE MAPS KEY',
  },
}

Usage

Once configured in nuxt.config.js, you can use it in your components like:

{
  ...
  mounted() {
    const autocomplete = new this.$google.maps.places.Autocomplete(inputElement,
      {
        types: ['geocode'],
      },
    );
  },
  ...
}

License

MIT License