Google maps api 3 使用google maps places API获取相关(而非伪随机)结果

Google maps api 3 使用google maps places API获取相关(而非伪随机)结果,google-maps-api-3,google-places-api,Google Maps Api 3,Google Places Api,我阅读了所有关于PlacesAPI的帖子(这里和其他地方),但仍然找不到解决方案。我有一个表单,用户可以在其中输入街道、编号或建筑名称(如购物中心)。在提交和显示地图之前,我想通过地理编码(如果是数字)或地点(如果是名称)验证信息,因为我需要确切的地址,但地点搜索会给我伪随机结果。例如: var cityCenter = new google.maps.LatLng(1.30563, 103.83751); var building = 'Forum'; places = new google.

我阅读了所有关于PlacesAPI的帖子(这里和其他地方),但仍然找不到解决方案。我有一个表单,用户可以在其中输入街道、编号或建筑名称(如购物中心)。在提交和显示地图之前,我想通过地理编码(如果是数字)或地点(如果是名称)验证信息,因为我需要确切的地址,但地点搜索会给我伪随机结果。例如:

var cityCenter = new google.maps.LatLng(1.30563, 103.83751);
var building = 'Forum';
places = new google.maps.places.PlacesService(map); 
places.search({ location: cityCenter, radius:'50000', query:building }, function(results, status) 
{
    console.log(results);
});
在maps.google.com上的第一个结果是完美的。实际上,前几个结果是相关的,或者至少包含“论坛”这个词。在我的应用程序中,我得到了20个与我的查询无关(显然)的结果


是否有任何方法可以获得与网站相同的结果?

似乎您正在尝试使用该服务,因为您正在使用
查询
参数,但是您正在调用该服务

尝试:

places.textSearch({ location: cityCenter, radius:'50000', query:building }, function(results, status) 
{
    console.log(results);
});