地点搜索google.api的处理结果

时间:2018-04-12 02:08:31

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

所以我目前正在开发一个webapp,我将不得不伪造自己的queryString来搜索位置。我在google places api中发现了地方搜索功能。但是,我似乎真的不明白我是如何处理从查询中检索的数据。

 var theUrl = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&type=restaurant&keyword=cruise&key=myHiddenKey";

   $.get(theUrl, function(data, status){
    ...I dont seem to get any results here and I know by 
     definition that there are matches... 
     cause if you run the same query in the searchbar of the browser you get all the matches
   });

如果我想让我们说这些地点的所有名称和位置我将如何进行?

非常感谢帮助

1 个答案:

答案 0 :(得分:0)

我从javascript运行该请求时收到错误:No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin is therefore not allowed access.

如果您想使用javascript中的Places API,请使用Google Maps Javascript API v3 Places Library