【发布时间】:2012-09-30 19:35:00
【问题描述】:
我正在尝试以 JSON 格式从 Google Places API 检索地点列表。我正在发送 AJAX 请求。
GET 请求发送正确的参数并收到 200 OK 成功消息,但没有响应(每个 firebug)。
您知道如何检索 JSON 中的地点列表或将 JSONP 转换为 JSON 吗?
photos.js
$.ajax({
type: 'GET',
url:'https://maps.googleapis.com/maps/api/place/search/json',
dataType: 'json',
data: {
'location' : data.location.latitude+","+data.location.longitude,
'radius' : 500,
'key' : "mykeyhere",
'sensor' : "false",
'keyword' : "hotel"
},
success: function(hotel){
console.log(hotel);
}
});
我尝试将 dataType 更改为 jsonp 并且我能够得到所有列表的响应,但我收到 "html_attributions" : [] 错误,因为它需要 JSON。响应如 https://developers.google.com/places/documentation/search 中所述,但我得到一个无法识别html_attributions的firebug错误
【问题讨论】:
-
您是否尝试过改用 Google Maps JavaScript API V3 的 Places Library?
-
我也有同样的问题 :( 那是我的问题stackoverflow.com/questions/12660723/…
标签: javascript ruby-on-rails-3 jquery google-places-api