aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/maps/CGeoMap.java
diff options
context:
space:
mode:
authorrsudev <rasch@munin-soft.de>2012-06-19 21:08:41 +0200
committerSamuel Tardieu <sam@rfc1149.net>2012-07-06 09:01:52 +0200
commita668a0358765ea2b45c1a05d8b95349e492f8d7f (patch)
tree3ccd7989852f44b8f18f78dcc3fb7bbeea5634d9 /main/src/cgeo/geocaching/maps/CGeoMap.java
parent6d7ee722c44ea3a26a03b0b7180afe811a887ce1 (diff)
downloadcgeo-a668a0358765ea2b45c1a05d8b95349e492f8d7f.zip
cgeo-a668a0358765ea2b45c1a05d8b95349e492f8d7f.tar.gz
cgeo-a668a0358765ea2b45c1a05d8b95349e492f8d7f.tar.bz2
Fix #374, store last known location
Store map center on leave (for all maps) and use it if no reliable location comes in through the GeoProvider
Diffstat (limited to 'main/src/cgeo/geocaching/maps/CGeoMap.java')
-rw-r--r--main/src/cgeo/geocaching/maps/CGeoMap.java26
1 files changed, 20 insertions, 6 deletions
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java
index 87b7285..ce9d4e4 100644
--- a/main/src/cgeo/geocaching/maps/CGeoMap.java
+++ b/main/src/cgeo/geocaching/maps/CGeoMap.java
@@ -427,6 +427,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
mapView.repaintRequired(null);
mapView.getMapController().setZoom(Settings.getMapZoom());
+ mapView.getMapController().setCenter(Settings.getMapCenter());
// live map, if no arguments are given
live = (searchIntent == null && geocodeIntent == null && coordsIntent == null);
@@ -832,11 +833,12 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
}
Settings.setMapZoom(mapView.getMapZoomLevel());
+ Settings.setMapCenter(mapView.getMapViewCenter());
}
// Set center of map to my location if appropriate.
private void myLocationInMiddle(final IGeoData geo) {
- if (followMyLocation) {
+ if (followMyLocation && !geo.isPseudoLocation()) {
centerMap(geo.getCoords());
}
}
@@ -853,19 +855,26 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
private static final float MIN_LOCATION_DELTA = 0.01f;
Location currentLocation = new Location("");
+ boolean locationValid = false;
float currentHeading;
private long timeLastPositionOverlayCalculation = 0;
@Override
protected void updateGeoData(final IGeoData geo) {
- currentLocation = geo.getLocation();
+ if (geo.isPseudoLocation()) {
+ locationValid = false;
+ } else {
+ locationValid = true;
- if (!Settings.isUseCompass() || geo.getSpeed() > 5) { // use GPS when speed is higher than 18 km/h
- currentHeading = geo.getBearing();
- }
+ currentLocation = geo.getLocation();
+
+ if (!Settings.isUseCompass() || geo.getSpeed() > 5) { // use GPS when speed is higher than 18 km/h
+ currentHeading = geo.getBearing();
+ }
- repaintPositionOverlay();
+ repaintPositionOverlay();
+ }
}
@Override
@@ -916,6 +925,11 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
}
boolean needsRepaintForDistance() {
+
+ if (!locationValid) {
+ return false;
+ }
+
final Location lastLocation = overlayPosition.getCoordinates();
float dist = Float.MAX_VALUE;