使用directy的CameraUpdate以防萬一你想在任何初始Location
程序加載Google Map
那麼你可以使用這段代碼,
FragmentManager fm = getFragmentManager(); // getChildFragmentManager inside fragments.
CameraPosition cp = new CameraPosition.Builder()
.target(initialLatLng) // your initial co-ordinates here. like, LatLng initialLatLng
.zoom(zoom_level)
.build();
SupportMapFragment mapFragment = SupportMapFragment.newInstance(new GoogleMapOptions().camera(cp));
fm.beginTransaction().replace(R.id.rl_map, mapFragment).commit();
添加此一段代碼爲layout
<RelativeLayout
android:id="@+id/rl_map"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
這將直接加載GoogleMap
,特別是Location
,即initialLatLng。
這個qustion幫助....即使沒有啓用位置... animateCamera指向非洲的某個地方... wiered!對於這個問題,'moveCamera'是這個 – Devrath
hahahhaha ....... + 1的最佳解決方案,你問我的心臟。 :D ......「它總是從一個固定的位置開始(在非洲附近)」........ rofll .....儘管如此,謝謝。 – akash89