I am experiencing an unusual behavior on my MapView
, i am using RoboGuice by the way i am not sure it could influence the issue.
The problem is, if i enable a MyLocationListener
on my map, then every overlay on it gets continually redrawn ad infinitum.
Give a look at this example:
MyMapActivity
@ContentView(R.layout.map)
public class MyMapActivity extends RoboMapActivity {
@InjectView(R.id.map)
private MapView map;
private List<Overlay> mapOverlays;
private MyLocationOverlay compass;
private TestOverlay testOverlay;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
map.setBuiltInZoomControls(true);
mapOverlays = map.getOverlays();
compass = new MyLocationOverlay(this, map);
testOverlay = new TestOverlay();
}
@Override
protected void onResume() {
super.onResume();
compass.enableCompass();
refreshMap();
}
private void refreshMap() {
mapOverlays.clear();
mapOverlays.add(testOverlay);
}
@Override
protected void onPause() {
compass.disableCompass();
super.onPause();
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
TestOverlay
public class TestOverlay extends Overlay {
@Override
public void draw(Canvas arg0, MapView arg1, boolean arg2) {
System.out.println("drawing...");
super.draw(arg0, arg1, arg2);
}
}
if i run this, i get drawing...
printed about ten times per second for ever.
but, if i avoid enabling MyLocationOverlay
's compass by commenting out this line:
// compass.enableCompass();
then the redrawings stop.
any idea about why this happens? is it a bug or am i doing something wrong?
Edit
Just reproduced it in a project that does not make use of RoboGuice, the problem still occurs.
I guess i will do without that compass from now on