0
var placesAPI = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=32.8400,-117.2769&radius=500&types=museum&sensor=true&key=my_key_here";
$.getJSON(placesAPI, function (json) {
    var address = json.results[0].name;
    console.log('Name : ', name);
});

I am trying the above code with no success. I do put in my API key and I get the json results on the webpage but when I try to parse them I get an error "No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. "

How do I parse the JSON?

1

1 Answer 1

0

Try the code below. I added &callback=? to your url as per the instruction is the following post.

var placesAPI = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=32.8400,-117.2769&radius=500&types=museum&sensor=true&key=my_key_here&callback=?";
$.getJSON(placesAPI, function (json) {
    var address = json.results[0].name;
    console.log('Name : ', name);
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.