gpt4 book ai didi

javascript - 将谷歌地图自动完成限制为仅距给定地址位置 50 英里

转载 作者:行者123 更新时间:2023-12-03 03:58:21 26 4
gpt4 key购买 nike

我已经浏览了下面链接中的示例 https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete?csw=1

我尝试了这个例子,但没有得到预期的输出,地址超出了我提到的半径范围,下面我添加了自动完成的代码,请告诉我我出了什么问题

var center22 = new google.maps.LatLng({ lat: 51.448386, lng: -0.199501 });
service = new google.maps.places.AutocompleteService();


service.getPlacePredictions({
input: query, location: center22, radius: 50000, strictbounds: true, componentRestrictions: { country: 'GB' }

}, function (predictions, status) {
if (status != google.maps.places.PlacesServiceStatus.OK) {
dfd.resolve([]);


}


dfd.resolve(predictions);
return dfd.promise

}
});

最佳答案

AutocompleteService 尚未实现严格的界限。目前您只能将结果偏置到特定区域,而不能限制。

https://developers.google.com/maps/documentation/javascript/reference#AutocompletionRequest

公共(public)问题跟踪器中有一个与此相关的功能请求:

https://issuetracker.google.com/issues/36219203

请随意为此功能请求加注星标以表达您的兴趣并订阅通知。

关于javascript - 将谷歌地图自动完成限制为仅距给定地址位置 50 英里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44839013/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com