如何解决Google Places Android显示错误“位置字段不能为空”吗?
当我单击“位置自动完成片段搜索”框时,
我遇到以下错误
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();
}
});
请帮助我解决此问题
解决方法
尝试使用setPlaceFields
指定要返回的位置数据的类型:
placesfragment.setPlaceFields(listOf(Place.Field.ID,Place.Field.NAME));
参考here。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。