在百度地图中处理方向更改的正确方法是什么?
似乎没有getter或setter来获取中心和缩放级别或当前显示的地图的边界。
答案 0 :(得分:0)
保存状态的常规方法是onSaveInstanceState(...)
回调。我在这里写了这段代码:
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelable("map", mapView.getMap().getMapStatus());
}
如果要恢复数据,请尝试此示例(取自片段):
@Nullable
@Override
public synchronized View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.baido_map, container, false);
mapView = (MapView) view.findViewById(R.id.baido_map);
if(savedInstanceState != null) {
mapView.getMap().setMapStatus(MapStatusUpdateFactory.newMapStatus(savedInstanceState.getParcelable("map")));
}
return view;
}