Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing locale #471

Closed
mrleblanc101 opened this issue Dec 6, 2021 · 3 comments
Closed

Changing locale #471

mrleblanc101 opened this issue Dec 6, 2021 · 3 comments
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@mrleblanc101
Copy link

Environment details

  1. Specify the API: Any
  2. OS type and version: Any
  3. Library version and other environment information: Nuxt.js

Steps to reproduce

  1. Create a Nuxt app
  2. Add @nuxtjs/i18n
  3. Change locale in your application front-end
  4. This error happen: Loader must not be called again with different options.

Code example

    async mounted() {
        const loader = new Loader({
            apiKey: this.$config.googleMapsKey,
            language: this.$i18n.locale,
        });
        const google = await loader.load();
        this.map = new google.maps.Map(this.$el.querySelector('#map'), {
            zoom: 14,
            mapTypeId: 'satellite',
            center: { lat: 46.8259601, lng: -71.2352226 },
            zoomControl: true,
            mapTypeControl: false,
            scaleControl: false,
            streetViewControl: false,
            rotateControl: false,
            fullscreenControl: true,
            tilt: 0,
            gestureHandling: 'cooperative',
            restriction: {
                strictBounds: true,
                latLngBounds: {
                    north: 85,
                    south: -85,
                    west: -180,
                    east: 180,
                },
            },
        });
    },

I don't see any other way to change the locale.

Following these steps will guarantee the quickest resolution possible.

Thanks!

@mrleblanc101 mrleblanc101 added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Dec 6, 2021
@keeratita
Copy link

keeratita commented Dec 7, 2021

what i did for a workaround is to load the script again if locale change detected.

       const loader = new Loader({
            apiKey: this.$config.googleMapsKey,
            language: this.$i18n.locale,
        });

      // this below line is to force remove the private instance in the loader and also remove google instance and also the script
      (Loader as any).instance = null;
      delete window.google;
      loader.deleteScript();

it might not be a good solution but it works for now.

@jpoehnelt
Copy link
Contributor

^ Note that this might have billing implications if you need to recreate map instances.

@jpoehnelt
Copy link
Contributor

duplicate of #210 which is blocked by https://issuetracker.google.com/issues/35819089. please star and upvote that issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants