我在 mapView 创建叠加层,问题是当我再次回到 mapsview 活动时,我看到了我之前制作的叠加层。我试图在 ondestroy 方法中删除没有帮助的覆盖。尝试了所有,相信我。这里的代码......也在 onCreate() 中我使用了 mapView.invalidate(); 这也无济于事。我只想在活动完成后摆脱叠加层。有什么解决办法吗?
@Override
protected void onDestroy(){
super.onDestroy();
stopWorker=true;
mapView.invalidate();
mapView.postInvalidate();
for (int i=0; i<mapView.getOverlays().size(); i++ ) {
mapView.getOverlays().remove(i);
}
Toast.makeText(this,"map destroy ...", Toast.LENGTH_LONG).show();
mapView.getOverlays().clear();
}