xkjyeah / vue-google-maps

Google maps component for vue with 2-way data binding
https://xkjyeah.github.io/vue-google-maps/
1.88k stars 475 forks source link

Change autocomplete language dynamically #281

Open VerhoevenWout opened 6 years ago

VerhoevenWout commented 6 years ago

Hi there, I'm working on a multi-language website and want to set the autocomplete language dynamically. Is this possible?

Currently my code looks like this: Vue.use(VueGoogleMaps, { load: { key: 'XXX', libraries: 'places', language: 'fr', } }); Vue.component('gmap-autocomplete', VueGoogleMaps.Autocomplete); Vue.component('google-map', VueGoogleMaps.Map);

Can I do something like this? VueGoogleMaps.loaded.then(() => { LANGUAGE SETTING... });

Thanks in advance!

philmillman commented 6 years ago

I don't think this is possible since you need to load a new js file for every country/region

https://github.com/xkjyeah/vue-google-maps/blob/vue2/src/manager.js#L82

If I understand correctly you'll need to reload the plugin whenever the language or region changes so it can load the appropriate localized bundle from Google.

More info here: https://developers.google.com/maps/documentation/javascript/localization

danon commented 5 years ago

So, why can't this feature be implemented?

xkjyeah commented 5 years ago

Because you can only load one JS file per page?

On Sun, 17 Mar 2019 at 21:12, Daniel Wilkowski notifications@github.com wrote:

So, why can't this feature be implemented?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/xkjyeah/vue-google-maps/issues/281#issuecomment-473664455, or mute the thread https://github.com/notifications/unsubscribe-auth/ACiTR6YWUJ9KCwNky5UDhv_G0dy3gyY8ks5vXj8pgaJpZM4RIYzW .

danon commented 5 years ago

And why is that? Conditional es6 imports work fine for me.

xkjyeah commented 5 years ago

Mmm, because we're not loading an ES6 module. We're loading Google Maps' API.

On Sun, 17 Mar 2019 at 21:25, Daniel Wilkowski notifications@github.com wrote:

And why is that? Conditional es6 imports work fine for me.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xkjyeah/vue-google-maps/issues/281#issuecomment-473665659, or mute the thread https://github.com/notifications/unsubscribe-auth/ACiTR-t9G-1L5l-CqfotQ-uGMNaOix7Gks5vXkJegaJpZM4RIYzW .

danon commented 5 years ago

I asked why is that that we can only load one js file?

xkjyeah commented 5 years ago

If you try loading the API twice (once for each different language) Google Maps will Bork. Don't ask me why -- ask Google

On Sun, 17 Mar 2019, 23:07 Daniel Wilkowski, notifications@github.com wrote:

I asked why is that that we can only load one js file?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xkjyeah/vue-google-maps/issues/281#issuecomment-473674417, or mute the thread https://github.com/notifications/unsubscribe-auth/ACiTRxcsDY7GQdVZki8pevqtrZN3X6Wqks5vXlpKgaJpZM4RIYzW .

danon commented 5 years ago

What do you mean it"ll Bork? Return http error code and not return the file?

xkjyeah commented 5 years ago

Dude, why don't you try inserting two lines of Autocomplete into your HTML and let me know? Do you JS?

On Sun, 17 Mar 2019, 23:15 Daniel Wilkowski, notifications@github.com wrote:

What do you mean it"ll Bork? Return http error code and not return the file?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xkjyeah/vue-google-maps/issues/281#issuecomment-473675120, or mute the thread https://github.com/notifications/unsubscribe-auth/ACiTR0CtoxRUIBiiNXzytwvvTSfvTE7-ks5vXlv6gaJpZM4RIYzW .