0

this code is remove with click infoWindow

// Setting click event handler for InfoWIndow
        googleMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {

            @Override
            public void onInfoWindowClick(Marker marker) {
                // Remove the marker
                marker.remove();
            }
        });

but, How remove a single marker by Id without click infoWindow ? i will remove by Button View

bukanamay
  • 577
  • 5
  • 11
  • 26
  • When you are adding markers to the map, then you have to hold those markers instance for this purpose. – amit singh Jun 26 '14 at 10:28
  • check out this answer http://stackoverflow.com/questions/13692398/remove-a-marker-from-a-googlemap – mnaa Jun 26 '14 at 10:29

1 Answers1

0

Whenever you add the marker to map don't forget to keep its record, like adding it to Map or ArrayList.

your_google_map_obj.addMarker(new MarkerOptions()) //this adds Marker on Google Map, you 
should know it always returns Marker object so that you can use it later especially for 
removal

so Marker marker=your_google_map_obj.addMarker(new MarkerOptions()) add this marker object to list or map markerArraylist.add(marker); then easily you can extract marker from list by Marker marker=markerArraylist.get(index); and then call marker.remove();

Other way to do it

After adding the marker it is possible to obtain its reference:

Marker marker = map.addMarker(..);

Marker class has remove method, check this documentation

Badrul
  • 1,582
  • 4
  • 16
  • 27