react-geocode icon indicating copy to clipboard operation
react-geocode copied to clipboard

add fromPlaceId function

Open bicf opened this issue 2 years ago • 4 comments

To allow to get geocode infos using the place_id string

bicf avatar Sep 06 '23 13:09 bicf

Hi @bicf,

Thank you for your PR! I appreciate the updates to the source file. Could you also consider updating the library folder for consistency? Let me know if you need any guidance.

shukerullah avatar Sep 08 '23 11:09 shukerullah

Hi @bicf,

Thank you for your PR! I appreciate the updates to the source file. Could you also consider updating the library folder for consistency? Let me know if you need any guidance.

Hi @shukerullah yes, absolutely! I've actually already tried to update the library folder, but I'm quite new to the node ecosystem, so a little guidance will be appreciated.

Please let me know the tool you've used to build the lib file.

bicf avatar Sep 11 '23 08:09 bicf

Thanks @bicf and @ivan-redooc for your start on this! I've further enhanced the changes and merged the PR. Could you test it with a fromPlaceId and confirm if it's good to go? If so, can I request closing the ticket?

Here's an example of how to use it:

import { setDefaults, fromPlaceId } from 'react-geocode';

setDefaults({
  key: 'YOUR_API_KEY', // Replace with your API key
  language: 'en', // Default language for responses
  region: 'es' // Default region for responses
});

fromPlaceId('ChIJd8BlQ2BZwokRAFUEcm_qrcA')
  .then(({ results }) => {
    const { lat, lng } = results[0].geometry.location;
    console.log(lat, lng);
  })
  .catch(console.error);

Appreciate your help! 😊

shukerullah avatar Sep 19 '23 16:09 shukerullah

Thanks @bicf and @ivan-redooc for your start on this! I've further enhanced the changes and merged the PR. Could you test it with a fromPlaceId and confirm if it's good to go? If so, can I request closing the ticket?

Yes

The sample code is correct!

bicf avatar Sep 19 '23 22:09 bicf