2016-06-02 1 views
3

google place api autocompleteview을 사용하고 있습니다.GooglePlace의 autocompleteFragment.setBoundsBias가 작동하지 않는 것 같습니다.

검색 결과를 United States of America으로 제한하고 싶습니다.

autocompleteFragment = (PlaceAutocompleteFragment) getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment); 


autocompleteFragment.setBoundsBias(new LatLngBounds(new LatLng(0,0),new LatLng(37.090240,-95.712891))); 

이 코드는 작동하지 않습니다. 내가 Sydney을 입력하면 결과가 나옵니다.

+1

바운드 바이어스는 엄격한 필터가 아닙니다. 웹 서비스에서 국가 별 구성 요소 제한을 설정할 수 있지만 Android Android에는이 기능이 구현되어 있지 않은 것처럼 보입니다. 이 기능 요청을 찾았습니다 https://code.google.com/p/gmaps-api-issues/issues/detail?id=8611 – xomena

+0

또한 autocompleteFragment.setBoundsBias()는 인수가 필요로하는 LatLngBounds를 북동쪽 남서쪽으로 가져옵니다. 북서쪽 남동쪽을 사용하고 있습니다. 올바른 코드 : autocompleteFragment.setBoundsBias (new LatLngBounds (new LatLng (37.09024, 0), new LatLng (0, -95.712891))); – miguev

답변

-1

이 코드를 사용해보십시오.

try { 
       AutocompleteFilter typeFilter = new AutocompleteFilter.Builder() 
         .setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS) 
         .setCountry("US") 
         .build(); 

       Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY) 
         .setFilter(typeFilter) 
         .build(actWithEditTextToReturn.this); 
       startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE_ORIGEM); 
      } catch (GooglePlayServicesRepairableException e) { 
       // TODO: error. 
      } catch (GooglePlayServicesNotAvailableException e) { 
       // TODO: error. 
      } 

봤는데 setBoundsBias에 문제가 나에게 오류 제공 :

E/Volley: [141] BasicNetwork.performRequest: Unexpected response code 503 for h t tps://www.googleapis.com/placesandroid/v1/getAutocompletePredictions?key=AIza....

을이 필터를 추가하고 ("US") .setCountry를 사용하여 간단한 setOnClickListener 버튼 안에

E/Volley: [140] BasicNetwork.performRequest: Unexpected response code 500 for h t tps://www.googleapis.com/placesandroid/v1/getAutocompletePredictions?key=AIza....

그리고 내 해결책은 setboundbias를 제거하는 것이 었음을 알 수 있습니다. 고맙습니다.

관련 문제