gpt4 book ai didi

javascript - 获取 Google Places Nearby Search 的 JSON

转载 作者:行者123 更新时间:2023-11-30 09:55:53 25 4
gpt4 key购买 nike

我正在尝试获取 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>
我什至在 jsonlint.com 网站上发布了 url,它给了我正确的 json,但我不明白为什么它在我的浏览器上不起作用

最佳答案

不要使用 Places web service来自javascript的api,使用Places Library .

问题跟踪器中的相关问题(标记为“WorkingAsIntended”):

关于javascript - 获取 Google Places Nearby Search 的 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34028977/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com