WilliamDASILVA / nuxt-google-maps-module

Inject Google Maps script
MIT License
22 stars 8 forks source link

Language change #14

Open AlxZb opened 4 years ago

AlxZb commented 4 years ago

Hi! 2 questions:

  1. How to pass the lang to map?
  2. If I want to change the lang from a form element, how would it be?

Thanks!

krokodilshnap commented 3 years ago

Please add a language prop to module options! 😭

sarkhanrajabov commented 3 years ago

How do you import component to the template? Please share code with me :)

krokodilshnap commented 3 years ago

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
        });
});
      }
}
}
Quineone commented 3 years ago

Please add a language prop to module options! 😭

Yes, had better add.