주소를 입력해서 검색하면 마커가 잘 찍힙니다

그런데 문제점은 다시 검색할때 기존 마커가 사라지지 않고 다시 검색한 곳의 마커가 표시되는데

새로 검색할때 기존 마커를 지우고싶은데 안되네요...

myOverlays.clear();

이거나

myOverlays.removeAll();

myOverlays.remove(0);

이렇게 하면 된다는데 전 해도해도 안되네요...

ㅠ.ㅠ

방법좀 알려주세요

 

 

 

public class MapSelect extends MapActivity{
 
 private MapView mapView;
 private List<Overlay> mapOverlays;
 private Drawable drawable;
    private HellItemizedOverlay itemizedOverlay;
    private MapController mc;
    int latitude, longitude;
    double _latitude, _longitude;
    EditText edit;
    OverlayItem ex;
   
    String text_Address = null;

 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.mapview);
  
  mapView = (MapView) findViewById(R.id.map);
  mapView.setBuiltInZoomControls(true);
  mapView.setSatellite(false);
  
  SharedPreferences pref = getSharedPreferences("Location", MODE_PRIVATE);
  
  mc = mapView.getController();
  mc.animateTo(new GeoPoint(pref.getInt("lat", 0), pref.getInt("lng", 0)));
  mc.setZoom(17);
  
  
  drawable = this.getResources().getDrawable(R.drawable.pin);
  itemizedOverlay = new HellItemizedOverlay(drawable, this);

        edit = (EditText) findViewById(R.id.text_selectAddress);

        Button btn_MapSelect = (Button) findViewById(R.id.btn_MapSelect);
        btn_MapSelect.setOnClickListener(new View.OnClickListener() {
           
            public void onClick(View v) {
             mapOverlays = mapView.getOverlays();
             if(mapOverlays.size() > 0){
              
              mapOverlays.remove(0);
             }else{
            
             }
             goLoc(edit.getText().toString());
            }
        });
       
        Button btn_MapOk = (Button)findViewById(R.id.btn_mapOk);
        btn_MapOk.setOnClickListener(new View.OnClickListener() {
   
   public void onClick(View v) {
    // TODO Auto-generated method stub
    Intent intent = getIntent();
    intent.putExtra("latitude", _latitude);
    intent.putExtra("longitude", _longitude);
    intent.putExtra("Address", text_Address);
    setResult(RESULT_OK, intent);
    finish();
   }
  });
    }

    public void goLoc(String goLocName) {
        Geocoder gc = new Geocoder(this, Locale.getDefault());
        List<Address> adds;

        try {
            adds = gc.getFromLocationName(goLocName, 1);

            if (adds.size() == 0) {
                Toast.makeText(this, goLocName + "을 찾을 수 없습니다!",
                        Toast.LENGTH_LONG).show();
                return;
            }
           
            text_Address = edit.getText().toString();
           
            latitude = (int) (adds.get(0).getLatitude() * 1E6);
            longitude = (int) (adds.get(0).getLongitude() * 1E6);
            _latitude = adds.get(0).getLatitude();
            _longitude = adds.get(0).getLongitude();
           
            OverlayItem overlayitem1 = new OverlayItem(new GeoPoint(latitude, longitude), text_Address, text_Address);
            mapOverlays.remove(ex);
            ex = overlayitem1;
            itemizedOverlay.addOverlay(overlayitem1);
            mapOverlays.add(itemizedOverlay);
            mc.animateTo(new GeoPoint(latitude, longitude));
//            GeoPoint gp = new GeoPoint(latitude, longitude);
//           
//            MyOverlay myOverlay = new MyOverlay(gp);
//           
//            mapView.getOverlays().add(myOverlay);
//            mapView.invalidate();
//
//            mapView.getController().setZoom(16);
//            mapView.getController().setCenter(gp);
//            mapView.getController().animateTo(gp);
           
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }
 

//    class MyOverlay extends Overlay{
//     GeoPoint geoPoint;
//     
//     //int radius = 10;
//     
//     MyOverlay(GeoPoint geoPoint){
//      super();
//      this.geoPoint = geoPoint;
//     }
//     
//     @Override
//     public void draw(Canvas canvas, MapView mapView, boolean shadow) {
//      // TODO Auto-generated method stub
//      super.draw(canvas, mapView, shadow);
//      
//      mapView.removeAllViews();
//      
//      if(shadow == false){
//       Projection projection = mapView.getProjection();
//       
//       Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.pin);
//       
//       /* 원 그리기
//       Paint paint = new Paint();
//       paint.setColor(Color.RED);
//       paint.setStrokeWidth(4);
//       */
//       
//       Point point = new Point();
//       projection.toPixels(geoPoint, point);
//       
//       canvas.drawBitmap(bmp, point.x-35, point.y-65, null);
//       
//       //canvas.drawCircle(point.x, point.y, radius, paint);
//      }
//     }
//
//    }

}