Android Google商家信息自动填充功能无法正常运行

qwe*_*rtz 7 android google-places-api google-play-services

我希望能够通过使用google places api自动完成一些地方.我只想包括某个地区的某些地方.Googles API文档通过使用该函数来描述此功能setBoundsBias,但我似乎无法使其正常工作,因为它仍然返回指定区域外的结果.

try {
            Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY)
                    .setBoundsBias(new LatLngBounds(
                            new LatLng(16.371163, 21.051073),
                            new LatLng(16.725743, 21.424006)))
                    .build(getActivity());

            startActivityForResult(intent, requestCode);
        } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
            e.printStackTrace();
        }
Run Code Online (Sandbox Code Playgroud)

hex*_*cle 0

应该setBoundsBias返回来自该区域之外的结果。这只是一种偏见。如果您想专门返回范围内的结果,则必须使用AutocompleteFilter. 不幸的是,目前按地区过滤的唯一级别是按国家/地区。