Is there a way to determine if a marker is present on a google map to remove it?

I use the Google Maps SDK to write an application in Xcode, and I have markers all over my map showing different locations.

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

Code snippet:

- (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; } .... } 

A fragment of the method for loading markers on a 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; } } 

The Google Map documentation does not explain how to detect markers on a map.

Since I use UIPickerView to display specific markers on a map, how do I detect markers on a map to remove them and show only the markers that the user selects from UIPickerView?

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

+2
ios objective-c xcode google-maps
source share

No one has answered this question yet.

See similar questions:

7
Remove specific GMSMarker from GMSMapview using Google Map sdk in ios

or similar:

634
JS API Google v3 API - Simple Multiple Token Example
528
How to disable mouse wheel scaling using the Google Maps API
403
Google Maps API v3: How to remove all markers?
372
Master data: the fastest way to delete all instances of an object
369
Launching Google Maps Directions through Android Intention
345
Google Maps and JavaFX: Displaying a marker on the map after clicking the JavaFX button
2
Google Maps API V2: different InfoWindow for each marker
0
Swift - moving a GMSMarker along an array of CLCoordinates from GMSPath (SDK for Google Maps for iOS)
0
Google Maps reuse marker, but not saying it clearly?
0
Display output in a UILabel from a UIPickerView using UIButton

All Articles