1
這是我的主要活動,在這裏它的工作正常,但是如果我們再次加載地圖時它會一次不顯示當前位置,因爲它是第一次(即當onCreate()
被調用。)GPSTracker文件實現LocationListner接口,並提供我哪些我傳遞給goToLocation(緯度,經度)當前位置谷歌地圖不是恢復當前位置的動畫
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.before_login_map_activity);
progressView = (View) findViewById(R.id.progress_bar);
if (initMap()) {
gpsTracker = new GPSTracker(this);
if (gpsTracker.canGetLoaction()) {
originlon = gpsTracker.getLongitide();
originlat = gpsTracker.getLattitude();
mMap.setMyLocationEnabled(true);
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
goToLocatoin(originlat, originlon);
}
getJsonLatLon();
} else {
Toast.makeText(BeforeLoginMapActivity.this, "Map Not Available!", Toast.LENGTH_SHORT).show();
}
<fragment android:id="@+id/map" android:name="com.google.android.gms.maps.SupportMapFragment" tools:ignore="MissingPrefix" android:layout_width="match_parent" android:layout_height="match_parent" />
你爲什麼不乾脆轉移您的實現'onResume'? – Androiderson
謝謝Androiderson,爲您提供幫助,但是我使用了CameraPosition類,它對我很有幫助。提供下面的代碼 – Mrinmoy