2011-11-13 8 views
0

Google Maps API를 사용하여 Android 용 애플리케이션을 만들고 있습니다. 내 위치를 찾기 위해지도를로드하지만 문제가 있습니다. 다른 위치로 이동하면 즉시 화면 중앙에 위치합니다. 나는 오히려지도가 내가 움직 인 지점에 남을 것이라고 생각합니다.Google지도는 어떻게 이동합니까?

private void setCurrentLocation(Location location) 
{    
    if(location != null) 
    { 
     // Aggiorna la location 
     Lat = location.getLatitude(); 
     Long = location.getLongitude(); 

     int latitudeE6 = (int) Math.floor(Lat * 1.0E6); 
     int longitudeE6 = (int) Math.floor(Long * 1.0E6); 

     GeoPoint p1 = new GeoPoint(latitudeE6, longitudeE6); 
     GeoPoint p2 = new GeoPoint(currentLatitude, currentLongitude); 

     // Aggiorna la posizione corrente 
     currentLatitude = latitudeE6; 
     currentLongitude = longitudeE6; 

     // Sposta la posizione corrente sulla mappa di F_Map 
     F_Map.mapController.setCenter(p1); 

     // Calcola i metri appena fatti 
     float dist = Distance.getDistance(p1, p2) *1000; 

     if(dist > 1) // maggiore di 1 metro 
     {        
      Toast.makeText(getApplicationContext(), "distance: "+dist,Toast.LENGTH_SHORT).show(); 

      try 
      { 
       SendMyPositionToDB(currentLatitude, currentLongitude); 
      } catch(IOException e) { 
       e.printStackTrace(); 
      }        
     } 
    } 
} 

답변

0

사용자가 설정할 수 있습니다 : 여기

내 코드입니다
F_Map.mapController.setCenter(p2); 

대신 P1의

?

+0

문제는 좌표가 아닙니다. GPS가 시프트를 감지 할 때마다지도가 이동합니다 (onChangeLocation()에서 map.setCenter();). 화면을 터치하면 setCenter가 비활성화 된 다음 특수 버튼을 누르면 다시 활성화됩니다. – user1023571

관련 문제