ubilabs / google-maps-react-hooks

The JavaScript library to easily implement a Google Maps map into your react application. It comes with a collection of React hooks to access the map instance or different Maps JavaScript Services.
MIT License
77 stars 13 forks source link

geocoder?.geocode returns undefined #142

Open architectDrivenKenny opened 10 months ago

architectDrivenKenny commented 10 months ago
const geocoder = useGeocodingService();

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

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

chwoozy commented 10 months ago

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

Yrll21 commented 8 months ago

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