1

I need a way to request a particular ID from google places then return the data from that place to show the reviews using JavaScript.

I have found some code that does it on a google map but what I want is just the plain data so I can display it a testimonial-like format on a website.

Any idea how I can do this?

1 Answer 1

1

I believe you are looking for the Place Details endpoint for the Places API Web Service.

Hit the endpoint like so:

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

Parameters will be a string containing your access key, PlaceID, and (optionally) the desired response data type.

The output will be either json or XML, according to what you specify in your parameters. In the response there should be an array in the result object called 'reviews'.

Display and use the reviews as you would any other array of data you need in your application.

The documentation for this endpoint, linked above, is very helpful. If you need to locate the ID of a particular place in order to use the above endpoint, check out Place Search Endpoint.

7
  • Thanks, this is a helpful start, could you possibly give me an example of what the parameters would look like, or how to format them?
    – Ryan Mc
    Feb 10, 2017 at 19:13
  • Sure, to request a json object you would send an HTTP Get Request structured like so:https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJN1t_tDeuEmsRUsoyG83frY4&key=YOUR_API_KEY Feb 10, 2017 at 19:24
  • Thanks, I did that using the link you provided but I can't seem to get a request object back. I get an error message saying 'No 'Access-Control-Allow-Origin' header is present on the requested resource.' I'm using MAMP on localhost. Any ideas?
    – Ryan Mc
    Feb 10, 2017 at 19:29
  • It may be easiest to use jQuery.getJSON Request the JSON object. Feb 10, 2017 at 19:30
  • Is your API Key registered and plugged in? When you load content across hosts sometimes content is blocked to prevent XSS. That type of error is independent of your particular use-case, so you will be able to leverage answers on No-Access-Control-Allow-Origin elsewhere on SO to solve that problem. Feb 10, 2017 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.