nuxt-google-maps-module
nuxt-google-maps-module copied to clipboard
Language change
Hi! 2 questions:
- How to pass the lang to map?
- If I want to change the lang from a form element, how would it be?
Thanks!
Please add a language prop to module options! 😭
How do you import component to the template? Please share code with me :)
Just add this to nuxt.config.js
['nuxt-google-maps-module', {
/* module options */
key: 'AIzaSyAlOasR7KJ5J851eCdjxgI0_bs6p_6HTMk&language=en', // you can change language here
libraries: ['places', 'geometry'] // additional libraries
}]
Then in your component you can write like this:
<template>
<div ref="map"></div>
</template>
export default {
data() {
return {
map: '',
minZoom: 4,
zoom: 10,
center: {lat: 54, lng: 30}
}
},
mounted() {
if (process.browser) {
window.addEventListener('maps-module:loaded', () => {
this.map = new this.$google.maps.Map(this.$refs.map, { // ref to element in template
center: this.center,
zoom: this.zoom,
minZoom: this.minZoom,
styles: this.mapStyle, // can use your custom map styles
});
});
}
}
}
Please add a language prop to module options! 😭
Yes, had better add.