Samples Desktop: remember map position #32

This commit is contained in:
Emux
2018-03-22 10:04:35 +02:00
parent fed0996f6f
commit 0137d9ff1f
8 changed files with 134 additions and 7 deletions

View File

@@ -77,12 +77,21 @@ public class MapsforgeTest extends GdxMapApp {
renderer.setOffset(5, 0);
mMap.layers().add(mapScaleBarLayer);
MapPosition pos = MapPreferences.getMapPosition();
MapInfo info = tileSource.getMapInfo();
MapPosition pos = new MapPosition();
pos.setByBoundingBox(info.boundingBox, Tile.SIZE * 4, Tile.SIZE * 4);
if (pos == null || !info.boundingBox.contains(pos.getGeoPoint())) {
pos = new MapPosition();
pos.setByBoundingBox(info.boundingBox, Tile.SIZE * 4, Tile.SIZE * 4);
}
mMap.setMapPosition(pos);
}
@Override
public void dispose() {
MapPreferences.saveMapPosition(mMap.getMapPosition());
super.dispose();
}
static File getMapFile(String[] args) {
if (args.length == 0) {
throw new IllegalArgumentException("missing argument: <mapFile>");