I have faced an issue with my Google Map API while getting nearest places.
Code:
var headers = {
'Access-Control-Allow-Origin' : '*',
'Content-Type': 'application/json'
};
var req = {
method: 'GET',
url: 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=cruise&key=AIzaSyCLf2OhSgKKOju1hpUBirFtZ-W26zObyVI?sensor=false',
headers: headers
}
$http(req).success(function(d) {
alert(d)
});
Error:
XMLHttpRequest cannot load https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8…=food&name=cruise&key=AIzaSyCLf2OhSgKKOju1hpUBirFtZ-W26zObyVI?sensor=false. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access. The response had HTTP status code 405.
var headers = {
'Access-Control-Allow-Origin' : '*',
'Content-Type': 'application/json'
};
var req = {
url: 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=cruise&key=AIzaSyCLf2OhSgKKOju1hpUBirFtZ-W26zObyVI?sensor=false',
headers:headers
}
$http.get(req.url,header).success(function(d){
alert(d)
});