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

This module needs the ability to remove the location bias from the autocomplete. #88

Closed
chapeljuice opened this issue Sep 26, 2017 · 9 comments

Comments

@chapeljuice
Copy link

I have a web app using the Google Places Library Autocomplete service. In it, we are able to remove the location bias from the search so autocomplete does NOT have a bias around the users current location.

Here is the url for that documentation:
https://developers.google.com/maps/documentation/javascript/places-autocomplete

Here is the relevant section I'm referencing:
screen shot 2017-09-26 at 8 44 20 am

This the snippet we use for that web app:

var defaultBounds = new google.maps.LatLngBounds(
  new google.maps.LatLng(-90,-180),
  new google.maps.LatLng(90,180)
);
var headerSearchInput = document.getElementById( 'headerSearchInput' );
var options = {
  bounds: defaultBounds
};
autocomplete = new google.maps.places.Autocomplete( headerSearchInput, options );

I would like to do the same for the RNGooglePlaces.openAutocompleteModal() function.

Is that possible?

I didn't see a LatLngBounds option or configuration anywhere in this module.

My versions, for clarity:

"react": "^16.0.0-alpha.6",
"react-native": "0.44.0",
"react-native-google-places": "^2.1.0",
@tolu360
Copy link
Owner

tolu360 commented Sep 26, 2017

Hi @chapeljuice, there are a few other params you can pass to openAutocompleteModal(), a latitude and longitude (to set bounds) are one of them. Go through the README again or just go here to quickly grab those other params.

@chapeljuice
Copy link
Author

chapeljuice commented Sep 26, 2017

@tolu360, thanks for the reply. I read the README and the docs. I don't want to search around a single point with a radius. I want to eliminate the location bias entirely using the same LatLngBounds functionality that is available in the Google Places library. If you look at my post above it doesn't use a single lat & long point, nor a radius.

Any way to REMOVE of the location bias?

@tolu360
Copy link
Owner

tolu360 commented Sep 26, 2017

Funnily enough Ryan, I think we are referring to the same functionality (if you check the source). And yes, you can set the bounds to a region with a set of latlng coordinates but so can you with just a single latlng. E.g. glance through how this is done on Android - see Bias results to a specific region. Similar methods are provided on iOS too.

Perhaps I would provide support for an array of latlng in a future update. PRs are fine too.

@chapeljuice
Copy link
Author

Hrm, apologies, I guess I don't know what you mean there. Do you have a code example of how I could achieve this?

This is what I'm currently using to search with autocomplete:

RNGooglePlaces.openAutocompleteModal()
  .then((place) => {
    this.setState({
      searchButtonText: place.address,
      searchPlacesLat: place.latitude,
      searchPlacesLong: place.longitude,
      searchPlacesName: place.name,
      lazyload: false,
      searchType: 'search'
    })
    this.searchByGeolocation(place.latitude, place.longitude, place.name, this.state.ciDate, this.state.coDate)
  })
  .catch(error => console.log(error.message))

So my question is what would that look like removing the location bias, and using the entire earth for autocomplete search? What would I put in-between the openAutocompleteModal parens?

Thanks a lot for your help and replies, btw. I really appreciate it, and love the module!

@tolu360
Copy link
Owner

tolu360 commented Sep 26, 2017

To be clear, right now you can only bias to a single latlng, I would add support for multiple latlng as bounds in a future update - in the meantime, you can do something like this:

RNGooglePlaces.openAutocompleteModal({
	  type: 'establishment',
	  country: 'CA',
	  latitude: 53.544389,
	  longitude: -113.490927,
	  radius: 10
  })
    .then((place) => {
    console.log(place);
    })
    .catch(error => console.log(error.message));

All params are optional

@chapeljuice
Copy link
Author

I see, okay, so this is not possible at the moment. Thanks for replying and confirming. Would be awesome to get in a future update, not sure how difficult that would be for someone. I don't think I have the native skills to pull it off.

@tolu360
Copy link
Owner

tolu360 commented Sep 26, 2017

Not a problem, I'd add that in but you'd be surprised what you can pull off by just having a go at it!

Stay tuned for the update. Cheers!

@chapeljuice
Copy link
Author

Any update here?

@tolu360
Copy link
Owner

tolu360 commented Mar 11, 2019

Better late than never, please see the changes in the very latest beta release, see #198

@tolu360 tolu360 closed this as completed Mar 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants