googlemaps / js-api-loader

Load the Google Maps JavaScript API script dynamically.
Apache License 2.0
354 stars 64 forks source link

Dynamically change the language of Loader #210

Open mcAnastasiou opened 3 years ago

mcAnastasiou commented 3 years ago

Environment details

  1. google.maps.places.AutocompleteService
  2. "@googlemaps/js-api-loader": "^1.11.2",

    Steps to reproduce

    I load the library as follows

    new Loader({
        apiKey: process.env.REACT_APP_GOOGLE_PLACES_API_KEY,
        libraries: ['places'],
        language: selectedLanguage,
    });

    I can dynamically change the language through a dropdown. If i try to reload the library i get an error that says i cannot use the same api key with different params

How can i dynamically change the results of the autocomplete to the desired language?

jpoehnelt commented 3 years ago

Similar to #5, it is not possible to currently change the language after the script has been loaded. There is a very old request for if you want to add your particular use case at https://issuetracker.google.com/35819089. I am hoping to address #5 this year. Language would be a potential followup to that.

In the meantime, I might investigate #100 to allow reloading the entire API, but that might have billing consequences...

Sorry I don't have better news!