mic*_*r92 3 javascript google-maps google-maps-api-3 google-places-api
谷歌地图服务无法正常工作并出现下一个错误
未捕获的错误:属性半径无效。一个可能的原因是该值与其他属性冲突。
代码
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)
}
});
Run Code Online (Sandbox Code Playgroud)
在radius当您使用-属性不被支持rankBy:distance。
Javascript-API 的文档似乎不完整,因为它不包含使用时不允许使用radius-property 的信息rankBy:distance,但 Places-Webservice 的文档包含以下信息:
radius— 定义返回地点结果的距离(以米为单位)。最大允许半径为 50?000 米。请注意,如果指定了 rankby=distance(在下面的可选参数中描述),则不能包括半径。
https://developers.google.com/places/webservice/search#PlaceSearchRequests
解决方案:删除radius- 属性
| 归档时间: |
|
| 查看次数: |
612 次 |
| 最近记录: |