Is there a way to detect if a marker is present on the google map to delete it?

I’m using Google Maps SDK to write an app in Xcode and I have markers all over my map showing different locations.

I have a UIPickerView that shows markers depending on which the user selects like so:
enter image description here

  • libMobileGestalt MobileGestaltSupport.m:153 MobileGestalt.c:550 Xcode Console
  • iOS share image AND text to WhatsApp
  • Property 'View; not found on object of type “x”
  • Handling autorotation for one view controller in iOS7
  • How to convert UTC date string to local time (systemTimeZone)
  • Core Data Fault
  • Snippet of code:

    - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
    {
        switch (row)
        {
            case 0: // Display no marker flags
            {
                ....
            }
                break;
            case 1: // Display vendor marker flags
            {
                if (isSelectedVendors == NO)
                {
                    // Mark item as selected in picker list
                    isSelectedVendors = YES;
    
                    [self addVendorMarkersToMap];
                }
                break;
            }
        ....
    }
    

    Snippet of method to load markers on map:

    - (void)addVendorMarkersToMap
    {
        // Add coordinates to know where to place markers
        NSArray *coords = [ [NSArray alloc] initWithObjects: ...];
    
        // Loop through all the coordinates and mark it on the map
        for (int i = 0; i < [coords count]; i = i + 2)
        {
            GMSMarker *marker = [ [GMSMarker alloc] init];
    
            marker.position = CLLocationCoordinate2DMake([ [coords objectAtIndex:i] floatValue], [ [coords objectAtIndex: (i + 1)] floatValue]);
            marker.appearAnimation = kGMSMarkerAnimationPop;
            marker.icon = [UIImage imageNamed:@"vendors.png"];
            marker.map = mapView;
        }
    }
    

    Google Map’s documentation doesn’t explain how to detect markers on the map.

    Since I’m using a UIPickerView to display certain markers on the map, how do I detect markers on the map to delete them and only show the markers the user selects from the UIPickerView?

    The only thing I know to do is to use [mapView clear] but then that would clear everything on the map, even the overlay that I have over the map.