获取 Google 附近搜索的 JSON

2023-12-12

我正在尝试获取 Google Places API 附近搜索的结果 json。我收到此错误:“请求的资源上不存在 Access-Control-Allow-Origin 标头。”
我正在使用的代码是:

<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>
I even posted the url on jsonlint.com website and it gave me the correct json, but I don't get why it doesn't work on my browser

不要使用地点网络服务来自 javascript 的 api,使用地方图书馆.

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

  • 问题 8779:Google 放置搜索 API
  • 问题 8477:错误:地点详细信息 API 缺少 CORS 标头
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

获取 Google 附近搜索的 JSON 的相关文章

随机推荐