<LinearLayout
android:id="@+id/LinMapCapture"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map2"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</LinearLayout>
xml은 이런식으로 구성되어있습니다
fragment를 사용해야 된다고 하더라구요 map v2는
그래서 이렇게 해서 맵은 잘 띄워졌습니다
그런데 해당 맵을 캡쳐했는데
검정 화면만 나옵니다
이렇게 나오더라구요
제 소스는 이렇게 되있습니다
GoogleMap mGoogleMap;
LinearLayout LinMapCaputre;
onCreate부분
LinMapCaputre = (LinearLayout) findViewById(R.id.LinMapCapture);
mGoogleMap = ((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map2)).getMap();
캡쳐 부분
LinMapCaputre.buildDrawingCache();
Bitmap bm = LinMapCaputre.getDrawingCache();
String sd =
Environment.getExternalStorageDirectory().getAbsolutePath();
File dir = new File(sd+"/DCIM/mapViewCapture");
//폴더가 존재 안하면
if(!dir.exists()){
dir.mkdirs();
}
FileOutputStream fos;
try {
String FileName = calendar.get(Calendar.YEAR) + "_" + calendar.get(Calendar.MONTH) + "_" + calendar.get(Calendar.DAY_OF_MONTH) +
"_" + calendar.get(Calendar.HOUR_OF_DAY) + "_" + calendar.get(Calendar.MINUTE) + "_" + calendar.get(Calendar.SECOND);
fos = new FileOutputStream(dir + "/" + FileName + ".jpg");
bm.compress(CompressFormat.JPEG, 100, fos);
MapCapturePath = dir + "/" + FileName + ".jpg";
Toast.makeText(map2test.this, "캡쳐된 파일 이름 : " + FileName + ".jpg", Toast.LENGTH_SHORT).show();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
이렇게 했는데 검정화면에 +,- 이 표시만 나오고 지도부분은 검정화면 나오네요
실행하면 지도는 잘보입니다
폰에서 바로 종료키와 홈키를 눌러서 캡쳐하면 전체 화면이 캡쳐되면서 보이더라구요
혹시 종료키와 홈키를 누를때처럼 그 기능을 바로 불러와서 쓸수 있는 방법도 있나요??
소스로
View v1 = this.mapView.getRootView();
v1.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(v1.getDrawingCache());
이런식으로 제일 위에 뷰를 가져와서 캡쳐해도 똑같던데 ㅠ.ㅠ