I have a problem with GoogleMap API for Android component MyLocationOverlay. I want to turn off MyLocationOverlay auto-recenter feature (to current user location) every time device location changes (and user location goes out of the visible part or the map).
It seems there is no flag to turn off the undesired maps auto-center feature when user location goes out of the screen
e.g.
public class LocationTest extends MapActivity{
private MapView map;
private MapController controller;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
map = (MapView) findViewById(R.id.map);
final MyLocationOverlayUpdate overlay = new MyLocationOverlayUpdate(this, map);
overlay.enableMyLocation();
map.getOverlays().add(overlay);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
public class MyLocationOverlayUpdate extends MyLocationOverlay {
public MyLocationOverlayUpdate(Context context, MapView mapView) {
super(context, mapView);
}
public void drawMyLocation(Canvas canvas, MapView mapView,
Location location, GeoPoint geoPoint, long when) {}
}
I looked through the net for this problem but didn't found the solution provided.
Additional info found:
I guess that documentation is faulty, buggy, or just outdated saying:
Optionally, the constructor can also take a MapController and use it to keep the "my location" dot visible by panning the map when it would go offscreen
because there is no constructor accepting MapController as an argument, and it seems that I have no choice over keeping the "my location" dot visible
or not.
- I accidentaly found a workaround by overriding method drawMyLocation() with no call to super.drawMyLocation() solves the problem of recentering the map (undesired "feature" turns off). However i have to reimplement drawMyLocation() method, therefore changing default appearence (and spending time...)
Maybe there is a more clear solution?