Closed udrea93 closed 1 year ago
Hi there,
Regarding the city name translation, the API displays results in the specified language if available; otherwise, it uses the language of the original input.
Source: Stack Overflow
Feel free to ask if you have more questions!
import {
setKey,
fromLatLng,
setLanguage,
setRegion,
setLocationType,
} from 'react-geocode';
setKey('AIzaSyDUAzKPR3MoFHwZz7wEYThVptNvnq_cBJY');
setLanguage('en');
setRegion('en');
setLocationType('ROOFTOP');
fromLatLng('48.13512530', '11.58198050')
.then(response => {
if (response.results[0].formatted_address) {
console.log(response.results[0].formatted_address);
const formattedAddressArray =
response.results[0].formatted_address.split(' ');
const getCity = formattedAddressArray[formattedAddressArray.length - 2];
const getCountry =
formattedAddressArray[formattedAddressArray.length - 1];
console.log(getCity + ' ' + getCountry);
}
})
.catch(console.error);
Hello, im using the following code ` Geocode.setLanguage("en"); Geocode.setRegion("en"); Geocode.setLocationType = 'ROOFTOP';
I get München, Germany I should get Munich, Germany The country seems to be translated but what about the city? Thanks!