当我单击“位置自动完成片段搜索”框时,
我遇到以下错误
place fields must not be empty (9012)
我已经迁移到新的地方SDK。还检查了我的Google Billing and Maps API。一切都正确
我的代码
Places.initialize(getApplicationContext(),getResources().getString(R.string.google_api_key));
placesClient = Places.createClient(this);
AutocompleteSupportFragment placesfragment = (AutocompleteSupportFragment) getSupportFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
placesfragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(@NonNull Place place) {
LatLng ll = place.getLatLng();
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(ll, 14));
if (manmarker != null) manmarker.remove();
manmarker = mMap.addMarker(new MarkerOptions().position(ll).title("Manually Selected Location"));
manapprox = getAddressFromLatLAng(ll);
manualaddr.setText(manapprox);
manlatlng = ll;
}
@Override
public void onError(Status status) { // Handle the error
Toast.makeText(MapsActivity.this, "Something went wrong! please try again "+status.getStatusCode() + " " + status.getStatusMessage() + Places.isInitialized(), Toast.LENGTH_SHORT).show();
}
});
请帮助我解决此问题
答案 0 :(得分:0)
尝试使用setPlaceFields
指定要返回的位置数据的类型:
placesfragment.setPlaceFields(listOf(Place.Field.ID, Place.Field.NAME));
参考here。