2017-11-20 19 views
0

로그 위도 및 로그가 길어 Google지도에 붙여 넣으면 올바른 위치로 리디렉션되지만 animateCamera()은 Google지도 안드로이드 앱의 잘못된 위치로 리디렉션됩니다. 도와주세요!android addmarker가 잘못된 위치로 redirct

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

당신은 2 개의 위도를 지나고 있습니다.

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

대신 저를 정정

LatLng(address.getLatitude(),address.getLongitude()); 
+0

thnk의 – JayeshNovice

+0

당신을 환영합니다! – Bek