KolisbikBoh
KolisbikBoh

Reputation: 85

How dynamically change google map language?

Please tell me how to dynamically update the language in google maps after the site language has been changed?

My main.js:

const { lang } = localStorage.getItem('lang') || 'en';
Vue.use(VueGoogleMaps, {
  load: {
    key: config.TOKEN_GOOGLE,
    language: lang,
    libraries: ['places', 'visualization']
  }
});
....

My map wrap componet:

...
<div style="position: relative;">
        <GMap
            :project="project"
            :devices="projectDevices"
            :trackers="trackers"
            :lang="lang"
            @dragend="changeDevicePosition"
            :filterZoom="filterZoom"
            :marker-focused="markerFocused"
            :projectProperties="projectProperties"
            :devicesProperties="devicesProperties"
            :editProp="edit"
        />
      </div>

As far as I understand after Vue.use the component that contains the map is no longer updated, how to get around it?

Maybe something like that:

watch: {
    lang(prev, next) {
      Vue.use(VueGoogleMaps, {
        language: next
      })
    }
  }

Upvotes: 0

Views: 1183

Answers (0)

Related Questions