Home » excel » javascript – How to obtained Google Place ID?

javascript – How to obtained Google Place ID?

Posted by: admin April 23, 2020 Leave a comment

Questions:

I’ve tried using Google Maps API connecting to Microsoft PowerBI with the following Web connector method: https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=54.77614759999999,-1.5605721&radius=2000&type=restaurant&key=INSERT_API_KEY

But this is a “Place Search” and doesn’t bring any details such as website or phone numbers etc. To include a “Detail Search” I have to use JavaScript function mentioned in this topic: Google Places API – Places detail request undefined

I have both PowerBI and Visual Studio but just not used to JavaScript.

How to&Answers:

The Google Places API endpoint for Place Details is at

https://maps.googleapis.com/maps/api/place/details/output?parameters

For example,

https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJN1t_tDeuEmsRUsoyG83frY4&key=YOUR_API_KEY

where placeid can be obtained from the Place Search API you used before.

How to automate the process programmatically, whether by JavaScript, VBA or Power BI is up to you, and also depends on how you want to make use of the data afterwards.

Answer:

You should use some KML-CSV parser to have opportunity to open it with Excel

Here I found one, and it seems works

Answer:

Are you not trying to do anything that would be against the API Terms of Service?

https://developers.google.com/maps/terms#section_10_5

10.5 Intellectual Property Restrictions.

d. No caching or storage. You will not pre-fetch, cache, index, or store any Content to be used outside the Service, except that you may store limited amounts of Content solely for the purpose of improving the performance of your Maps API Implementation due to network latency (and not for the purpose of preventing Google from accurately tracking usage), and only if such storage:

  1. is temporary (and in no event more than 30 calendar days);
  2. is secure;
  3. does not manipulate or aggregate any part of the Content or Service; and
  4. does not modify attribution in any way.

e. No mass downloading. You will not use the Service in a manner that gives you or a third party access to mass downloads or bulk feeds of any Content. For example, you are not permitted to offer a batch geocoding service that uses Content contained in the Maps API(s).

Answer:

To get a place ID from Google API, your request URL is like this:
https://maps.googleapis.com/maps/api/geocode/json?address=PLACE_ADDRESS&key=YOUR_API_KEY

Replace these two variables: ‘PLACE_ADDRESS’ and ‘YOUR_API_KEY’ with your specific details.

The result returned will be a JSON string which contains the “place_id” among other details as seen below.

enter image description here