javascriptgoogle-mapsgoogle-nearby

Google Maps nearby search returning Invalid_Request


I am trying to connect to google maps using the following url and code to fetch nearby places, but I am getting invalid request. What seems to be the issue here?

let url = 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=...&location=49.1804488%2C-122.7851227'
let results = await axios.get(url)
console.log(results.data)
console.log(results.status)
console.log(results.error_message)
console.log(results.info_messages)

Solution

  • The documentation says that only location is required. That seems to be wrong, adding radius to the query returns a result.

    This works:

    https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=49.1804488%2C-122.7851227&radius=1500&key=API_KEY

    This doesn't work (returns "status" : "INVALID_REQUEST"):

    https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=49.1804488%2C-122.7851227&key=API_KEY