我正在使用谷歌地图 V2。我想用来geocoder
查找位置,但getFromLocationName()
它返回空值,我找不到原因。只需查看我的代码并建议我,我该怎么办?
EditText sLocation = (EditText) v.findViewById(R.id.editText1);
String location = sLocation.getText().toString();
List<android.location.Address> addressList= null;
if (location != null || !location.equals("")) {
Geocoder geocoder = new Geocoder(getActivity().getApplicationContext());
try {
addressList = geocoder.getFromLocationName(location, 1);
} catch (IOException e) {
e.printStackTrace();
}
android.location.Address address = addressList.get(0);
LatLng latlng = new LatLng(address.getLatitude(), address.getLatitude());
gMap.addMarker(new MarkerOptions().position(latlng).title("Marker"));
gMap.animateCamera(CameraUpdateFactory.newLatLng(latlng));
}