Resume the number address suggestions with google Places Api

Asked

Viewed 128 times

1

I’m using the Google Api for the address search. The api works correctly, but I need the api to return me the data already with the location number.

Currently the api returns me something like: Av. Paulista - Bela Vista, São Paulo - SP, Brazil

I would like that when the user typed "Avenida Paulista" were only displayed the results followed by the number, as for example does Uber and Rappi.

Follow the excerpt of my code where I do the search:

     const options = {
        types: ['address'],
        componentRestrictions: {
            country: ['br']
        }
    }; 

    // Initialize Google Autocomplete
    /*global google*/ // To disable any eslint 'google not defined' errors
    this.autocomplete = new google.maps.places.Autocomplete(
      document.getElementById('autocomplete'),
      options
    );

    // Fire Event when a suggested name is selected
    this.autocomplete.addListener('place_changed', this.handlePlaceSelect);

1 answer

0

What Uber does is use the Place Details.

You need to pass the placeid that you get by making a site search

In the result of this endpoint comes the street number.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.