nuxt-google-maps-module icon indicating copy to clipboard operation
nuxt-google-maps-module copied to clipboard

Language change

Open AlxZb opened this issue 4 years ago • 4 comments

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!

AlxZb avatar May 07 '20 14:05 AlxZb

Please add a language prop to module options! 😭

krokodilshnap avatar Sep 01 '20 13:09 krokodilshnap

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

sarkhanrajabov avatar Sep 18 '20 11:09 sarkhanrajabov

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
        });
});
      }
}
}

krokodilshnap avatar Sep 18 '20 18:09 krokodilshnap

Please add a language prop to module options! 😭

Yes, had better add.

Quineone avatar Apr 07 '21 11:04 Quineone