지도를 항상 중앙에 유지해야하는 앱을 제작하고 있습니다.Android - Google지도 - 모든 위치 변경 카메라 업데이트
locationManager = (LocationManager) saveContext
.getSystemService(Context.LOCATION_SERVICE);
LocationListener locationListener = new MapLocationListener();
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000,
10, locationListener);
if (myLocation != null) {
setLocation(myLocation);
}
private void setLocation(Location location) {
workoutMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(
location.getLatitude(), location.getLongitude()), 18.0f));
}
이 작품은 한 내 휴대 전화의 역사에 lastKnownLocation 있습니다
나는 다음과 같은 설정했습니다. 지도가 올바르게 중앙에 배치됩니다.
새로운 위치 정보를 가져올 때마다 setLocation()이 새 위치 정보와 함께 다시 실행되기를 바랍니다.
나는 단지 lastKnownLocation과 setLocation()을 얻는 스레드를 만들려고 시도했다. 하지만이 방법은 효과가 없습니다.