android addmarker redirct do nieprawidłowej pozycji

głosy
0

Gdybym wklej wyjście dziennika Lat i zalogować długo w google maps to przekierowuje do właściwej lokalizacji, ale animateCamera()przekierowuje do niewłaściwym miejscu w google maps Android app. proszę pomóż!

 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 {

            }

        }
Utwórz 20/11/2017 o 17:04
źródło użytkownik
W innych językach...                            


1 odpowiedzi

głosy
0

Jesteś przejazdem 2 lattitudes.

LatLng(address.getLatitude(),address.getLatitude());

Zamiast

LatLng(address.getLatitude(),address.getLongitude());
Odpowiedział 21/11/2017 o 05:39
źródło użytkownik

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more