title: Refresh overlay object in Map Activity on Android
body: <p>I have to build a map activity and on top of that, I need to display some location points. These locations are retrieving from a hashtable in another class. The content of this hashtable always changes. So I expect to see those location spots on the Map Activity move as the hashtable is modified.
  The code is shown below:</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.mapview);
  
      MapView mapView = (MapView) this.findViewById(R.id.map);   
      mapView.setStreetView(true);
      mc = mapView.getController();
  
  
      mc.animateTo(...);
      mc.setZoom(12); 
  
      mapView.invalidate();
  
      List&lt;Overlay&gt; listOfOverlays = mapView.getOverlays();
      listOfOverlays.clear();
  
      MarkerOverlay mark = new MarkerOverlay(p);
       listOfOverlays.add(mark);
  
      for(Entry&lt;Long,Pair&gt; p: LQTManager.getInstance().ResultTable.entrySet())
      {
  
          GeoPoint point = new GeoPoint(
                      (int) (p.getValue().x * 1E6), 
                      (int) (p.getValue().y * 1E6));//some code is not shown
           MarkerOverlay markerOverlay = new MarkerOverlay(point);
           listOfOverlays.add(markerOverlay); 
  
  
  
      }
  
      mapView.postInvalidate();
  
  
  }
  
  
  class MarkerOverlay extends com.google.android.maps.Overlay
  {
      public GeoPoint pt;
  
      public MarkerOverlay(GeoPoint pt){
          this.pt=pt;
          }
  
      @Override
      public boolean draw(Canvas canvas, MapView mapView, 
      boolean shadow, long when) 
      {
          super.draw(canvas, mapView, shadow);                   
  
          Point screenPts = new Point();
          mapView.getProjection().toPixels(pt, screenPts);
  
          Bitmap bmp = BitmapFactory.decodeResource(
              getResources(), R.drawable.pushpin);            
  
          canvas.drawBitmap(bmp, screenPts.x-16, screenPts.y-32, null); 
  
          return true;
      }
  } 
  </code></pre>
  
  <p>Is there any way to refresh overlay objects if I touch the screen. I am thinking about put some functions in onTap override method of MarkerOverlay. But I think is is not logically if I try to make the Overlay try to clear itself?
  Any suggested idea?</p>