如果我粘贴log lat的输出并在google地图中长日志,它会重定向到正确的位置,但animateCamera()
会重定向到google maps android app中的错误位置。请帮忙!
public void onSearch(View view){
Log.i("******************","in search function");
EditText locationTf = (EditText)findViewById(R.id.editText);
String location = locationTf.getText().toString();
Log.i("Entered location:",location);
if(location != null || location.equals("")){
Log.i("In if statement","all condition are satisfied");
Geocoder geocoder = new Geocoder(this);
try {
addresses = geocoder.getFromLocationName(location,1);
Log.i("in try block",addresses.toString());
} catch (IOException e) {
e.printStackTrace();
}
Address address = addresses.get(0);
Log.i("after try catch block",address.toString());
LatLng searchLatLng = new LatLng(address.getLatitude(),address.getLatitude());
double logLat = address.getLatitude() ;
double logLon = address.getLongitude() ;
Log.i("********************","&&&&&&&&&&&&&&&&&&&&&&&&");
Log.i(Double.toString(logLat),Double.toString(logLon));
mMap.addMarker(new MarkerOptions().position(searchLatLng).title("Results"));
mMap.animateCamera(CameraUpdateFactory.newLatLng(searchLatLng));
// mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(searchLatLng, 10));
}
else {
}
}
答案 0 :(得分:0)
你正在经过2个阶段。
LatLng(address.getLatitude(),address.getLatitude());
而不是
LatLng(address.getLatitude(),address.getLongitude());