Currenty, I\'m using the following code to get the country, postal code, locality and sub-locality:
var country, postal_code, locality, sublocality;
for (i =
I made function before that extracts a list of values given a list of place types:
const getValue = function(data, types=[]){
/* used by results taken from Geocoder.geocode api */
const values = data.reduce((values, address) => {
return address.address_components.reduce((values2, component) => {
if(component.types.reduce((result, type) => result || types.indexOf(type) > -1, false))
values2.push(component.long_name);
return values2
}, []);
if(buff.length)
return [...values, ...buff];
return values;
}, []).filter(
(value, index, self) => {
return self.indexOf(value) === index;
}
);
}