我正在尝试获取 Google Places API 附近搜索的结果 json。我收到此错误:“请求的资源上不存在 Access-Control-Allow-Origin header 。”
我使用的代码是:
<html>
<head>
<title>Place searches</title>
<script type="text/javascript" src="lib/jquery-2.1.1.min.js"></script>
<script>
var mJson = "http://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=cruise&key=AIzaSyCy639YCvWAzb3Sx0wkMzO5gxG-nHei4QU";
$.getJSON(mJson,function(data){
console.log(data);
});
</script>
</head>
<body>
<h1>Google places test</h1>
</body>
</html>
最佳答案
不要使用 Places web service来自javascript的api,使用Places Library .
问题跟踪器中的相关问题(标记为“WorkingAsIntended”):
关于javascript - 获取 Google Places Nearby Search 的 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34028977/