小编Lar*_*gyn的帖子

Android:在Google地图中保存地图状态

之前我使用过这段代码,但现在我在恢复地图状态时遇到了一些错误.我从David Gassner的教程中得到了这段代码,现在我想再次使用它.我有点困惑,我把一些抛出的消息,以便追踪.LogCat报告指出RESUME中的错误从此行开始任何人都知道如何解决这个问题?

map.animateCamera(update);          
map.setMapType(mgr.getSavedMapType())
Run Code Online (Sandbox Code Playgroud)

继承守则:

@Override
protected void onStop() {
    super.onStop();
    MapStateManager mgr = new MapStateManager(this);
    mgr.saveMapState(mMap);
    Toast.makeText(this, "Map State has been save?", Toast.LENGTH_SHORT).show();
}

@Override
protected void onResume() {
    super.onResume();
    MapStateManager mgr = new MapStateManager(this);
    CameraPosition position = mgr.getSavedCameraPosition();
    if (position != null) {
        CameraUpdate update = CameraUpdateFactory.newCameraPosition(position);
        Toast.makeText(this, "entering Resume State", Toast.LENGTH_SHORT).show();
        mMap.moveCamera(update);

        mMap.setMapType(mgr.getSavedMapType());
    }
}
public class MapStateManager {

    private static final String LONGITUDE = "longitude";
    private static final String LATITUDE = "latitude";
    private static final …
Run Code Online (Sandbox Code Playgroud)

android google-maps

6
推荐指数
1
解决办法
6261
查看次数

标签 统计

android ×1

google-maps ×1