获取Google Places附近搜索的JSON

时间:2015-12-01 19:56:10

标签: javascript json google-maps google-places-api

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

1 个答案:

答案 0 :(得分:4)

请勿使用javascript中的Places web service api,请使用Places Library

问题跟踪器中的相关问题(标记为&#34; WorkingAsIntended&#34;):

相关问题