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