I have a problem with the GoogleMap API for the Android component MyLocationOverlay. I want to disable the MyLocationOverlay autostart function (for the current location of the user) every time the location of the device changes (and the user's location goes beyond the visible part or map).
There seems to be no checkbox to disable the auto-center feature of unwanted cards when the user's location leaves the screen.
eg.
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 scanned the network for this problem, but could not find a solution.
Additional information found:
I assume the documentation is erroneous, erroneous, or simply outdated, saying:
Additionally, the designer can also take the MapController and use it to save the βmy locationβ point, visible by panning the map when it enters the screen
because the constructor does not accept MapController as an argument, and it seems that I have no choice over keeping the "my location" dot visible or not.
- I accidentally found a workaround by overriding the drawMyLocation () method without calling super.drawMyLocation () solves the problem of re-placing the map (the unwanted function is "disabled"). However, I need to override the drawMyLocation () method, so change the default value (and spend time ...)
Maybe there is a clearer solution?
source share