Samples MapsforgeActivity: remember map position (#515)

This commit is contained in:
Gustl22 2018-03-21 13:14:27 +01:00 committed by Emux
parent 69ed1fe034
commit dcad929316
No known key found for this signature in database
GPG Key ID: 89C6921D7AF2BDD0

View File

@ -2,6 +2,7 @@
* Copyright 2014 Hannes Janetzek * Copyright 2014 Hannes Janetzek
* Copyright 2016-2018 devemux86 * Copyright 2016-2018 devemux86
* Copyright 2017 Longri * Copyright 2017 Longri
* Copyright 2018 Gustl22
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
@ -204,11 +205,12 @@ public class MapsforgeActivity extends MapActivity {
mMap.layers().add(mapScaleBarLayer); mMap.layers().add(mapScaleBarLayer);
MapInfo info = mTileSource.getMapInfo(); MapInfo info = mTileSource.getMapInfo();
MapPosition pos = new MapPosition(); if (!info.boundingBox.contains(mMap.getMapPosition().getGeoPoint())) {
pos.setByBoundingBox(info.boundingBox, Tile.SIZE * 4, Tile.SIZE * 4); MapPosition pos = new MapPosition();
mMap.setMapPosition(pos); pos.setByBoundingBox(info.boundingBox, Tile.SIZE * 4, Tile.SIZE * 4);
mMap.setMapPosition(pos);
mPrefs.clear(); mPrefs.clear();
}
} }
} else if (requestCode == SELECT_THEME_FILE) { } else if (requestCode == SELECT_THEME_FILE) {
if (resultCode != RESULT_OK || intent == null || intent.getStringExtra(FilePicker.SELECTED_FILE) == null) { if (resultCode != RESULT_OK || intent == null || intent.getStringExtra(FilePicker.SELECTED_FILE) == null) {