I'm trying to figure out how to use Google Places API. I have read all their documentation. I'm just trying to figure out how to get the data in the JSON response. I'm not trying to output the response to a map. I want to access things like place names, etc.
I was trying to use the $.getJSON jquery function in a previous post I made (http://stackoverflow.com/questions/11642418/trying-to-use-google-places-api-with-jquerys-getjson-function), however I couldn't get the browser to parse the JSON response accordingly, I'm thinking because the JSON response is in a remote server. I'm now trying to use JSONP but I have the same error.
<script type="text/javascript">
function jasonPCall() {
var url = 'https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=****my key****&callback=?';
$.ajax({
type: 'GET',
url: url,
async: false,
jsonpCallback: 'jsonCallback',
contentType: "application/json",
dataType: 'jsonp',
success: function (json) {
console.log("We got a response.");
console.dir(json.results[0].name);
},
error: function (e) {
console.log("We didn't get a response.");
console.log(e.message);
}
});
}
</script>
Is what I'm trying to do possible? If so, how then are you supposed to access the JSON reply data provided by Google Places? Can someone post a simple example of the proper way to do it?