调用搜索服务api时
var pyrmont = new google.maps.LatLng(-33.8665433,151.1956316);
var request = { location: pyrmont, radius: '500', types: ['store'] };
service = new google.maps.places.PlacesService(map);
service.search(request, callback);http://maps.google.com/.
--更新--
正如@Trott所建议的,这是我更新的代码,但我在回调函数中得到了status = "ZERO_RESULTS“。
var keyword='search placename';
var request = { name : keyword,
bounds : new google.maps.LatLngBounds(
google.maps.LatLng(-89.999999,-179.999999),
google.maps.LatLng(89.999999,179.999999)
)};
service = new google.maps.places.PlacesService(map);
service.search(request, callback);
function callback(results, status)
{
console.log("status="+status);
if ( status == google.maps.places.PlacesServiceStatus.OK)
{
for (var i = 0; i < results.length; i++)
console.log(results[i]);
}
}我做错什么了?
发布于 2011-06-07 16:34:55
search()的调用必须包含一个位置和一个半径,或者包含一个边界(作为LatLngBounds对象)。这是在http://code.google.com/apis/maps/documentation/javascript/places.html#place_search_requests.LatLngBounds被记录在http://code.google.com/apis/maps/documentation/javascript/reference.html#LatLngBounds上。我想你会想做这样的事:
var sw = new google.maps.LatLng(-89.999999,-179.999999);
var ne = new google.maps.LatLng(89.999999,179.999999);
var bounds = new google.maps.LatLngBounds(sw,ne);https://stackoverflow.com/questions/6265443
复制相似问题