デバイスを回転させたときの SupportMapFragment のパフォーマンスを改善したいと考えています。フラグメントを再作成する必要があるようです。これについてはよくわかりませんが、デバイスを回転させると、マップ タイルをリロードする必要があります。フラグメントを再インスタンス化することなく、マップフラグメント全体を保持して再利用することは、パフォーマンスの観点から理にかなっています。これについての洞察をいただければ幸いです。
xml で SupportMapFragment を宣言し、API ドキュメントで説明されているように SetupMapIfNeeded() を使用しています。
private void setUpMapIfNeeded() {
// Do a null check to confirm that we have not already instantiated the
// map.
if (mMap == null) {
// Try to obtain the map from the SupportMapFragment.
mMap = ((SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map)).getMap();
// Check if we were successful in obtaining the map.
if (mMap != null) {
setUpMap();
}
}
}