我一直在尝试从自动完成中单击某个位置后获取latlng,奇怪的是,places.getName()它工作正常,但place.getLatLng()返回null。我应该怎么做才能解决这个问题?我是Google Maps and Place API的新手!
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == AUTOCOMPLETE_REQUEST_CODE_FROM) {
if (resultCode == RESULT_OK) {
Place place = Autocomplete.getPlaceFromIntent(data);
Log.i("shipadd", "Place: " + place.getName() + ", " + place.getId());
from_edit_txt.setText(place.getName());
origin=place.getLatLng();
Log.e("origin_destarray",""+place.getLatLng());
} else if (resultCode == AutocompleteActivity.RESULT_ERROR) {
// TODO: Handle the error.
Status status = Autocomplete.getStatusFromIntent(data);
Log.i("shipadd", status.getStatusMessage());
} else if (resultCode == RESULT_CANCELED) {
// The user canceled the operation.
}
}
else if …Run Code Online (Sandbox Code Playgroud)