wellyshen / use-places-autocomplete

😎 📍 React hook for Google Maps Places Autocomplete.
https://use-places-autocomplete.netlify.app
MIT License
1.25k stars 63 forks source link

Bounds, location, and radius in the Maps JavaScript API Place Autocomplete Service (Deprecated as of May 2023) #1135

Open JacobGeoGeek opened 11 months ago

JacobGeoGeek commented 11 months ago

Bug Report

When I am using the usePlacesAutocomplete, a waning appears in my browsing console:

places_impl.js:15 As of May 2023, bounds, location, and radius are deprecated. Please use locationBias and locationRestriction instead. The feature will continue to work, and 12 months notice will be given before support is discontinued. See https://developers.google.com/maps/deprecations for more information.

How to Reproduce

Add the following code and create a widget to search an address (like a AutoComplete input):

  const defaultBounds = new window.google.maps.LatLngBounds(
    new window.google.maps.LatLng(44.306576, -79.372785),
    new window.google.maps.LatLng(62.683234, -57.905501)
  )

  const {
    ready,
    value,
    setValue,
    suggestions,
    clearSuggestions
  } = usePlacesAutocomplete({
    requestOptions: {
      componentRestrictions: { country: "ca" },
      bounds: defaultBounds
    }
  })

Your Environment

Additional Information

Perhaps an update is necessary to support the new attributes: locationBias and locationRestriction.

wellyshen commented 11 months ago

@JacobGeoGeek You can pass any valid properties into the requestOptions, I think they should just work.

eliawk commented 10 months ago

@wellyshen componentRestrictions: { country: 'us' }doesn't work

bcaylor10 commented 8 months ago

Any update on this? This is a big requirement, and I will have to move to another library if I cannot filter by country through the request itself