GDX samples: remember map position (#569)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016-2018 devemux86
|
||||
* Copyright 2018 Gustl22
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -24,6 +25,7 @@ import com.badlogic.gdx.backends.android.AndroidApplication;
|
||||
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
|
||||
import com.badlogic.gdx.utils.SharedLibraryLoader;
|
||||
|
||||
import org.oscim.android.MapPreferences;
|
||||
import org.oscim.android.canvas.AndroidGraphics;
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.GLAdapter;
|
||||
@@ -36,6 +38,7 @@ import org.oscim.tiling.source.OkHttpEngine;
|
||||
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
|
||||
|
||||
public class GdxActivity extends AndroidApplication {
|
||||
MapPreferences mPrefs;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -56,6 +59,7 @@ public class GdxActivity extends AndroidApplication {
|
||||
new SharedLibraryLoader().load("vtm-jni");
|
||||
|
||||
initialize(new GdxMapAndroid(), cfg);
|
||||
mPrefs = new MapPreferences(GdxActivity.class.getName(), this);
|
||||
}
|
||||
|
||||
class GdxMapAndroid extends GdxMap {
|
||||
@@ -65,6 +69,15 @@ public class GdxActivity extends AndroidApplication {
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||
.build();
|
||||
initDefaultLayers(ts, false, true, true);
|
||||
|
||||
mPrefs.load(getMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() {
|
||||
mPrefs.save(getMap());
|
||||
|
||||
super.pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2016-2017 devemux86
|
||||
* Copyright 2018 Gustl22
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -16,11 +17,13 @@
|
||||
*/
|
||||
package org.oscim.test.gdx.poi3d;
|
||||
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.gdx.GdxMapApp;
|
||||
import org.oscim.layers.tile.buildings.BuildingLayer;
|
||||
import org.oscim.layers.tile.vector.VectorTileLayer;
|
||||
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||
import org.oscim.renderer.MapRenderer;
|
||||
import org.oscim.test.MapPreferences;
|
||||
import org.oscim.theme.VtmThemes;
|
||||
import org.oscim.tiling.TileSource;
|
||||
import org.oscim.tiling.source.OkHttpEngine;
|
||||
@@ -32,8 +35,6 @@ public class Gdx3DTest extends GdxMapApp {
|
||||
public void createLayers() {
|
||||
MapRenderer.setBackgroundColor(0xff888888);
|
||||
|
||||
mMap.setMapPosition(53.1, 8.8, 1 << 15);
|
||||
|
||||
TileSource ts = OSciMap4TileSource.builder()
|
||||
.httpFactory(new OkHttpEngine.OkHttpFactory())
|
||||
.build();
|
||||
@@ -57,6 +58,18 @@ public class Gdx3DTest extends GdxMapApp {
|
||||
mMap.layers().add(new Poi3DLayer(mMap, mMapLayer));
|
||||
|
||||
mMap.layers().add(new LabelLayer(mMap, mMapLayer));
|
||||
|
||||
MapPosition pos = MapPreferences.getMapPosition();
|
||||
if (pos != null)
|
||||
mMap.setMapPosition(pos);
|
||||
else
|
||||
mMap.setMapPosition(53.1, 8.8, 1 << 15);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
MapPreferences.saveMapPosition(mMap.getMapPosition());
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Reference in New Issue
Block a user