A NuxtJS module to import Google maps script
- npm
- NuxtJS
- NodeJS
$ npm install --save nuxt-google-maps-module
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',
},
}
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'],
},
);
},
...
}