Google offers different ways to use the Place Autocomplete API. Two of these being the Autocomplete and AutocompleteService classes. Whenever I use the Autocomplete class I get the address components without a problem. However, whenever I use the AutocompleteService the address components are missing. I do get an address but not in the same way I do with Autocomplete (I can parse into city, street, state, etc.).
Is there a way I can get the address components field using AutocompleteService WITHOUT making an additional call with the place ID ?
Autocomplete example
function initAutocomplete() { autocomplete = new google.maps.places.Autocomplete(document.getElementById('search'), { componentRestrictions: { country: ["us", "ca"] }, fields: ["address_components", "geometry"], types: ["address"], }); autocomplete.addListener("place_changed", () => { const place = autocomplete.getPlace(); // Includes Address Components and Geometry (Lat and Lng) }); } AutocompleteService example
function initAutocompleteService() { const service = new google.maps.places.AutocompleteService(); service.getPlacePredictions({ input: "1600 Amphitheatre", componentRestrictions: { country: 'us' }, types: ['address'] }, (predictions, status) => { console.log(predictions); // It shows the address a single string but missing address components }); }