react-google-places-autocomplete
react-google-places-autocomplete copied to clipboard
Create ability of changing language request for the utilities
Hello. Thank you for your library. It works great. But there is one problem. I use it in my application the next way:
import GooglePlacesAutocomplete, { geocodeByPlaceId } from "react-google-places-autocomplete";
export const Component = () => {
const handlePickAddress = useCallback(
async (result: any, field: "from" | "to") => {
......
try {
const data = await geocodeByPlaceId(result.value.place_id);
...
} catch (e) {}
},
[],
);
return (
<GooglePlacesAutocomplete
apiKey={GoogleApiKey}
apiOptions={{
language: userLocale,
}}
/>
)
}
And I need to use geocodeByPlaceId
and GooglePlacesAutocomplete
with different languages. For example user uses autocomplete with spanish language, but geocodeByPlaceId
uses english version. It need to save to database only English name of place id.
But for now after initialization GooglePlacesAutocomplete
with particular language I can't to replace it. So can you create a functionality of changing language and other params for utils, as geocodeByPlaceId
, etc.?
I was just about to create an issue requesting the same. Can we add localization for this?
I'm not sure about the geocodeBy* utilities, but for the autocomplete you can set the language on the autocompletion request (see here).