Remove particular GMSMarker from GMSMapview using Google Map sdk in ios

I am integrating google maps sdk. Its all work fine. But how to remove particular Marker(Pin Point) when second will appear.(I am not using Mapkit)

I want the following:

If i tap on map then one marker pin is generate at that location now if i tap on another location on map then two pins are displayed but i want to remove the old marker pin.

I also use,

[self.mapView clear];

But it was clear all other marker points from GMSMapview.

Following is the code to add pin on Map:

            GMSMapView *mapView;
            GMSMarker *currLocMarker = [[GMSMarker alloc] init];
    = nil;
            [currLocMarker setTitle:NSLocalizedString(@"current_location_title", nil)];
            currLocMarker.icon = [UIImage imageNamed:@"pin_fetch_location.png"];
            currLocMarker.position = CLLocationCoordinate2DMake(pCoordinate.latitude, pCoordinate.longitude);
   = self.mapView;

Please help me to solve out this stuff..!!

Thanks in advance..:)


  • Yes, I got that solution. Add pin like the following:

    - (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinates {
    pCoordinate.latitude =coordinates.latitude;
    pCoordinate.longitude =coordinates.longitude;
    [[GMSGeocoder geocoder] reverseGeocodeCoordinate:CLLocationCoordinate2DMake(coordinates.latitude, coordinates.longitude) completionHandler:^(GMSReverseGeocodeResponse *resp, NSError *error)
         [currLocMarker setTitle:NSLocalizedString(@"current_location_title", nil)];
         currLocMarker.icon = [UIImage imageNamed:@"pin.png"];
         currLocMarker.position = CLLocationCoordinate2DMake(coordinates.latitude,       coordinates.longitude); = self.mapView;} ] ;}

    Please remove the following line if you used in the above:

    GMSMarker *currLocMarker = [[GMSMarker alloc] init];