Validation autocomplete places api

问题描述 投票:0回答:0

如何将预测自动完成限制在给定范围内(如果我有超过 4 个范围)。

现在我正在使用这个脚本来限制给定城市的搜索区域,但我需要指定更多的边界,有什么办法可以做到这一点吗?

strictSearch.radius = window.google.maps.geometry.spherical.computeDistanceBetween(
                            new window.google.maps.LatLng(
                                cityData.bounds?.pointNorthEast.lat,
                                cityData.bounds?.pointNorthEast.lng,
                            ),
                            new window.google.maps.LatLng(
                                cityData.bounds?.pointSouthWest.lat,
                                cityData.bounds?.pointSouthWest.lng,
                            ),
                        ) / 2;
                    strictSearch.strictbounds = true;

现在我在地图上绘制了一个62个点的多边形,我想用相同的点来限制自动完成

google-maps google-places-api google-places-autocomplete
© www.soinside.com 2019 - 2024. All rights reserved.