google-maps-react-hooks icon indicating copy to clipboard operation
google-maps-react-hooks copied to clipboard

geocoder?.geocode returns undefined

Open iamk3nnyt opened this issue 2 years ago • 3 comments

const geocoder = useGeocodingService();

const handleOnClick = async () => {
  const x = await geocoder?.geocode({
    location: { lat: 59.27240992362248, lng: 15.213029186736854 },
  });
  console.log(x?.results); //undefined
};

iamk3nnyt avatar Sep 17 '23 11:09 iamk3nnyt

In what context did you used this code? Did you have set up the provider (referring to https://github.com/ubilabs/google-maps-react-hooks/issues/143) correct and did you read teh documentaion about the hooks?

Here you can find the example for the geocoding service. https://github.com/ubilabs/google-maps-react-hooks/tree/develop/examples/geocoding-service

yfr avatar Sep 19 '23 09:09 yfr

Hi, I'm also facing this issue right now. The provider is set up correctly on my end. But this issue seems to be happening when it is ran on useEffect for the first load.

In what context did you used this code? Did you have set up the provider (referring to #143) correct and did you read teh documentaion about the hooks?

Here you can find the example for the geocoding service. https://github.com/ubilabs/google-maps-react-hooks/tree/develop/examples/geocoding-service

chwoozy avatar Sep 19 '23 10:09 chwoozy

The sample code above did not seem to define the parameters for geocode() method which could have caused the "undefined".

Yrll21 avatar Nov 14 '23 01:11 Yrll21