wellyshen / use-places-autocomplete

😎 📍 React hook for Google Maps Places Autocomplete.

Home Page:https://use-places-autocomplete.netlify.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

JacobGeoGeek opened this issue · comments

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

  • Device: [MacBook Pro]
  • OS: [macOS]
  • Browser: [Chrome]
  • Version: [Chrome: 117.0.5938.92 (Official Build) (x86_64)]

Additional Information

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

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

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

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