Goal
- Android에서 Google Map API를 통해 전세계 지도를 한 눈에 보기
Problems
- Android App 화면에 전 세계 지도를 볼 수 있는 기능 구현 중에, Zoom Level을 1(Whole World)로 설정해도 지도에 전체가 보이지 않는 현상 발생

Solutions
1. Google Map Lite Mode 적용
- Lite Mode는 구글 맵에서 특정 지역들만을 나타내는 비트맵 이
미지
- 많은 맵을 스트리밍으로 서비스 하거나 너무 작은 화면에 맵을 출력해야될 때 이용
- Layout XML attribute에 map:liteMode=”true” 항목 추가
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:name="com.google.android.gms.maps.MapFragment"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:cameraZoom="13"
map:mapType="normal"
map:liteMode="true"/>

2. LatlngBounds 적용
- 화면이 작아 Lite Mode를 적용해도 전체 지도가 한번에 출력되지 않을 수도 있다.

SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mapViewLocationDashboard);
mapFragment.getMapAsync(googleMap -> {
LatLngBounds bound = new LatLngBounds(
new LatLng(-85, 180), // bottom right corner
new LatLng(85, -180) // top left corner of map);
);
googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bound, 5)); // bound, padding
});

References
- 1: World
- 5: Landmass/continent
- 10: City
- 15: Streets
- 20: Buildings
댓글남기기