MapsApi - Google 地图定位服务出现奇怪的错误

MapsApi - Google maps place service giving a weird error

Google maps place 服务无法正常工作并给出下一个错误

Uncaught Error: Property radius is invalid. A possible cause is that the value conflicts with other properties.

代码

var service = new google.maps.places.PlacesService(map);
var request = {
    location: centerLatLong,
    rankBy: google.maps.places.RankBy.DISTANCE,
    radius: 500
}; 
service.nearbySearch(request, function(results, status){
    if (status == google.maps.places.PlacesServiceStatus.OK){
        console.log(results)
    }
});

使用rankBy:distance时不支持radius-属性。

Javascript-API 的文档似乎不完整,因为它不包含半径-属性 是 不允许的信息 当您使用 rankBy:distance 时,但是 places-Webservice 的文档包含以下信息:

radius — Defines the distance (in meters) within which to return place results. The maximum allowed radius is 50 000 meters. Note that radius must not be included if rankby=distance (described under Optional parameters below) is specified.

https://developers.google.com/places/webservice/search#PlaceSearchRequests

解决方法:删除radius-属性