react-native-google-places-autocomplete icon indicating copy to clipboard operation
react-native-google-places-autocomplete copied to clipboard

Need to show only addresses with a house number

Open valin0k opened this issue 4 years ago • 7 comments

Describe the problem

I want to exclude all results without street addresses and home numbers. I tried with different values for filterReverseGeocodingByTypes but each time i received Country, City or something like that in dropdown results. Also i searched solution in google api but didn't find it.

Additional context

react-native-geolocation-service: ^5.3.0-beta.3 react-native-google-places-autocomplete: ^2.4.1

  • Library Version: [e.g. 1.4.2]

  • React Native Version: [^0.65.1]

  • [ ] iOS

  • [ ] Android

  • [ ] Web

If you are using expo please indicate here:

  • [ ] I am using expo

valin0k avatar Oct 06 '21 11:10 valin0k

Could you solve this issue? Im using filterReverseGeocodingByTypes={['establishment','street_address']} but it doesn't work

sirtok4 avatar Jan 21 '22 12:01 sirtok4

@sirtok4 sorry for the long response. Actually no, i have not found any option to do it. Instead of i've added validation that checking that an address includes country name, street name and any number as a street name

valin0k avatar Feb 19 '22 11:02 valin0k

@valin0k thanks for the answer! Yea I found a different way to do it as well

sirtok4 avatar Feb 19 '22 12:02 sirtok4

query={{ "key":"key", "language":"en", "components":"country:us", "sessiontoken":"sessionToken", "type":"address" }}

Adding the type property filters more.

ofkarakus avatar Jun 10 '22 14:06 ofkarakus

@valin0k thanks for the answer! Yea I found a different way to do it as well

Sorry what solution did you find for this?

jenniredfield avatar Mar 09 '23 18:03 jenniredfield

Anyone have a solution for this? "type":"address" still returns addresses with no street/street # and "types": ['street_number', 'street_address'] in the query or GooglePlacesSearchQuery does not work.

enchorb avatar Mar 12 '23 14:03 enchorb

Hi @jenniredfield I dont remember exactly but I guess I ended up formatting the address in the onPress param like this:

onPress={(data, details = null) => {
                var addressName = null, postalCode = null, numberStreet = null;
                if (details.address_components) {
                    for (const obj of details.address_components) {
                        if (obj.types.includes('route')) addressName = obj.short_name;
                        else if (obj.types.includes('street_number')) numberStreet = obj.long_name;
                        else if (obj.types.includes('postal_code')) postalCode = obj.long_name;
                }}
}

sirtok4 avatar Mar 13 '23 11:03 sirtok4