카메라를 사용하면 지도의 사용자 시점을 변경할 수 있습니다. 카메라 모드를 사용하여 내비게이션 중에 지도 뷰의 동작을 제어할 수 있습니다. 카메라 모드를 설정하려면 카메라와 연결된 다음 메서드 중 하나를 호출합니다.
내 위치 추적 (
GoogleMap.followMyLocation) - 내비게이션의 기본 카메라 모드입니다. 이 모드는 카메라를 기기 또는 차량에 설정합니다. 내비게이션을 사용하는 동안 카메라는 자동으로 이동 방향을 향합니다.위치에 고정 (
GoogleMap.animateCamera및GoogleMap.moveCamera) - 카메라를 특정 위치에 고정합니다. 이 모드를 사용하면 방위, 기울기, 확대/축소와 같은 다른 카메라 속성과 함께 카메라 위치를 설정할 수 있습니다. 이 뷰가 선택되고 Navigator가 초기화되면 중심 재설정 버튼이 표시됩니다.경로 개요 표시 (
NavigationView.showRouteOverview또는NavigationFragment.showRouteOverview): 남은 경로의 개요 (다음 45분 운전 시간까지)를 표시하고 필요에 따라 상하/좌우로 이동하고 확대/축소하여 경로를 지도 뷰에 맞춥니다. 이 뷰를 선택하면 중심 재설정 버튼이 표시됩니다.
Re-center 버튼을 클릭하면 카메라가 followMyLocation 모드로 설정됩니다.
내 위치 모드 따라가기
가장 일반적인 카메라 설정은 카메라를 기기 또는 차량에 설정하여 여정 내 현재 위치를 표시하는 것입니다. 이 카메라 모드에서는 차량이 항상 화면 위쪽을 향하는 각도 (CameraPerspective.TILTED)로 경로를 보거나, 북쪽 (CameraPerspective.TOP_DOWN_NORTH_UP) 또는 진행 방향 (CameraPerspective.TOP_DOWN_HEADING_UP)이 항상 화면 상단에 표시된 상태로 차량이 이동하는 모습을 볼 수 있습니다.
다음 코드 조각은 TILTED 관점을 사용합니다.
// Set the camera to follow the device (vehicle):
mNavFragment.getMapAsync(googleMap -> googleMap.followMyLocation(CameraPerspective.TILTED))
위치 모드에 고정됨
Pinned 모드는 카메라를 가장 세밀하게 제어할 수 있는 모드입니다. 이 모드에서는 카메라를 특정 위치에 배치하고, 방위를 할당하여 카메라 뷰의 방향을 지정하고, 기울기를 변경하여 시야각을 설정하고, 카메라의 확대/축소 수준을 설정합니다.
다음 코드 스니펫은 카메라를 이동하는 일반적인 방법을 몇 가지 보여줍니다.
private static final LatLng SYDNEY = new LatLng(-33.88, 151.21);
private static final LatLng MOUNTAIN_VIEW = new LatLng(37.4, -122.1);
private GoogleMap map;
... // Obtain the map from a NavigationFragment or NavigationView.
// Move the camera instantly to Sydney with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(SYDNEY, 15));
// Zoom in, animating the camera.
map.animateCamera(CameraUpdateFactory.zoomIn());
// Zoom out to zoom level 10, animating with a duration of 2 seconds.
map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
// Construct a CameraPosition focusing on Mountain View and animate the camera to that position.
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(MOUNTAIN_VIEW) // Sets the center of the map to Mountain View
.zoom(17) // Sets the zoom
.bearing(90) // Sets the orientation of the camera to east
.tilt(30) // Sets the tilt of the camera to 30 degrees
.build(); // Creates a CameraPosition from the builder
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
경로 개요 모드 표시
showRouteOverview 카메라 설정은 전체 여정을 표시합니다.
목적지가 여러 개인 여정의 경우 이 모드는 경로에서 이동하지 않은 부분을 표시합니다.
// Place the camera to see the remaining route:
mNavFragment.showRouteOverview();
다음 단계
내장 UI 구성요소 구성에 관한 자세한 내용은 탐색 UI 맞춤설정을 참고하세요.