Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering by types does not work #686

Open
3 tasks
tgreco opened this issue Jan 15, 2021 · 5 comments
Open
3 tasks

Filtering by types does not work #686

tgreco opened this issue Jan 15, 2021 · 5 comments

Comments

@tgreco
Copy link

tgreco commented Jan 15, 2021

Describe the bug

I am trying to filter by schools using the GooglePlacesSearchQuery property but it does not have any affect.

Reproduction - (required - issue will be closed without this)

  
  <GooglePlacesAutocomplete
          placeholder='Search'
          currentLocation={true}
          currentLocationLabel='Current location'
          enablePoweredByContainer={false}
          fetchDetails={true}

          onPress={(data, details = null) => {
            // 'details' is provided when fetchDetails = true
            console.log(data, details);
          }}
          query={{
            key: '****',
            language: 'en',
          }}
          GooglePlacesSearchQuery={{
            type: 'primary_school|school|secondary_school'
          }}
        />

Additional context

  • Library Version: 2.1.2

  • React Native Version: 0.63.2

  • [ X] iOS

  • Android

  • Web

  • I am using expo

image

@tgreco tgreco added the bug label Jan 15, 2021
@bell-steven
Copy link
Collaborator

Thanks for the bug report. I can confirm that it doesn't work as expected.

PRs welcome!

@fruityperson
Copy link
Contributor

I had the same problem with filtering by type address.

<GooglePlacesAutocomplete
      placeholder="Vyhledat adresu"
      onPress={async (data, details) => {
        ...
      }}
      query={{
        key: "...",
        language: "cs",
        components: "country:cz",
        types: "address",
      }}
    />

Results included cities, companies, etc. instead of just addresses.

I found a typo in the library in GooglePlacesAutocomplete.js line 512(?& in params instead of ?):

`${url}/place/autocomplete/json?&input=` +

should be

`${url}/place/autocomplete/json?input=` +

This fixed my problem.

Will be opening a pull request with a fix.

fruityperson pushed a commit to fruityperson/react-native-google-places-autocomplete that referenced this issue Feb 3, 2021
replaced ?&input with ?input, this should fix filtering by type FaridSafi#686
@nescroft
Copy link

nescroft commented Feb 9, 2021

i was able to get it working with cities by adding the fix @fedor-moiseev recommended and using query={{ types: '(cities)',}} in

bell-steven pushed a commit that referenced this issue Mar 23, 2021
replaced ?&input with ?input, this should fix filtering by type #686
@esmailbenmoussa
Copy link

esmailbenmoussa commented Jan 10, 2022

I'm having the same issue with

query={{type: "restaurant"}}

any workarounds on this?

@ProgrammedForAdventure
Copy link

Some of these issues may be because of invalid place types, such as "restaurants". According to the Google Autocomplete API, you're limited to a subset of Place 'types' you can refer to: https://developers.google.com/maps/documentation/places/web-service/autocomplete#types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants