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

Wrong query parameters #49

Open
saikatharryc opened this issue May 30, 2019 · 5 comments
Open

Wrong query parameters #49

saikatharryc opened this issue May 30, 2019 · 5 comments

Comments

@saikatharryc
Copy link
Contributor

i'm trying to get only nearby places in the search result, not the result from anywhere in the world.

i guess people are using radious option for that .
here is one related stackoverflow topic.

can we do that using this package?
i'm using this in a large project.

@cedricdelpoux
Copy link
Owner

Hello @saikatharryc,

That is right, you can use radius.

<ReactGooglePlacesSuggest
    googleMaps={googleMaps}
    autocompletionRequest={{
        input: search,
        radius: YOUR_RADIUS,
    }}
    ...
/>

For more, please checkout https://developers.google.com/maps/documentation/javascript/reference/places-autocomplete-service?hl=fr#AutocompletionRequest

@web3rover
Copy link

@xuopled radius is not working. Here is code example:

<ReactGooglePlacesSuggest
                                        name="boardingPoint"
                                        autocompletionRequest={{
                                            input: this.state.boardsearch,
                                            radius: 1000 * 40,
                                            location: new mapApi.LatLng(this.state.currentLocation.lat, this.state.currentLocation.lng),
                                            strictbounds: true
                                        }}
                                        googleMaps={mapApi}
                                        onSelectSuggest={this.addBoardingPlace.bind(
                                            this
                                        )}
                                    >

The API call it makes doesn't have correct query parameters. Here is the URL:

https://maps.googleapis.com/maps/api/place/js/AutocompletionService.GetPredictionsJson?1sdraper%20uni&4sen-GB&6m6&1m2&1d21.183053886352194&2d38.81165817965143&2m2&1d21.90170611364781&2d39.58428182034845&15e3&21m1&2e1&callback=_xdc_._ipi1sd&key=AIzaSyAs2LAkFCJr8p4EzgIVtk169Qreykfi74Q&token=86999

It should have looked something like this:

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=hotel&key=AIzaSyAs2LAkFCJr8p4EzgIVtk169Qreykfi74Q&radius=2000&location=37.564,-122.32553&strictbounds=true

@cedricdelpoux
Copy link
Owner

It's very strange because, no transformation are applied before sending to Google Autocomplete API.
Feel free to investigate et open a PR if you found something.

@cedricdelpoux cedricdelpoux reopened this Jun 3, 2019
@cedricdelpoux cedricdelpoux changed the title [Question] how to put radius as an option Wrong query parameters Jun 3, 2019
@AcidRaZor
Copy link

AcidRaZor commented Jul 8, 2019

@saikatharryc & @narayanprusty you can use "components" to restrict it to a specific country (up to 5 https://developers.google.com/places/web-service/autocomplete) if you don't necessarily want to specify the radius and/or direct location. Hopefully that helps while the bug is investigated

/edit Apologies, it seems that no optional parameters are passed through

@ftruzzi
Copy link

ftruzzi commented Oct 8, 2020

Not sure if help is still needed, but I'm using a similar library (https://github.com/Giners/mui-places-autocomplete) and I ran into the same issue.

If you refer to this documentation it says the radius property also requires the location property to be set.

I think you can refer to this other documentation if you call the mentioned API URL directly without using the google.maps.places.AutocompletionRequest interface of the maps API library (which I believe this library is doing) that also supports more filters.

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

5 participants