gpt4 book ai didi

google-maps-api-3 - 谷歌放置自动完成 - 位置和半径不起作用

转载 作者:行者123 更新时间:2023-12-04 15:01:53 28 4
gpt4 key购买 nike

我试图设置谷歌地点自动完成以从最近到一个点对结果进行排序。我有一个这样的代码...

var defaultPlace = new google.maps.LatLng(49.227463, 16.546097);

var optionsAuto = {
location: defaultPlace,
radius: 20000,
types: ['geocode'],
componentRestrictions: {
country: 'cz'
}
};

var autocomplete = new google.maps.places.Autocomplete( inputStart, optionsAuto );

类型和 componentRestrictions 效果很好,但位置和半径似乎不起作用。

最佳答案

documentation

它指出:

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.



听起来你想要可选参数:rankby=distance:

rankby | distance. This option sorts results in ascending order by their distance from the specified location. Ranking results by distance will set a fixed search radius of 50km. One or more of keyword, name, or types is required.



也可在 javascript service 中找到

Working Example

关于google-maps-api-3 - 谷歌放置自动完成 - 位置和半径不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11810810/

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